Skip to main content

Python client for Run:ai REST API

Project description

runapy

This project provides a Python client to interact with the Run:ai REST API.

The client offers:

  • A single class interface to perform all API actions
  • Body scheme validation on compilation (with Pydantic)
  • Static type checks
  • Retry mechanism for resiliency on intermittent network errors
  • Debug messages flag

Requirements:

Note on token and permissions

When creating an application, it is important to select the relevant role and scope for the required API actions.
Some API calls may fail with 403 if the application token has no sufficient permissions.

Installation

runapy is avaialble in PyPi and can be downloaded directly as a python package

pip3 install runapy

Client

RunaiClient is the only class required to interact with the Run:ai REST API

from runai.client import RunaiClient

client = RunaiClient(
            realm="myorgrealm",
            client_id="API"
            client_secret="clientsecret",
            runai_base_url="https://myorg.run.ai",
            cluster_id="513423qx-127t-4yk6-979g-5po843g37e2b",
            retries=3,
            debug=False
    )
Parameter Type Description
realm string Required: Can be obtained from the UI login screen at your Run:ai domain app.run.ai -> app.run.ai/auth/realms/
client_id string Required: The Run:ai application name
client_secret string Required: The Run:ai application password
runai_base_url string Required: The URL used to access Run:ai UI
retries int Required: Number of retries to attempt on each failed API call for 5xx errors
debug bool Optional: Debug mode output

Note on Controllers

The RuaniClient exposes object controllers for all API endpoints. For example, to access projects:

from runai.client import RunaiClient

client = RunaiClient(
            realm="myorgrealm",
            client_id="API",
            client_secret="clientsecret",
            runai_base_url="https://myorg.run.ai",
            cluster_id="513423qx-127t-4yk6-979g-5po843g37e2b",
            retries=3,
            debug=False
    )

client.projects.all()

client.projects.all() returns a list of all projects in a given cluster according to the cluster id of the RunaiClient.

Currently supported controllers:

client.projects
client.node_pools
client.departments
client.access_rules
client.roles
client.users

client.workloads
client.workspace
client.training
client.inference
client.distributed

Each controller exposes the function options() so you can see which methods are currently availalble for a given controller.
For example:

client.roles.options()
-> 
['all', 'get', 'get_roles_name_to_id_map']

Controller methods are documented.
Hover on the method parentheses to see the required and optional fields to pass to the function

Examples

For more examples, check the existing examples here
Feel free to copy and run them as is, moify them as you wish, or use them as a reference.

Warranty

This package is not maintained by the Run:ai product.

For any issues and requests, please open an issue, or contact the authors of this package.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

runapy-0.2.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

runapy-0.2.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file runapy-0.2.1.tar.gz.

File metadata

  • Download URL: runapy-0.2.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for runapy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5e8c1c0c0381c338fbc7f1fcfdb59551373be2e4c6973b8e4ed0a063a250dd8b
MD5 1eb8040df3c9d2a87af8268be999ffe8
BLAKE2b-256 2c80f6327553d6078b41292ccbe1ae554a77943b32c34bc592d9568cb9149395

See more details on using hashes here.

File details

Details for the file runapy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: runapy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for runapy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64179fdfcdd5380ef13fa389dcab4fcee432fa1ce7cd9f5d0ee9a6d14675a840
MD5 bc8f035bb5e61e3b35ae29ee0c5bf2b9
BLAKE2b-256 bc386536d4bc7a8eab103c1ad789440ffe26f753e314c1ebeb5ec8db76bc948c

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