@schedule decorator creates a schedule that triggers runs of a job or asset materialization on a regular time-based cadence defined by a cron expression.
Signature
Parameters
A valid cron string or sequence of cron strings specifying when the schedule will run.
- Single cron string:
"45 23 * * 6"(11:45 PM every Saturday) - Multiple cron strings:
["45 23 * * 6", "30 9 * * 0"](11:45 PM Saturday and 9:30 AM Sunday)
The name of the schedule. Defaults to the name of the decorated function.
A set of key-value tags that annotate the schedule and can be used for searching and filtering in the UI.Note: Either
tags or tags_fn may be set, but not both.A function that generates tags to attach to the schedule’s runs. Takes a
ScheduleEvaluationContext and returns a dictionary of tags (string key-value pairs).Note: Either tags or tags_fn may be set, but not both.A set of metadata entries that annotate the schedule. Values will be normalized to typed
MetadataValue objects.A function that runs at schedule execution time to determine whether a schedule should execute or skip. Takes a
ScheduleEvaluationContext and returns a boolean (True if the schedule should execute). Defaults to a function that always returns True.Timezone in which the schedule should run. Supported strings are from the IANA time zone database (e.g.
"America/Los_Angeles").A human-readable description of the schedule.
The job that should execute when the schedule runs.
If set to
RUNNING, the schedule will immediately be active when starting Dagster. The default status can be overridden from the Dagster UI or via the GraphQL API.The set of resource keys required by the schedule.
target
Optional[Union[CoercibleToAssetSelection, AssetsDefinition, JobDefinition, UnresolvedAssetJobDefinition]]
The target that the schedule will execute. It can take
AssetSelection objects and anything coercible to it (e.g. str, Sequence[str], AssetKey, AssetsDefinition). It can also accept JobDefinition and UnresolvedAssetJobDefinition objects. This parameter will replace job and job_name.A sequence of strings identifying the owners of the schedule.
Returns
Type:ScheduleDefinition
A schedule definition object.
Evaluation Function Return Values
The decorated function takes aScheduleEvaluationContext and may return:
- A
RunRequestobject - A list of
RunRequestobjects - A
SkipReasonobject, providing a descriptive message of why no runs were requested - Nothing (skipping without providing a reason)
- A run config dictionary
- Yield a
SkipReasonor yield one or moreRunRequestobjects
Examples
Basic Schedule
Schedule with Run Config
Schedule with Dynamic Tags
Conditional Schedule
Schedule for Asset Materialization
Multiple Run Requests
Schedule with Multiple Cron Expressions
Schedule with Resources
Always-On Schedule
Schedule with Metadata
Cron Expression Format
Cron expressions follow the standard format:Common Cron Patterns
"0 0 * * *"- Daily at midnight"0 9 * * 1-5"- Weekdays at 9 AM"*/15 * * * *"- Every 15 minutes"0 0 1 * *"- First day of every month"0 0 * * 0"- Every Sunday at midnight
Related
- @sensor - Event-driven alternative to schedules
- RunRequest - Request to launch a run
- SkipReason - Skip schedule evaluation with a reason
- ScheduleEvaluationContext - Context for schedule evaluation
- PartitionedConfig - Partition-based scheduling
