codeflare_sdk.ray.client package

Submodules

codeflare_sdk.ray.client.ray_jobs module

The ray_jobs sub-module contains methods needed to submit jobs and connect to Ray Clusters that were not created by CodeFlare. The SDK acts as a wrapper for the Ray Job Submission Client.

class codeflare_sdk.ray.client.ray_jobs.RayJobClient(address: str | None = None, create_cluster_if_needed: bool = False, cookies: Dict[str, Any] | None = None, metadata: Dict[str, Any] | None = None, headers: Dict[str, Any] | None = None, verify: str | bool | None = True)[source]

Bases: object

A class that functions as a wrapper for the Ray Job Submission Client.

parameters: address – Either (1) the address of the Ray cluster, or (2) the HTTP address of the dashboard server on the head node, e.g. “http://<head-node-ip>:8265”. In case (1) it must be specified as an address that can be passed to ray.init(), e.g. a Ray Client address (ray://<head_node_host>:10001), or “auto”, or “localhost:<port>”. If unspecified, will try to connect to a running local Ray cluster. This argument is always overridden by the RAY_ADDRESS environment variable. create_cluster_if_needed – Indicates whether the cluster at the specified address needs to already be running. Ray doesn’t start a cluster before interacting with jobs, but third-party job managers may do so. cookies – Cookies to use when sending requests to the HTTP job server. metadata – Arbitrary metadata to store along with all jobs. New metadata specified per job will be merged with the global metadata provided here via a simple dict update. headers – Headers to use when sending requests to the HTTP job server, used for cases like authentication to a remote cluster. verify – Boolean indication to verify the server’s TLS certificate or a path to a file or directory of trusted certificates. Default: True.

delete_job(job_id: str) -> (<class 'bool'>, <class 'str'>)[source]

Method for deleting jobs with the job id being a mandatory field.

get_address() str[source]

Method for getting the address from the RayJobClient

get_job_info(job_id: str)[source]

Method for getting the job info with the job id being a mandatory field.

get_job_logs(job_id: str) str[source]

Method for getting the job logs with the job id being a mandatory field.

get_job_status(job_id: str) str[source]

Method for getting the job’s status with the job id being a mandatory field.

list_jobs() List[JobDetails][source]

Method for getting a list of current jobs in the Ray Cluster.

stop_job(job_id: str) -> (<class 'bool'>, <class 'str'>)[source]

Method for stopping a job with the job id being a mandatory field.

submit_job(entrypoint: str, job_id: str | None = None, runtime_env: Dict[str, Any] | None = None, metadata: Dict[str, str] | None = None, submission_id: str | None = None, entrypoint_num_cpus: int | float | None = None, entrypoint_num_gpus: int | float | None = None, entrypoint_memory: int | None = None, entrypoint_resources: Dict[str, float] | None = None) str[source]

Method for submitting jobs to a Ray Cluster and returning the job id with entrypoint being a mandatory field.

Parameters: entrypoint – The shell command to run for this job. submission_id – A unique ID for this job. runtime_env – The runtime environment to install and run this job in. metadata – Arbitrary data to store along with this job. job_id – DEPRECATED. This has been renamed to submission_id entrypoint_num_cpus – The quantity of CPU cores to reserve for the execution of the entrypoint command, separately from any tasks or actors launched by it. Defaults to 0. entrypoint_num_gpus – The quantity of GPUs to reserve for the execution of the entrypoint command, separately from any tasks or actors launched by it. Defaults to 0. entrypoint_memory –- The quantity of memory to reserve for the execution of the entrypoint command, separately from any tasks or actors launched by it. Defaults to 0. entrypoint_resources – The quantity of custom resources to reserve for the execution of the entrypoint command, separately from any tasks or actors launched by it.

tail_job_logs(job_id: str) Iterator[str][source]

Method for getting an iterator that follows the logs of a job with the job id being a mandatory field.

Module contents