Skip to main content

E360 Chart Image Client for Python

Project description

E360 Chart Image Client

pipeline status

E360 Chart Image Client for Python

Requires Python 3.12+. Packaging uses uv and pyproject.toml.

Development

Requires Python 3.12+ and uv.

This package depends on clients_core, resolved from the internal e360-pypi index (see [tool.uv.index] / [tool.uv.sources] in pyproject.toml). On a machine that can reach Artifactory, sync dependencies—for example with UV_INDEX_URL set to https://rwes-artifactory01.internal.imsglobal.com/artifactory/api/pypi/e360-pypi/simple if your tooling needs it (see clients-core README for the same pattern):

uv sync --group dev

Run tests and lint:

uv run pytest
uv run ruff check chart_image_clients tests

Introduction

Utilises the E360-ChartImage-Service microservice.

Features

  • Uses the Plotly endpoint to send requests to.
  • Returns an chart content as bytes.

Usage

An example of a full implementation

from clients_core.authentication.token_handler import OIDCTokenHandler
from clients_core.api_match_client import ApiMatchClient, MatchSpec
from clients_core.secured_rest_client import SecuredRestClient
from sd_clients.service_directory_client import ServiceDirectoryClient
from chart_image_clients import ChartImageServicePlotlyClient


token_handler = OIDCTokenHandler(
    "https://e360-identity-dev.internal.imsglobal.com:20001/connect/token",
    "<CLIENT_ID>", "<CLIENT_SECRET>", False)

rest_client = SecuredRestClient(
    "https://e360-service-directory-service-dev.internal.imsglobal.com/",
    ["service-directory-service"], token_handler, verify_ssl=False)

sd_client = ServiceDirectoryClient(rest_client)

match_client = ApiMatchClient(sd_client)

match_spec = MatchSpec("E360-ChartImage-Service", "Plotly", 1, 0, 0, ["e360_chart_image_service"])

service_rest_client = match_client.get_secured_client(
    match_spec, token_handler, extra_headers=ChartImageServicePlotlyClient.extra_headers, verify_ssl=False)

ci = ChartImageServicePlotlyClient(service_rest_client, user_id='<USER_GUID>')

payload = {
    "data": [
        {
            "x": [
                "giraffes",
                "orangutans",
                "monkeys"
            ],
            "y": [
                20,
                14,
                23
            ],
            "type": "bar"
        }
    ]
}

image_bytes = ci.get_chart_bytes(payload)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chart_image_clients-1.2.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file chart_image_clients-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chart_image_clients-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06d5b31aed3a1ca141052732dbf50fcc46af5ad347a863ec949ec2010b982bf4
MD5 683fc6afcc21c32c1ebb5333e607646e
BLAKE2b-256 fd9d5b52854cdb14ae84f423b01bf46ca2c6f0c87094a7a97d195f220c2779ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page