Skip to main content

A hypermedia-based client for the DataCybernetics PinexQ platform.

Project description

Pine-x-Q Python Client

A hypermedia-based client for the DataCybernetics PinexQ platform.

This module contains the submodules:

  • core: A generic hypermedia client (HC) to work with siren hypermedia APIs Siren on GitHub

  • job_management: Specialized HC-object (HCO) implementations for the PinexQ Job-Management API (JMA).

Installation

Install from PyPI by running

pip install pinexq-client

Setup the Client

The hypermedia client uses HTTPX as a backend. To access the API you need to provide a pre-configured HTTPX-client with a valid API key for authentication. From The API key the user and permissions are derived so do not share the API key and store it securely.

To initialize the client parts must be supplied:

  • The API key (as header)
  • The API host as URL with port if required
from httpx import Client

from hypermedia_client.job_management.enterjma import enter_jma
from hypermedia_client.job_management.hcos.entrypoint_hco import EntryPointHco


client = Client(
    base_url="https://myapihost.com:80", 
    headers={'x-api-key': '<SECRET_PAT>'}
)

# the client is now ready to be passed to function entering the API
entrypoint: EntryPointHco = enter_jma(client)

Using the API

There is a convenience layer wrapping job-management-specific objects in interface classes for ease of use. In the spirit of a hypermedia API you can also use low level calls to navigate the API.

Job-Management Interface

The main concepts of the job-management-API (e.g. "Jobs") are wrapped in

from hypermedia_client.job_management.tool import Job
from hypermedia_client.job_management.model import JobStates
job = (
    Job(client)
    .create(name="JobName")
    .select_processing(processing_step="step_function_name")
    .configure_parameters(param_name="value")
    .start()
    .wait_for_state(JobStates.completed)
)
result = job.get_result()

Raw Hypermedia API

You can navigate and use the full API with raw hypermedia primitives, e.g. when features are not yet exposed in the convenience wrapper.

from hypermedia_client.job_management.enterjma import enter_jma
from hypermedia_client.job_management.hcos.entrypoint_hco import EntryPointHco
from hypermedia_client.job_management.model import CreateJobParameters, SetJobTagsParameters

entrypoint: EntryPointHco = enter_jma(client)
# Get to jobs root
job_root = entrypoint.job_root_link.navigate()
# Create a new job
parameters = CreateJobParameters(name="Test Job")
job = job_root.create_job_action.execute(parameters).navigate()
# Edit the job's tags
job.edit_tags_action.execute(SetJobTagsParameters(tags=["test", ]))

...

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

pinexq_client-0.2.0.2024.607.8-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file pinexq_client-0.2.0.2024.607.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pinexq_client-0.2.0.2024.607.8-py3-none-any.whl
Algorithm Hash digest
SHA256 84e32b7d56ab0f073949babbce4388c59c51f1e239e1d9e2e2506de2fe0d6c45
MD5 73d01d6e8600a6ac13bf4843d8289dd2
BLAKE2b-256 4347b72ca066b75b716c94da086b10163eec650ba9b534728074a61031e7fd76

See more details on using hashes here.

Supported by

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