Dagster can automatically materialize assets when criteria are met, enabling a declarative approach to asset materialization. Instead of defining explicit workflows to materialize assets, you describe the conditions under which they should be materialized and let the system kick off runs in response.
For example, you have an asset that's scheduled to execute every day at midnight. Instead of executing whether there's new data or not, you can use Declarative Automation to materialize the asset only after its parent has been updated.
Declarative Automation includes pre-built conditions to handle common use cases, such as executing on a periodic schedule or whenever an upstream dependency updates, but conditions can also be customized.
Automation conditions describe the conditions under which an asset should be executed. Dagster provides two pre-built conditions:
Name
Description
Useful for
AutomationCondition.eager()
This condition will materialize an asset:
If the asset has never been materialized before, or
When the asset's parents update, as long as none of the parents are currently missing or have an update in progress
Automatically propagating changes through the asset graph
Ensuring assets remain up-to-date
AutomationCondition.cron(cron_schedule)
This condition will materialize an asset once per cron schedule tick, after all of its parents have been updated since the tick
Regularly updating an asset without worrying about the specifics of how its parents update
Automation conditions can be set on the @asset decorator or on an AssetSpec:
from dagster import AssetSpec, AutomationCondition, asset
@asset(automation_condition=AutomationCondition.eager())defmy_eager_asset():...
AssetSpec("my_cron_asset", automation_condition=AutomationCondition.cron("@daily"))
The core AutomationCondition framework is extremely flexible, allowing you to build custom conditions from the ground up. Refer to the Customizing automation conditions guide for more information.
When automation conditions for an asset are met, a sensor will kick off a run to materialize the asset. This sensor, named default_automation_condition_sensor, will be available for each code location and monitor all assets within that location. To use multiple sensors or change the properties of the default sensor, refer to the AutomationConditionSensorDefinition documentation.
After these criteria are met, the sensor's evaluation history will be visible in the UI:
You'll also be able to view a detailed history of each asset's evaluations on the asset's Asset Details page. This allows you to see why an asset was or wasn't materialized at different points in time: