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

added retry policy param to dbt assets decorator #18990

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DagsterInvalidDefinitionError,
Nothing,
PartitionsDefinition,
RetryPolicy,
multi_asset,
)
from dagster._utils.warnings import (
Expand Down Expand Up @@ -55,6 +56,7 @@ def dbt_assets(
partitions_def: Optional[PartitionsDefinition] = None,
dagster_dbt_translator: DagsterDbtTranslator = DagsterDbtTranslator(),
backfill_policy: Optional[BackfillPolicy] = None,
retry_policy: Optional[RetryPolicy] = None,
op_tags: Optional[Mapping[str, Any]] = None,
) -> Callable[..., AssetsDefinition]:
"""Create a definition for how to compute a set of dbt resources, described by a manifest.json.
Expand All @@ -81,6 +83,7 @@ def dbt_assets(
dbt models, seeds, etc. to asset keys and asset metadata.
backfill_policy (Optional[BackfillPolicy]): If a partitions_def is defined, this determines
how to execute backfills that target multiple partitions.
retry_policy (Optional[RetryPolicy]): The retry policy for the underlying asset function.
op_tags (Optional[Dict[str, Any]]): A dictionary of tags for the op that computes the assets.
Frameworks may expect and require certain metadata to be attached to a op. Values that
are not strings will be json encoded and must meet the criteria that
Expand Down Expand Up @@ -311,6 +314,7 @@ def inner(fn) -> AssetsDefinition:
op_tags=resolved_op_tags,
check_specs=check_specs,
backfill_policy=backfill_policy,
retry_policy=retry_policy,
)(fn)

return asset_definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NodeInvocation,
PartitionMapping,
PartitionsDefinition,
RetryPolicy,
TimeWindowPartitionMapping,
asset,
)
Expand Down Expand Up @@ -231,6 +232,19 @@ def my_dbt_assets():
assert my_dbt_assets.backfill_policy == backfill_policy


def test_retry_policy():
retry_policy = RetryPolicy(max_retries=2)

@dbt_assets(
manifest=manifest,
retry_policy=retry_policy,
)
def my_dbt_assets():
...

assert my_dbt_assets.op.retry_policy == retry_policy


def test_op_tags():
@dbt_assets(manifest=manifest, op_tags={"a": "b", "c": "d"})
def my_dbt_assets():
Expand Down