Skip to main content

Automating asset checks

While it is most common to use automation conditions to automate the execution of assets, you can also use and customize them in the same ways to automate the execution of asset checks. This is particularly helpful in cases where you want to automate your data quality checks independently of the assets they are associated with.

The AutomationCondition.on_cron will execute an asset check once per cron schedule tick, after all upstream dependencies have updated. This allows you to check the quality of your data on a lower frequency than the asset itself updates, which can be helpful in cases where the data quality check is slow or expensive to execute.

In the following example, at the start of each hour, the above check will start waiting for its associated asset to be updated. Once this happens, the check will immediately be requested. The check will not be requested again until the next hour.

import dagster as dg


@dg.asset_check(
asset="upstream",
automation_condition=dg.AutomationCondition.on_cron("@hourly"),
)
def on_cron_asset_check() -> dg.AssetCheckResult: ...

Behavior

  • If at least one upstream partition of all upstream assets has been updated since the previous cron schedule tick, and the downstream check has not yet been requested or executed, it will be requested.
  • If all upstream assets do not update within the given cron tick, the check will not be requested.

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