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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for chart_image_clients-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 440068a6325b24b3b24d3c587fe7670c9a7bb0b212664c4e31298110475b6feb
MD5 2fe3c9577d9082db57fe88dd1191aeec
BLAKE2b-256 24bee4134671805fd7657946b33acecde2217eaf32368bd309055faf62df2a36

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