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 classs 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.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

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

Uploaded Source

Built Distribution

runapy-0.2.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: runapy-0.2.0.tar.gz
  • Upload date:
  • Size: 12.9 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.0.tar.gz
Algorithm Hash digest
SHA256 378113995ae4bc19e6c6284b8baef6c799383495e2b00af693de231fa604273e
MD5 05bec842683923f0f2dee5bfe2f57f71
BLAKE2b-256 0cde4a74574908b23e773291f67460abb50004ee7374e0b40e45a56dae8c2cce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: runapy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27e236118ab7855bf72baa972549f76931279a1dc3922856e5d4d08c5d73ab55
MD5 17411b15163f59bb47db9da6c77c1b14
BLAKE2b-256 0437137d342a4d0c1bf6a490dec53dc099e41273f2d674de781f0f0dca8ed4d5

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