Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default backfill policy to BackfillPolicy.multi_run(1) for executable assets #22282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smackesey
Copy link
Collaborator

@smackesey smackesey commented Jun 4, 2024

Summary & Motivation

Currently backfill policy defaults to None for assets. This null value flows all the way through our backfill machinery, and is interpreted the same way as BackfillPolicy.multi_run(1). This is weird because the backfill machinery doesn't recognize the equivalence of these two values.

This PR makes it so that the backfill system never deals with null values. We do this by having AssetsDefinition default to BackfillPolicy.multi_run(1) (via a new DEFAULT_BACKFILL_POLICY constant) for materializable assets. It didn't make sense to default to a non-null value for all assets because the backfill policy really is undefined for unexecutable assets.

This is mostly a refactor-- the only intended behavior change from this PR is that if users specify a mix of None and BackfillPolicy.multi_run(1) for backfill policies for their assets, we will no longer error (because None is now being converted for them).

How I Tested These Changes

Existing test suite.

Copy link
Collaborator Author

smackesey commented Jun 4, 2024

@smackesey smackesey marked this pull request as ready for review June 4, 2024 14:39
@smackesey smackesey force-pushed the sean/standardize-dagster-dbt-default-backfill-policy branch from 2a1e03c to 73a7421 Compare June 4, 2024 14:42
@smackesey smackesey force-pushed the sean/default-backfill-policy branch from a79895e to 73135c8 Compare June 4, 2024 14:43
Copy link
Contributor

@sryza sryza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely a premature optimization, but I would probably add cached_method to default, or use a constant, so that we don't make a new object per AssetsDefinition.

@smackesey smackesey force-pushed the sean/default-backfill-policy branch from 73135c8 to 0c0504d Compare June 12, 2024 11:31
@smackesey smackesey changed the base branch from sean/standardize-dagster-dbt-default-backfill-policy to master June 12, 2024 11:31
Copy link

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-f8ohxbvoo-elementl.vercel.app
https://sean-default-backfill-policy.components-storybook.dagster-docs.io

Built with commit 0c0504d.
This pull request is being automatically deployed with vercel-action

Copy link

Deploy preview for dagster-docs ready!

Preview available at https://dagster-docs-pjs2izn8r-elementl.vercel.app
https://sean-default-backfill-policy.dagster.dagster-docs.io

Direct link to changed pages:

Copy link

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-240ftkpok-elementl.vercel.app
https://sean-default-backfill-policy.core-storybook.dagster-docs.io

Built with commit 0c0504d.
This pull request is being automatically deployed with vercel-action

@smackesey smackesey changed the title Change default backfill policy to BackfillPolicy.multi_run(1) for materializable assets Change default backfill policy to BackfillPolicy.multi_run(1) for executable assets Jun 12, 2024
@smackesey smackesey force-pushed the sean/default-backfill-policy branch 2 times, most recently from d377d14 to 3285b44 Compare June 12, 2024 15:18
@smackesey smackesey changed the base branch from master to sean/set-partition-key-for-range-l1 June 12, 2024 15:18
@smackesey smackesey force-pushed the sean/set-partition-key-for-range-l1 branch from c4ca5e6 to 695dac3 Compare June 12, 2024 15:23
@smackesey smackesey force-pushed the sean/default-backfill-policy branch from 3285b44 to ff91890 Compare June 12, 2024 15:23
Base automatically changed from sean/set-partition-key-for-range-l1 to master June 12, 2024 15:47
@smackesey smackesey force-pushed the sean/default-backfill-policy branch from ff91890 to caf4b19 Compare June 12, 2024 19:39
f"Cannot have {ASSET_PARTITION_RANGE_START_TAG} or"
f" {ASSET_PARTITION_RANGE_END_TAG} set along with"
f" {PARTITION_NAME_TAG}"
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this restriction no longer makes sense since runs targeting a single partition but launched as part of a backfill will have both of these set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be difficult to avoid setting the range tags in the case that there's a single partition targeted? Not necessarily a blocker if it's complicated, but seems like a safer and less invasive change than adding the range tags to every run from an asset backfill.

if partition_range_start or partition_range_end:
if is_partitioned and partition_tag:
partition = partition_tag
partitions_subset = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssetMaterializationPlannedData accepts one non-null value for partition and partitions_subset. Prefer partition if we are targeting a single partition.

@@ -37,53 +36,6 @@
)


def test_asset_backfill_not_all_asset_have_backfill_policy():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete this test because all assets now have a defined policy.

@smackesey smackesey force-pushed the sean/default-backfill-policy branch from caf4b19 to d9d92e1 Compare June 12, 2024 21:22
@smackesey
Copy link
Collaborator Author

@sryza I made significant updates to this since you reviewed it so you'll want to take another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants