|
17 | 17 | The SDK acts as a wrapper for the Ray Job Submission Client.
|
18 | 18 | """
|
19 | 19 | from ray.job_submission import JobSubmissionClient
|
20 |
| -from typing import Iterator, Optional, Dict, Any, Union |
| 20 | +from ray.dashboard.modules.job.pydantic_models import JobDetails |
| 21 | +from typing import Iterator, Optional, Dict, Any, Union, List |
21 | 22 |
|
22 | 23 |
|
23 | 24 | class RayJobClient:
|
24 | 25 | """
|
25 |
| - An object for that acts as the Ray Job Submission Client. |
| 26 | + A class that functions as a wrapper for the Ray Job Submission Client. |
| 27 | +
|
| 28 | + parameters: |
| 29 | + 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(), |
| 30 | + 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. |
| 31 | + 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. |
| 32 | + cookies -- Cookies to use when sending requests to the HTTP job server. |
| 33 | + 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. |
| 34 | + headers -- Headers to use when sending requests to the HTTP job server, used for cases like authentication to a remote cluster. |
| 35 | + verify -- Boolean indication to verify the server's TLS certificate or a path to a file or directory of trusted certificates. Default: True. |
26 | 36 | """
|
27 | 37 |
|
28 | 38 | def __init__(
|
@@ -56,6 +66,16 @@ def submit_job(
|
56 | 66 | ) -> str:
|
57 | 67 | """
|
58 | 68 | Method for submitting jobs to a Ray Cluster and returning the job id with entrypoint being a mandatory field.
|
| 69 | +
|
| 70 | + Parameters: |
| 71 | + entrypoint -- The shell command to run for this job. |
| 72 | + submission_id -- A unique ID for this job. |
| 73 | + runtime_env -- The runtime environment to install and run this job in. |
| 74 | + metadata -- Arbitrary data to store along with this job. |
| 75 | + job_id -- DEPRECATED. This has been renamed to submission_id |
| 76 | + 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. |
| 77 | + 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. |
| 78 | + 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. |
59 | 79 | """
|
60 | 80 | return self.rayJobClient.submit_job(
|
61 | 81 | entrypoint=entrypoint,
|
@@ -105,7 +125,7 @@ def get_job_status(self, job_id: str) -> str:
|
105 | 125 | """
|
106 | 126 | return self.rayJobClient.get_job_status(job_id=job_id)
|
107 | 127 |
|
108 |
| - def list_jobs(self): |
| 128 | + def list_jobs(self) -> List[JobDetails]: |
109 | 129 | """
|
110 | 130 | Method for getting a list of current jobs in the Ray Cluster.
|
111 | 131 | """
|
|
0 commit comments