Schedule API Reference
Customer-hosted cloud features
Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.
Schedule CLI
anyscale schedule apply
Usage
anyscale schedule apply [OPTIONS]
Create or Update a Schedule
The schedule should be specified in a YAML config file.
Options
--config-file/-f
: Path to a YAML config file to use for this schedule. Command-line flags will overwrite values read from the file.--name/-n
: Name of the schedule.
Examples
- CLI
$ anyscale schedule apply -n my-schedule -f my-schedule.yaml
(anyscale +0.5s) Applying schedule with config ScheduleConfig(job_config=JobConfig(name='my-schedule', image_uri=None, compute_config=None, env_vars=None, py_modules=None, cloud=None, project=None, ray_version=None, job_queue_config=None), cron_expression='0 0 * * * *', timezone='UTC').
(anyscale +2.3s) Uploading local dir '.' to cloud storage.
(anyscale +3.7s) Including workspace-managed pip dependencies.
(anyscale +4.9s) Schedule 'my-schedule' submitted, ID: 'cronjob_vrjrbwcnfjjid7fsld3sfkn8jz'.
$ cat my-schedule.yaml
timezone: local
cron_expression: 0 0 * * * *
job_config:
name: my-job
entrypoint: python main.py
max_retries: 5
anyscale schedule list
Usage
anyscale schedule list [OPTIONS]
List Schedules
You can optionally filter schedules by rowname.
Options
--name/-n
: Filter by the name of the job--id/-i
: Id of the schedule.
Examples
- CLI
$ anyscale schedule list -n my-schedule
Output
+------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------+
| ID | NAME | DESCRIPTION | PROJECT | CRON | NEXT TRIGGER | TIMEZONE | CREATOR | LATEST EXECUTION ID |
|------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------|
| cronjob_vrjrbwcnfjjid7fsld3sfkn8jz | my-schedule | | default | 0 0 * * * * | 2 hours from now | UTC | doc@anyscale.com | |
+------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------+
anyscale schedule pause
Usage
anyscale schedule pause [OPTIONS]
Pause a Schedule.
You can pause a schedule by config file, name, or id.
To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.
To specify the schedule by id, use the --id flag.
To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.
Options
--config-file/-f
: Path to a YAML config file to use for this schedule.--name/-n
: Name of the schedule.--id/-i
: Id of the schedule.--cloud
: The named Anyscale Cloud for the schedule. 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 schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Examples
- CLI
$ anyscale schedule pause -n my-schedule
(anyscale +3.6s) Set schedule 'my-schedule' to state DISABLED
anyscale schedule resume
Usage
anyscale schedule resume [OPTIONS]
Resume a Schedule
You can resume a schedule by config file, name, or id.
To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.
To specify the schedule by id, use the --id flag.
To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.
Options
--config-file/-f
: Path to a YAML config file to use for this schedule.--name/-n
: Name of the schedule.--id/-i
: Id of the schedule.--cloud
: The named Anyscale Cloud for the schedule. 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 schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Examples
- CLI
$ anyscale schedule resume -n my-schedule
(anyscale +4.1s) Set schedule 'my-schedule' to state ENABLED
anyscale schedule status
Usage
anyscale schedule status [OPTIONS]
Query the status of a Schedule.
You can query the status of a schedule by config file, name, or id.
To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.
To specify the schedule by id, use the --id flag.
To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.
Options
--config-file/-f
: Path to a YAML config file to use for this schedule.--name/-n
: Name of the schedule.--id/-i
: Id of the schedule.--cloud
: The named Anyscale Cloud for the schedule. 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 schedule. 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.
Examples
- CLI
$ anyscale schedule status -n my-schedule
id: cronjob_vrjrbwcnfjjid7fsld3sfkn8jz
name: my-schedule
state: ENABLED
anyscale schedule run
Usage
anyscale schedule run [OPTIONS]
Manually run a Schedule
This function takes an existing schedule and runs it now.
You can specify the schedule by name or id.
You can also pass in a YAML file as a convinience. This is equivalent to passing in the name specified in the YAML file.
IMPORTANT: if you pass in a YAML definition that differs from the Schedule defition, the Schedule will NOT be updated.
Please use the anyscale schedule apply
command to update the configuration of your schedule
or use the anyscale job submit
command to submit a one off job that is not a part of a schedule.
Options
--config-file/-f
: Path to a YAML config file to use for this schedule.--name/-n
: Name of the schedule.--id/-i
: Id of the schedule.--cloud
: The named Anyscale Cloud for the schedule. 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 schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Examples
- CLI
$ anyscale schedule run -n my-schedule
(anyscale +2.5s) Triggered job for schedule 'my-schedule'.
anyscale schedule url
Usage
anyscale schedule url [OPTIONS] [SCHEDULE_CONFIG_FILE]
Get a Schedule URL
This function accepts 1 argument, a path to a YAML config file that defines this schedule. You can also specify the schedule by name or id.
Options
--name/-n
: Name of the schedule.--id/-i
: Id of the schedule.
Examples
- CLI
$ anyscale schedule url -n my-schedule
Output
(anyscale +2.3s) View your schedule at https://console.anyscale.com/scheduled-jobs/cronjob_7zj
Schedule SDK
anyscale.schedule.apply
Apply or update a schedule.
Returns the id of the schedule.
Arguments
config
(ScheduleConfig): The config options defining the schedule.
Returns: str
Examples
- Python
import anyscale
from anyscale.job.models import JobConfig
from anyscale.schedule.models import ScheduleConfig
anyscale.schedule.apply(
ScheduleConfig(
cron_expression="0 0 * * * *",
job_config=JobConfig(
name="my-job",
entrypoint="python main.py",
working_dir=".",
)
)
)
anyscale.schedule.set_state
Set the state of a schedule.
Returns the id of the schedule.
Arguments
id
(str | None) = None: The id of the schedule.name
(str | None) = None: The name of the schedule.cloud
(str | None) = None: 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
(str | None) = None: 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
(ScheduleState): The state to set the schedule to.
Returns: str
Examples
- Python
import anyscale
from anyscale.schedule.models import ScheduleState
anyscale.schedule.set_state(
id="my=schedule-id",
state=ScheduleState.DISABLED,
)
anyscale.schedule.status
Return the status of the schedule.
Arguments
id
(str | None) = None: The id of the schedule.name
(str | None) = None: The name of the schedule.cloud
(str | None) = None: 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
(str | None) = None: 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).
Returns: ScheduleStatus
Examples
- Python
import anyscale
anyscale.schedule.status(id="cronjob_yt389jvskwht9k2ygx7rj6iz62")
anyscale.schedule.trigger
Trigger the execution of the schedule.
Arguments
id
(str | None) = None: The id of the schedule.name
(str | None) = None: The name of the schedule.cloud
(str | None) = None: 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
(str | None) = None: 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).
Returns: str
Examples
- Python
import anyscale
anyscale.schedule.trigger(id="cronjob_yt389jvskwht9k2ygx7rj6iz62")
Schedule Models
ScheduleConfig
Configuration options for a schedule.
Fields
job_config
(Dict | JobConfig): Configuration of the job.cron_expression
(str): A cron expression to define the frequency at which to run this cron job, for example '0 0 * * *' is a cron expression that means 'run at midnight'. Visit crontab.guru to construct a precise cron_expression.timezone
(str): The timezone in which to interpret the cron_expression. Default is Universal time (UTC). You can specify 'local' to use the local timezone
Python Methods
def __init__(self, **fields) -> ScheduleConfig
"""Construct a model with the provided field values set."""
def options(self, **fields) -> ScheduleConfig
"""Return a copy of the model with the provided field values overwritten."""
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- YAML
- Python
timezone: local
cron_expression: 0 0 * * * *
job_config:
name: my-schedule-job
entrypoint: python main.py
max_retries: 5
from anyscale.schedule.models import ScheduleConfig
from anyscale.job.models import JobConfig
config = ScheduleConfig(
job_config=JobConfig(
entrypoint="python main.py"
),
timezone="local",
cron_expression="0 0 * * *"
)
ScheduleState
Current state of a schedule.
Values
ENABLED
: The schedule is enabled. Jobs will be started according to this jobs cron expression.DISABLED
: The schedule is disabled. No jobs will be started until the schedule is reenabled.
ScheduleStatus
Current status of a schedule.
Fields
config
(ScheduleConfig): Configuration of the schedule.id
(str): Unique ID of the schedule (generated when the schedule is first submitted).name
(str): Name of the schedule.state
(str | ScheduleState): Current state of the schedule.
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
- CLI
import anyscale
from anyscale.schedule.models import ScheduleStatus
status: ScheduleStatus = anyscale.schedule.status(name="my-schedule")
$ anyscale schedule status -n my-schedule
id: cronjob_dfhqufws6s3issltpjgrdzcgyc
name: my-schedule
state: ENABLED
Schedule CLI Legacy
anyscale schedule create
Legacy
This command is deprecated. Upgrade to anyscale schedule apply.
Usage
anyscale schedule create [OPTIONS] SCHEDULE_CONFIG_FILE
Create or Update a Schedule
This function accepts 1 argument, a path to a YAML config file that defines this schedule.
Note: if a schedule with the name exists in the specified project, it will be updated instead.
Options
--name/-n
: Name of the schedule.--description
: Description of schedule.
anyscale schedule update
Legacy
This command is deprecated. Upgrade to anyscale schedule apply.
Usage
anyscale schedule update [OPTIONS] SCHEDULE_CONFIG_FILE
Create or Update a Schedule
This function accepts 1 argument, a path to a YAML config file that defines this schedule.
Options
--name/-n
: Name of the schedule.--description
: Description of schedule.
Schedule SDK Legacy
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_or_update_schedule
Legacy
This command is deprecated. Upgrade to anyscale.schedule.apply.
Create or update a Schedule
Parameters
Name | Type | Description | Notes |
---|---|---|---|
create_schedule | CreateSchedule |
Returns ScheduleapimodelResponse
get_schedule
Legacy
This command is deprecated. Upgrade to anyscale.schedule.status.
Get Schedules
Parameters
Name | Type | Description | Notes |
---|---|---|---|
schedule_id | str | Defaults to null |
Returns ScheduleapimodelResponse
pause_schedule
Legacy
This command is deprecated. Upgrade to anyscale.schedule.set_state.
Pause a Schedule
Parameters
Name | Type | Description | Notes |
---|---|---|---|
schedule_id | str | Defaults to null | |
pause_schedule | PauseSchedule |
Returns ScheduleapimodelResponse
run_schedule
Legacy
This command is deprecated. Upgrade to anyscale.schedule.trigger.
Run a Schedule manually
Parameters
Name | Type | Description | Notes |
---|---|---|---|
schedule_id | str | Defaults to null |
Returns ProductionjobResponse
list_schedules
Legacy
This command is not actively maintained. Use with caution.
List Schedules
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 |
creator_id | optional str | filter by creator id | Defaults to null |
Returns ScheduleapimodelListResponse