Vinnie
08/10/2022, 10:08 AMmulti_assets
? Say I receive an email every so often and depending on the contents/attachments, it should rematerialize a subset of assets in a @multi_asset
. This would mean kicking off a dynamic amount of computations, one for each attachment, preferably in parallel. Thinking in jobs/graphs, the pattern would be fairly straightforward; yielding DynamicOutputs
from an op and calling .map()
. I would love to split the computations into different ops
connected through a graph
, but am struggling to map the outputs from a DynamicOut
to assets. Is it even possible to back multi_assets
with a graph when using `DynamicOut`s? The following code snippet is the interim solution I landed on.
@multi_asset(
required_resource_keys={"foo", "bar"},
outs={"baz": Out(is_required=False), "qux": Out(is_required=False)},
)
def my_cool_assets(context):
res = context.resources.foo.fetch()
for elem in res:
processed_elem = context.resources.bar.process(elem)
yield Output(value=processed_elem["data"], output_name=processed_elem["type"])
key_prefix
to @multi_asset
, doesn’t seem to be in the docs.Aaron
08/10/2022, 6:05 PMclaire
08/10/2022, 7:39 PMcan_subset=True
into the @multi_asset decorator, which will enable functionalities such as selecting just one asset to materialize in Dagit out of your multi asset.Vinnie
08/11/2022, 5:17 AMAverell
08/11/2022, 2:10 PM@multi_asset(
partitions_def=daily_partitions,
can_subset=True,
required_resource_keys={"my_client"},
outs={
"A": AssetOut(
key_prefix=["raw"],
),
"B": AssetOut(
key_prefix=["raw"],
),
}
)
DagsterStepOutputNotFoundError: Core compute for op "my_assets" did not return an output for non-optional output "B"
when I already set can_subset=True
. Could you help have a look? ThanksVinnie
08/11/2022, 2:13 PMAssetOut
in the docs.
The error seems to be from dagster thinking all assets are required. Should be able to fix it by adding is_required=False
. From what I can see, the parameter is allowed: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/_core/definitions/asset_out.py#L63Averell
08/11/2022, 2:23 PMVinnie
08/11/2022, 2:23 PMclaire
08/11/2022, 4:35 PMkey_prefix
is missing as a parameter on @multi_asset
. I can file an issue to add this, and file another issue to document AssetOut
Dagster Bot
08/11/2022, 4:35 PMclaire
08/11/2022, 4:36 PMDagster Bot
08/11/2022, 4:36 PM