-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On multi-asset concept page, use AssetSpec, not AssetOut
- Loading branch information
Showing
3 changed files
with
64 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
...es/docs_snippets/docs_snippets/concepts/assets/multi_asset_conditional_materialization.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
import random | ||
|
||
from dagster import AssetOut, Output, asset, multi_asset | ||
from dagster import AssetSpec, MaterializeResult, asset, multi_asset | ||
|
||
|
||
@multi_asset( | ||
outs={"asset1": AssetOut(is_required=False), "asset2": AssetOut(is_required=False)} | ||
specs=[AssetSpec("asset1", skippable=True), AssetSpec("asset2", skippable=True)] | ||
) | ||
def assets_1_and_2(): | ||
if random.randint(1, 10) < 5: | ||
yield Output([1, 2, 3, 4], output_name="asset1") | ||
yield MaterializeResult(asset_key="asset1") | ||
|
||
if random.randint(1, 10) < 5: | ||
yield Output([6, 7, 8, 9], output_name="asset2") | ||
yield MaterializeResult(asset_key="asset2") | ||
|
||
|
||
@asset | ||
def downstream1(asset1): | ||
# will not run when assets_1_and_2 doesn't materialize the asset1 | ||
return asset1 + [5] | ||
@asset(deps=["asset1"]) | ||
def downstream1(): | ||
"""Will not run when assets_1_and_2 doesn't materialize asset1.""" | ||
|
||
|
||
@asset | ||
def downstream2(asset2): | ||
# will not run when assets_1_and_2 doesn't materialize the asset2 | ||
return asset2 + [10] | ||
"""Will not run when assets_1_and_2 doesn't materialize asset2.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters