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.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: runapy-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b7ab1a8a600b06d16dfa8b58bc2de22b6071ea3c8f861a3a69054ee1717adb2e
MD5 2f1c03c0c640542ac71d4bb0e8da280f
BLAKE2b-256 9ecc0c937325b363c09827c7ed4b7dd4c25e59dd4c107ef2bfc0a0baff70f70b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: runapy-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e08bf7ee65b67e3820cf80e4fa133bd5e8c6355485f75d86dd0d8af11b68b78
MD5 4fe391629e04d92cfd63a954ac76e8be
BLAKE2b-256 9df7566d1999ecd999515b2330e883a5c182122a05c4612be67fea66849d21ce

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