Skip to main content

Declarative Automation

Declarative Automation is a framework that uses information about the status of your assets and their dependencies to launch executions of your assets.

Not sure what automation method to use? Check out the automation overview for a comparison of the different automation methods available in Dagster.

note

To use Declarative Automation, you will need to enable the default automation condition sensor in the UI, which evaluates automation conditions and launches runs in response to their statuses. To do so, navigate to Automation, find the desired code location, and toggle on the default_automation_condition_sensor sensor.

An AutomationCondition on an asset or asset check describe the conditions under which work should be executed.

While the system can be customized to fit your specific needs, we recommend starting with one of the built-in conditions below, rather than building up your own condition from scratch.

The AutomationCondition.on_cron will execute an asset once per cron schedule tick, after all upstream dependencies have updated. This allows you to schedule assets to execute on a regular cadence regardless of the exact time that upstream data arrives.

In the example below, the asset will start waiting for each of its dependencies to be updated at the start of each hour. Once all dependencies have updated since the start of the hour, this asset will be immediately requested.

import dagster as dg


@dg.asset(
deps=["upstream"],
automation_condition=dg.AutomationCondition.on_cron("@hourly"),
)
def hourly_asset() -> None: ...

Behavior

If you would like to customize aspects of this behavior, refer to the customizing on_cron guide.

  • If at least one upstream partition of all upstream assets has been updated since the previous cron schedule tick, and the downstream asset has not yet been requested or updated, the downstream asset will be requested.
  • If all upstream assets do not update within the given cron tick, the downstream asset will not be requested.
  • For time-partitioned assets, this condition will only request the latest time partition of the asset.
  • For static and dynamic-partitioned assets, this condition will request all partitions of the asset.