Job API Reference (Legacy)
Job API Reference (Legacy)
These APIs are legacy and deprecated. Please use the current APIs instead.
Job SDK
The AnyscaleSDK class must be constructed in order to make calls to the SDK. This class allows you to create an authenticated client in which to use the SDK.
Param | Type | Description |
---|---|---|
auth_token | Optional String | Authentication token used to verify you have permissions to access Anyscale. If not provided, permissions default to the credentials set for your current user. Credentials can be set by following the instructions on this page: https://console.anyscale.com/credentials |
Example
from anyscale import AnyscaleSDK
sdk = AnyscaleSDK()
create_job
Create an Production Job
Parameters
Name | Type | Description | Notes |
---|---|---|---|
create_production_job | CreateProductionJob |
Returns ProductionjobResponse
get_production_job
Get an Production Job
Parameters
Name | Type | Description | Notes |
---|---|---|---|
production_job_id | str | Defaults to null |
Returns ProductionjobResponse
terminate_job
Terminate an Production Job
Parameters
Name | Type | Description | Notes |
---|---|---|---|
production_job_id | str | Defaults to null |
Returns ProductionjobResponse
fetch_job_logs
Retrieves logs for a Job.
This function may take several minutes if the Cluster this Job ran on has been terminated.
Returns the log output as a string.
Raises an Exception if fetching logs fails.
Param | Type | Description |
---|---|---|
job_id | String | ID of the Job |
Example
from anyscale import AnyscaleSDK
sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")
job_logs = sdk.fetch_job_logs(job_id="job_id")
print(job_logs)
fetch_production_job_logs
Retrieves logs for a Production Job.
This function may take several minutes if the Cluster this Production Job ran on has been terminated.
Returns the log output as a string.
Raises an Exception if fetching logs fails.
Param | Type | Description |
---|---|---|
job_id | String | ID of the Job |
Example
from anyscale import AnyscaleSDK
sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")
job_logs = sdk.fetch_production_job_logs(job_id="production_job_id")
print(job_logs)
get_job_logs_download
Parameters
Name | Type | Description | Notes |
---|---|---|---|
job_id | str | Defaults to null | |
all_logs | optional bool | Whether to grab all logs. | Defaults to true |
Returns LogdownloadresultResponse
get_job_logs_stream
Parameters
Name | Type | Description | Notes |
---|---|---|---|
job_id | str | Defaults to null |
Returns LogstreamResponse
search_jobs
DEPRECATED: This API is now deprecated. Use list_production_jobs instead.
Parameters
Name | Type | Description | Notes |
---|---|---|---|
jobs_query | JobsQuery |
Returns JobListResponse
list_production_jobs
Parameters
Name | Type | Description | Notes |
---|---|---|---|
project_id | optional str | project_id to filter by | Defaults to null |
name | optional str | name to filter by | Defaults to null |
state_filter | List[HaJobStates] | A list of session states to filter by | Defaults to [] |
creator_id | optional str | filter by creator id | Defaults to null |
paging_token | optional str | Defaults to null | |
count | optional int | Defaults to null |
Returns ProductionjobListResponse
Job Models
BaseJobStatus
An enumeration.
Possible Values: ['RUNNING', 'COMPLETED', 'PENDING', 'STOPPED', 'SUCCEEDED', 'FAILED', 'UNKNOWN']
CreateClusterComputeConfig
Configuration of compute resources to use for launching a Cluster. Used when creating a cluster compute.
Name | Type | Description | Notes |
---|---|---|---|
cloud_id | str | The ID of the Anyscale cloud to use for launching Clusters. | [default to null] |
maximum_uptime_minutes | int | If set to a positive number, Anyscale will terminate the cluster this many minutes after cluster start. | [optional] [default to null] |
deployment_configs | List[CloudDeploymentComputeConfig] | A list of cloud deployment-specific configs to use. | [optional] [default to null] |
max_workers | int | DEPRECATED. This attribute will be ignored - please use the "max_resources" flag to configure resource limits. | [optional] [default to null] |
region | str | Deprecated! When creating a cluster compute, a region does not have to be provided. Instead we will use the value from the cloud. | [optional] [default to USE_CLOUD] |
allowed_azs | List[str] | The availability zones that sessions are allowed to be launched in, e.g. "us-west-2a". If not specified or "any" is provided as the option, any AZ may be used. If "any" is provided, it must be the only item in the list. | [optional] [default to null] |
head_node_type | ComputeNodeType | Node configuration to use for the head node. | [default to null] |
worker_node_types | List[WorkerNodeType] | A list of node types to use for worker nodes. | [optional] [default to null] |
aws_advanced_configurations_json | object | [DEPRECATED: use advanced_configurations_json instead] The advanced configuration json that we pass directly AWS APIs when launching an instance. We may do some validation on this json and reject the json if it is using a configuration that Anyscale does not support. | [optional] [default to null] |
gcp_advanced_configurations_json | object | [DEPRECATED: use advanced_configurations_json instead] The advanced configuration json that we pass directly GCP APIs when launching an instance. We may do some validation on this json and reject the json if it is using a configuration that Anyscale does not support. | [optional] [default to null] |
advanced_configurations_json | object | Advanced configurations for this compute node type to pass to the cloud provider when launching this instance. | [optional] [default to null] |
auto_select_worker_config | bool | If set to true, worker node groups will automatically be selected based on workload. | [optional] [default to false] |
flags | object | A set of advanced cluster-level flags that can be used to configure a particular workload. | [optional] [default to null] |
idle_termination_minutes | int | If set to a positive number, Anyscale will terminate the cluster this many minutes after the cluster is idle. Idle time is defined as the time during which a Cluster is not running a user command or a Ray driver. Time spent running commands on Jupyter or ssh is still considered 'idle'. To disable, set this field to 0. | [optional] [default to 120] |
CreateJobQueueConfig
Specifies configuration of the job being added to a Job Queue
Name | Type | Description | Notes |
---|---|---|---|
priority | int | Job's relative priority (only relevant for Job Queues of type PRIORITY). Valid values range from 0 (highest) to +inf (lowest). Default value is None | [optional] [default to null] |
target_job_queue_id | str | Identifier of the existing Job Queue this job should be added to. Note, only one of `target_job_queue_id`, `target_job_queue_name` or `job_queue_spec` could be provided | [optional] [default to null] |
target_job_queue_name | str | Existing Job Queue user-provided name (identifier), this job should be added to. Note, only one of `target_job_queue_id`, `target_job_queue_name` or `job_queue_spec` could be provided | [optional] [default to null] |
job_queue_spec | JobQueueSpec | Spec of the Job Queue definition that should be created and associated with this job. Note, only one of `target_job_queue_id`, `target_job_queue_name` or `job_queue_spec` could be provided | [optional] [default to null] |
CreateProductionJob
Name | Type | Description | Notes |
---|---|---|---|
name | str | Name of the job | [default to null] |
description | str | Description of the job | [optional] [default to null] |
project_id | str | Id of the project this job will start clusters in | [optional] [default to null] |
config | CreateProductionJobConfig | [default to null] | |
job_queue_config | CreateJobQueueConfig | Configuration specifying semantic of the execution using job queues | [optional] [default to null] |
CreateProductionJobConfig
Name | Type | Description | Notes |
---|---|---|---|
entrypoint | str | A script that will be run to start your job.This command will be run in the root directory of the specified runtime env. Eg. 'python script.py' | [optional] [default to ] |
ray_serve_config | object | The Ray Serve config to use for this Production service. This config defines your Ray Serve application, and will be passed directly to Ray Serve. You can learn more about Ray Serve config files here: https://docs.ray.io/en/latest/serve/production-guide/config.html | [optional] [default to null] |
runtime_env | RayRuntimeEnvConfig | A ray runtime env json. Your entrypoint will be run in the environment specified by this runtime env. | [optional] [default to null] |
build_id | str | The id of the cluster env build. This id will determine the docker image your job is run on. | [default to null] |
compute_config_id | str | The id of the compute configuration that you want to use. This id will specify the resources required for your job | [optional] [default to null] |
compute_config | CreateClusterComputeConfig | One-off compute that the cluster will use. | [optional] [default to null] |
max_retries | int | The number of retries this job will attempt on failure. Set to None to set infinite retries | [optional] [default to 5] |
timeout_s | int | The timeout in seconds for each job run. Set to None for no limit to be set | [optional] [default to null] |
runtime_env_config | RayRuntimeEnvConfig | DEPRECATED: Use runtime_env | [optional] [default to null] |
HaJobGoalStates
An enumeration.
Possible Values: ['SCHEDULED', 'RUNNING', 'TERMINATED', 'SUCCESS']
HaJobStates
An enumeration.
Possible Values: ['PENDING', 'AWAITING_CLUSTER_START', 'UPDATING', 'RUNNING', 'SUCCESS', 'ERRORED', 'TERMINATED', 'CLEANING_UP', 'BROKEN', 'OUT_OF_RETRIES', 'RESTARTING']
Job
Name | Type | Description | Notes |
---|---|---|---|
id | str | Server assigned unique identifier. | [default to null] |
ray_session_name | str | Name of the Session provided from Ray | [default to null] |
ray_job_id | str | ID of the Job provided from Ray | [default to null] |
name | str | Name of this Job. | [optional] [default to null] |
status | JobStatus | Status of this Job's execution. | [default to null] |
created_at | datetime | Time at which this Job was created. | [default to null] |
finished_at | datetime | Time at which this Job finished. If absent, this Job is still running. | [optional] [default to null] |
ray_job_submission_id | str | ID of the submitted Ray Job that this Job corresponds to. | [optional] [default to null] |
cluster_id | str | ID of the Anyscale Cluster this Job is on. | [default to null] |
namespace_id | str | ID of the Anyscale Namespace this Job is using. | [optional] [default to DEPRECATED_NAMESPACE_ID] |
runtime_environment_id | str | ID of the Anyscale Runtime Environment this Job is using. | [default to null] |
project_id | str | ID of the Project this Job belongs to. | [optional] [default to null] |
creator_id | str | ID of the user who created this Job. | [default to null] |
JobListResponse
A list response form the API. Contains a field "results" which has the contents of the response.
Name | Type | Description | Notes |
---|---|---|---|
results | List[Job] | [default to null] | |
metadata | ListResponseMetadata | [optional] [default to null] |
JobQueueConfig
Captures job's configuration in the context of its scheduling & execution via Job Queues
Name | Type | Description | Notes |
---|---|---|---|
priority | int | Job's relative priority (only relevant for Job Queues of type PRIORITY). Valid values range from 0 (highest) to +inf (lowest). Default value is None | [optional] [default to null] |
JobQueueExecutionMode
An enumeration.
Possible Values: ['FIFO', 'LIFO', 'PRIORITY']
JobQueueSpec
Specifies definition of the Job Queue to be created
Name | Type | Description | Notes |
---|---|---|---|
job_queue_name | str | Optional user-provided identifier of the queue that could be subsequently used to reference the queue when submitting jobs. Note that name has to be unique within the project. | [optional] [default to null] |
execution_mode | JobQueueExecutionMode | Execution mode of the jobs submitted into the queue (one of: FIFO,LIFO,PRIORITY | [optional] [default to null] |
compute_config_id | str | The id of the compute configuration that will be used to create cluster associated with the queue. Defaults to default compute config in the given project | [optional] [default to null] |
cluster_environment_build_id | str | The id of the cluster environment build that will be used to create cluster associated with the queue. | [optional] [default to null] |
max_concurrency | int | Max number of jobs to be run concurrently. Defaults to 1, ie running no more than 1 job at a time. | [optional] [default to 1] |
idle_timeout_sec | int | Max period of time queue will be accepting new jobs, before being sealed off and its associated cluster being shutdown | [default to null] |
auto_termination_threshold_job_count | int | Maximum number of jobs the cluster can run before it becomes eligible for termination. | [optional] [default to null] |
JobRunType
An enumeration.
Possible Values: ['INTERACTIVE_SESSION', 'RUN', 'RAY_SUBMIT']
JobStatus
An enumeration.
Possible Values: ['RUNNING', 'COMPLETED', 'PENDING', 'STOPPED', 'SUCCEEDED', 'FAILED', 'UNKNOWN']
JobsSortField
An enumeration.
Possible Values: ['STATUS', 'CREATED_AT', 'FINISHED_AT', 'NAME', 'ID']
ProductionJob
Model of a Production Job for use in the SDK.
Name | Type | Description | Notes |
---|---|---|---|
id | str | The id of this job | [default to null] |
name | str | Name of the job | [default to null] |
description | str | Description of the job | [optional] [default to null] |
created_at | datetime | The time this job was created | [default to null] |
creator_id | str | The id of the user who created this job | [default to null] |
config | ProductionJobConfig | The config that was used to create this job | [default to null] |
job_queue_config | JobQueueConfig | Job Queue configuration of this job (if applicable) | [optional] [default to null] |
state | ProductionJobStateTransition | The current state of this job | [default to null] |
project_id | str | Id of the project this job will start clusters in | [default to null] |
last_job_run_id | str | The id of the last job run | [optional] [default to null] |
schedule_id | str | If the job was launched via Scheduled job, this will contain the id of that schedule. | [optional] [default to null] |
job_queue_id | str | Id of the job queue this job is being enqueued to | [optional] [default to null] |
ProductionJobConfig
Name | Type | Description | Notes |
---|---|---|---|
entrypoint | str | A script that will be run to start your job.This command will be run in the root directory of the specified runtime env. Eg. 'python script.py' | [optional] [default to ] |
ray_serve_config | object | The Ray Serve config to use for this Production service. This config defines your Ray Serve application, and will be passed directly to Ray Serve. You can learn more about Ray Serve config files here: https://docs.ray.io/en/latest/serve/production-guide/config.html | [optional] [default to null] |
runtime_env | RayRuntimeEnvConfig | A ray runtime env json. Your entrypoint will be run in the environment specified by this runtime env. | [optional] [default to null] |
build_id | str | The id of the cluster env build. This id will determine the docker image your job is run on. | [default to null] |
compute_config_id | str | The id of the compute configuration that you want to use. This id will specify the resources required for your job | [default to null] |
compute_config | CreateClusterComputeConfig | One-off compute that the cluster will use. | [optional] [default to null] |
max_retries | int | The number of retries this job will attempt on failure. Set to None to set infinite retries | [optional] [default to 5] |
timeout_s | int | The timeout in seconds for each job run. Set to None for no limit to be set | [optional] [default to null] |
runtime_env_config | RayRuntimeEnvConfig | DEPRECATED: Use runtime_env | [optional] [default to null] |
ProductionJobStateTransition
Name | Type | Description | Notes |
---|---|---|---|
id | str | The id of this job state transition | [default to null] |
state_transitioned_at | datetime | The last time the state of this job was updated | [default to null] |
current_state | HaJobStates | The current state of the job | [default to null] |
goal_state | HaJobGoalStates | The goal state of the job | [optional] [default to null] |
error | str | An error message that occurred in this job state transition | [optional] [default to null] |
operation_message | str | The logging message for this job state transition | [optional] [default to null] |
cluster_id | str | The id of the cluster the job is running on | [optional] [default to null] |
ProductionjobListResponse
A list response form the API. Contains a field "results" which has the contents of the response.
Name | Type | Description | Notes |
---|---|---|---|
results | List[ProductionJob] | [default to null] | |
metadata | ListResponseMetadata | [optional] [default to null] |
ProductionjobResponse
A response from the API. Contains a field "result" which has the contents of the response.
Name | Type | Description | Notes |
---|---|---|---|
result | ProductionJob | [default to null] |
RayRuntimeEnvConfig
A runtime env config. Can be used to start a production job.
Name | Type | Description | Notes |
---|---|---|---|
working_dir | str | The working directory that your code will run in. Must be a remote URI like an s3 or git path. | [optional] [default to null] |
py_modules | List[str] | Python modules that will be installed along with your runtime env. These must be remote URIs. | [optional] [default to null] |
relative_working_dir | str | Relative path to the working directory that your code will run in. The appropriate cloud deployment object storage will be prepended to this path. | [optional] [default to null] |
relative_py_modules | List[str] | Relative paths to python modules that will be installed along with your runtime env. The appropriate cloud deployment object storage will be prepended to these paths. If `py_modules` are specified, they will be also be installed. | [optional] [default to null] |
py_executable | str | Specifies the executable used for running the Ray workers. It can include arguments as well. | [optional] [default to null] |
pip | List[str] | A list of pip packages to install. | [optional] [default to null] |
conda | object | [Union[Dict[str, Any], str]: Either the conda YAML config or the name of a local conda env (e.g., "pytorch_p36"), | [optional] [default to null] |
env_vars | Dict(str, str) | Environment variables to set. | [optional] [default to null] |
config | object | Config for runtime environment. Can be used to setup setup_timeout_seconds, the timeout of runtime environment creation. | [optional] [default to null] |
image_uri | str | Specifies the image URI of the container in which the job will run. | [optional] [default to null] |
SortByClauseJobsSortField
This model is used in the backend to represent the SQL ORDER BY clauses.
Name | Type | Description | Notes |
---|---|---|---|
sort_field | JobsSortField | [default to null] | |
sort_order | SortOrder | [default to null] |