Migrating from AutoMaterializePolicy
to AutomationCondition
#23495
Replies: 2 comments 8 replies
-
Hi, nice revamp :) I have some question :
Also, assets with |
Beta Was this translation helpful? Give feedback.
-
I can't get this example to work: from dagster import asset, AutomationCondition
@asset(automation_condition=AutomationCondition.any_downstream_conditions())
def upstream(): ...
@asset(
automation_condition=AutomationCondition.on_cron("30 8 * * *"),
)
def downstream(): ... What I see happening instead, is that neither the downstream nor the upstream asset ever get materialized. The downstream asset waits eternally for the upstream assets to get materialized, as the See this example evaluation: Is this as expected, or has something changed since this migration guide was made? |
Beta Was this translation helpful? Give feedback.
-
Background
In Dagster version 1.8.0,
AutoMaterializePolicy
is marked as deprecated. You can learn more about the reasoning behind this change here.The functionality provided by this API will be replaced with the
AutomationCondition
abstraction. This guide covers how to migrate fromAutoMaterializePolicy
toAutomationCondition
.These APIs are 100% compatible with each other. In fact, all
AutoMaterializePolicy
objects are automatically converted intoAutomationConditions
before evaluation. This means that you can migrate assets one by one with no global impact. This guide covers how to migrate individual assets.Migrating from AutoMaterializePolicy.eager()
If you have an asset defined as:
, then this can be migrated to:
AutomationCondition.eager()
is composed of a set of simpler conditions, and has the same purpose as the originalAutoMaterializePolicy.eager()
. However, it has a few key differences to note:max_materializations_per_minute
rate limit would cause only one of those partitions to be requested (by default). If you are applying this condition to an asset with one of those partition types, and you do not want those missing partitions to be requested, you can useAutomationCondition.eager() & ~AutomationCondition.missing()
, which will ensure that missing partitions are not materialized for that asset.Migrating from AutoMaterializePolicy.lazy()
If you have assets which look like:
, then this can be migrated to:
Note that the upstream asset now has a condition which will be a copy of any downstream condition(s). In this case, it “inherits” the condition of the downstream, meaning it will materialize at 8:30AM every day.
This setup will have nearly identical behavior to the previous version, with a run being kicked off at exactly 8:30AM to refresh both assets. Differences in behavior may occur in cases where there are multiple downstream assets with different cron schedules which do not divide evenly into each other. Previously, the system would attempt to choose a time to execute that landed within the time windows of each independent cron schedule. However, this process was imprecise and frequently led to confusing and unintuitive behavior, and rarely resulted in an optimization that was operationally useful.
We are considering adding utilities to help handle the edge cases of uneven scheduling constraints better, so if you experience undesirable behavior changes after making these updates, let us know and we can work with you to understand your use case.
Migrating from other policies
If you have policies set up with custom rules which cannot be handled by
AutomationCondition.on_cron()
, then check out the Customizing automation conditions guide, or leave a comment below.Beta Was this translation helpful? Give feedback.
All reactions