Job API Reference (0.26.92)
Job API Reference (0.26.92)
This is archived documentation for version 0.26.92. For the current documentation, see current documentation.
Customer-hosted cloud features
Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.
Job CLI
anyscale job submit
Usage
anyscale job submit [OPTIONS] [ENTRYPOINT]...
Submit a job.
The job config can be specified in one of the following ways:
-
Job config file can be specified as a single positional argument. E.g.
anyscale job submit config.yaml. -
Job config can also be specified with command-line arguments. In this case, the entrypoint should be specified as the positional arguments starting with
--. Other arguments can be specified with command-line flags. E.g.-
anyscale job submit -- python main.py: submit a job with the entrypointpython main.py. -
anyscale job submit --name my-job -- python main.py: submit a job with the namemy-joband the entrypointpython main.py.
-
-
[Experimental] If you want to specify a config file and override some arguments with the commmand-line flags, use the
--config-fileflag. E.g.-
anyscale job submit --config-file config.yaml: submit a job with the config inconfig.yaml. -
anyscale job submit --config-file config.yaml -- python main.py: submit a job with the config inconfig.yamland override the entrypoint withpython main.py.
-
Either containerfile or image-uri should be used, specifying both will result in an error.
By default, this command submits the job asynchronously and exits. To wait for the job to complete, use the --wait flag.
Options
-n/--name: Name of the job.-w/--wait: Block this CLI command and print logs until the job finishes.--config-file/-f: Path to a YAML config file to use for this job. Command-line flags will overwrite values read from the file.--compute-config: Named compute configuration to use for the job. This defaults to the compute configuration of the workspace.--image-uri: Container image to use for this job. When running in a workspace, this defaults to the image of the workspace.--registry-login-secret: Name or identifier of the secret containing credentials to authenticate to the docker registry hosting the image. This can only be used when 'image_uri' is specified and the image is not hosted on Anyscale.--containerfile: Path to a containerfile to build the image to use for the job.--env: Environment variables to set for the job. The format is 'key=value'. This argument can be specified multiple times. When the same key is also specified in the config file, the value from the command-line flag will overwrite the value from the config file.--working-dir: Path to a local directory or a remote URI to a .zip file (S3, GS, HTTP) that will be the working directory for the job. The files in the directory will be automatically uploaded to cloud storage. When running in a workspace, this defaults to the current working directory.-e/--exclude: File pattern to exclude when uploading local directories. This argument can be specified multiple times and the patterns will be appended to the 'excludes' list in the config file (if any).-r/--requirements: Path to a requirements.txt file containing dependencies for the job. Anyscale installs these dependencies on top of the image. If you run a job from a workspace, the default is to use the workspace dependencies, but specifying this option overrides them.--py-module: Python modules to be available for import in the Ray workers. Each entry must be a path to a local directory.--tag: Tag in key=value (or key:value) format. Repeat to add multiple.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--ray-version: The Ray version (X.Y.Z) to the image specified by --image-uri. This is only used when --image-uri is provided. If you don't specify a Ray version, Anyscale defaults to the latest Ray version available at the time of the Anyscale CLI/SDK release.--max-retries: Maximum number of retries to attempt before failing the entire job.--timeout-s/--timeout/-t: The timeout in seconds for each job run. Set to None for no limit to be set.--connection: [Beta] Third-party connection to associate with the job (e.g., Databricks). Format: type=TYPE,name=NAME. Example: --connection type=databricks,name=my-conn. Can be repeated for multiple connections. This feature is in beta preview. Contact Anyscale support to request enablement.
Examples
- CLI
# Submit a job without a yaml file, this will inherit the environment from the workspace.
$ anyscale job submit --name my-job --wait -- python main.py
Output
(anyscale +1.0s) Submitting job with config JobConfig(name='my-job', image_uri=None, compute_config=None, env_vars=None, py_modules=None, cloud=None, project=None, ray_version=None, job_queue_config=None).
(anyscale +1.7s) Uploading local dir '.' to cloud storage.
(anyscale +2.6s) Including workspace-managed pip dependencies.
(anyscale +3.2s) Job 'my-job' submitted, ID: 'prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe'.
(anyscale +3.2s) View the job in the UI: https://console.anyscale.com/jobs/prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe
(anyscale +3.2s) Waiting for the job to run. Interrupting this command will not cancel the job.
(anyscale +3.5s) Waiting for job 'prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe' to reach target state SUCCEEDED, currently in state: STARTING
(anyscale +1m19.7s) Job 'prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe' transitioned from STARTING to SUCCEEDED
(anyscale +1m19.7s) Job 'prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe' reached target state, exiting
# Submit a job specified by a yaml file, this will run a job with the specified settings.
# See the API reference for a list of all available fields.
$ cat job.yaml
name: my-job
entrypoint: python main.py
image_uri: anyscale/ray:2.44.1-slim-py312-cu128 # (Optional) Exclusive with `containerfile`.
# compute_config: # (Optional) An inline dictionary can also be provided.
# head_node:
# instance_type: m5.8xlarge
working_dir: . # (Optional) Use current working directory "." as the working_dir. Can be any local path or remote .zip file in cloud storage.
requirements: # (Optional) List of requirements files to install. Can also be a path to a requirements.txt.
- emoji
max_retries: 0 # (Optional) Maximum number of times the job will be retried before being marked failed. Defaults to `1`.
$ anyscale job submit -f job.yaml
Output
(anyscale +1.0s) Submitting job with config JobConfig(name='my-job', image_uri='anyscale/ray:2.44.1-slim-py312-cu128', compute_config=None, env_vars=None, py_modules=None, py_executable=None, cloud=None, project=None, ray_version=None, job_queue_config=None).
(anyscale +4.2s) Uploading local dir '.' to cloud storage.
(anyscale +5.4s) Job 'my-job' submitted, ID: 'prodjob_ugk21r7pt6sbsxfuxn1an82x3e'.
(anyscale +5.4s) View the job in the UI: https://console.anyscale.com/jobs/prodjob_ugk21r7pt6sbsxfuxn1an82x3e
(anyscale +5.4s) Use `--wait` to wait for the job to run and stream logs.
anyscale job status
Usage
anyscale job status [OPTIONS]
Query the status of a job.
To specify the job by name, use the --name flag. To specify the job by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
If job is specified by name and there are multiple jobs with the specified name, the most recently created job status will be returned.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--json/-j: Output the status in a structured JSON format.--verbose/-v: Include verbose details in the status.--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job status -n my-job
id: prodjob_6ntzknwk1i9b1uw1zk1gp9dbhe
name: my-job
state: STARTING
runs:
- name: raysubmit_ynxBVGT1SmzndiXL
state: SUCCEEDED
anyscale job terminate
Usage
anyscale job terminate [OPTIONS]
Terminate a job.
To specify the job by name, use the --name flag. To specify the job by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
If job is specified by name and there are multiple jobs with the specified name, the most recently created job status will be terminated.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job terminate -n my-job
(anyscale +5.4s) Marked job 'my-job' for termination
(anyscale +5.4s) Query the status of the job with `anyscale job status --name my-job`.
anyscale job archive
Usage
anyscale job archive [OPTIONS]
Archive a job.
To specify the job by name, use the --name flag. To specify the job by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
If job is specified by name and there are multiple jobs with the specified name, the most recently created job status will be archived.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job archive -n my-job
(anyscale +8.5s) Job prodjob_vzq2pvkzyz3c1jw55kl76h4dk1 is successfully archived.
anyscale job delete
Usage
anyscale job delete [OPTIONS]
Delete a job and all associated job runs.
The job must be in a terminal state (SUCCEEDED, FAILED) before deletion. This action permanently removes the job and cannot be undone.
To specify the job by name, use the --name flag. To specify by ID, use --id. Either name or ID must be provided, but not both.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--cloud: The Anyscale Cloud of this workload. If not provided, the organization default will be used.--project: Named project to use for the job. If not provided, the default project will be used.--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job delete -n my-job
(anyscale +3.2s) Job 'my-job' (ID: prodjob_abc123) has been deleted.
anyscale job logs
Usage
anyscale job logs [OPTIONS]
Print the logs of a job.
By default from the latest job attempt.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--run: Name of the job run.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--head: Used with --max-lines to getmax-lineslines from the head of the log.--tail: Used with --max-lines to getmax-lineslines from the tail of the log.--max-lines: Used with --head or --tail to limit the number of lines output.--follow/-f: Whether to follow the log.--all-attempts: Listing logs from all attempts no longer supported, instead list jobs by run name.--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job logs -n my-job
2024-08-23 20:31:10,913 INFO job_manager.py:531 -- Runtime env is setting up.
hello world
anyscale job wait
Usage
anyscale job wait [OPTIONS]
Wait for a job to enter a specific state (default: SUCCEEDED).
To specify the job by name, use the --name flag. To specify the job by id, use the --id flag.
If the job reaches the target state, the command will exit successfully.
If the job reaches a terminal state other than the target state, the command will exit with an error.
If the command reaches the timeout, the command will exit with an error but job execution will continue.
Options
--id/--job-id: Unique ID of the job.--name/-n: Name of the job.--cloud: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project: Named project to use for the job. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).--state/-s: The state to wait for this job to enter--timeout-s/--timeout/-t: The timeout in seconds after which this command will exit.--include-archived: Include archived jobs when searching by name. Ignored when using --id.
Examples
- CLI
$ anyscale job wait -n my-job
(anyscale +5.7s) Waiting for job 'my-job' to reach target state SUCCEEDED, currently in state: STARTING
(anyscale +1m34.2s) Job 'my-job' transitioned from STARTING to SUCCEEDED
(anyscale +1m34.2s) Job 'my-job' reached target state, exiting
anyscale job list
Usage
anyscale job list [OPTIONS]
Display information about existing jobs.
Options
--v2: [RECOMMENDED] Enable extended filtering options. Needs migration to match return values.--name/-n: Filter by job name.--id/--job-id: Filter by job id.--project-id: Filter by project ID. Use --project instead.--project: Filter by project name. Only with --v2 flag.--cloud: Filter by cloud name. Only with --v2 flag.--include-all-users: Include jobs not created by current user.--include-archived: List archived jobs as well as unarchived jobs.If not provided, defaults to listing only unarchived jobs.--tag: This option can be repeated to filter by multiple tags. Tags with the same key are ORed, whereas tags with different keys are ANDed. Example: --tag team:mlops --tag team:infra --tag env:prod. Filters with team: (mlops OR infra) AND env:prod.--max-items: Max total items (only with --no-interactive).--state/-s: Filter jobs by state. Accepts one or more states. With --v2, use: STARTING, RUNNING, SUCCEEDED, FAILED. Without --v2, use: PENDING, AWAITING_CLUSTER_START, UPDATING, RUNNING, SUCCESS, ERRORED, TERMINATED, CLEANING_UP, BROKEN, OUT_OF_RETRIES, RESTARTING.--page-size: Number of items per page (1-50). Defaults to 10. Only with --v2.--sort: Sort by field. Prefix with '-' for descending order. Defaults to -created_at. Allowed: STATUS, CREATED_AT, LAST_UPDATED_AT, LAST_STATUS_UPDATED_AT, ENDED_AT, NAME, ID. Only with --v2.--created-at-from: Filter for jobs created at or after this time (ISO 8601, e.g. 2024-01-01T00:00:00Z). Only with --v2.--created-at-to: Filter for jobs created at or before this time (ISO 8601, e.g. 2024-12-31T23:59:59Z). Only with --v2.--updated-at-from: Filter for jobs last updated at or after this time (ISO 8601, e.g. 2024-01-01T00:00:00Z). Only with --v2.--updated-at-to: Filter for jobs last updated at or before this time (ISO 8601, e.g. 2024-12-31T23:59:59Z). Only with --v2.--status-updated-at-from: Filter for jobs whose status was last updated at or after this time (ISO 8601, e.g. 2024-01-01T00:00:00Z). Only with --v2.--status-updated-at-to: Filter for jobs whose status was last updated at or before this time (ISO 8601, e.g. 2024-12-31T23:59:59Z). Only with --v2.--json/-j: Output results as JSON. Only with --v2.--interactive/--no-interactive: Enable interactive pagination. Only with --v2.
Examples
- CLI
$ anyscale job list -n my-job
Output
View your Jobs in the UI at https://console.anyscale.com/jobs
JOBS:
NAME ID COST PROJECT NAME CLUSTER NAME CURRENT STATE CREATOR ENTRYPOINT
my-job prodjob_s9x4uzc5jnkt5z53g4tujb3y2e 0 default cluster_for_prodjob_s9x4uzc5jnkt5z53g4tujb3y2e SUCCESS doc@anyscale.com python main.py