ray.job_submission.JobSubmissionClient.submit_job#

JobSubmissionClient.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]#

Submit and execute a job asynchronously.

When a job is submitted, it runs once to completion or failure. Retries or different runs with different parameters should be handled by the submitter. Jobs are bound to the lifetime of a Ray cluster, so if the cluster goes down, all running jobs on that cluster will be terminated.

Example

>>> from ray.job_submission import JobSubmissionClient
>>> client = JobSubmissionClient("http://127.0.0.1:8265") 
>>> client.submit_job( 
...     entrypoint="python script.py",
...     runtime_env={
...         "working_dir": "./",
...         "pip": ["requests==2.26.0"]
...     }
... )  
'raysubmit_4LamXRuQpYdSMg7J'
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.

Returns:

The submission ID of the submitted job. If not specified, this is a randomly generated unique ID.

Raises:

RuntimeError – If the request to the job server fails, or if the specified submission_id has already been used by a job on this cluster.