https://dagster.io/ logo
#ask-community
Title
# ask-community
m

Mark Raj

08/17/2023, 9:18 PM
Hi! I'm working on developing testing using
materialize
and was able to successfully pull data and metadata for an asset that I pass in. However, I'm having trouble getting both of the outputs from a multi-asset - any ideas how to include both and if using
asset_value
works in the same way? Multi-Asset Declaration
Copy code
@multi_asset(
    outs={'foo': AssetOut(is_required=True),          #foo asset is always generated and is correctly able to be pulled with asset_value
          'bar': AssetOut(is_required=False)},        #bar acts like a dead-letter queue, only sometimes generated, but is unable to be pulled with 'bar' asset key and asset_value()
    can_subset=True,
)
def foo:
Testing Call
Copy code
result = materialize(
            [foo],
            instance=instance
        )
        assert result.success
        data = result.asset_value('foo')     #this correctly pulls the main 'foo' output of the asset with it's asset key
        data = result.asset_value('bar')     #this is unable to pull the generated 'bar' asset with it's asset key
dagster bot responded by community 1
🤖 1
d

Daniel Kilcoyne

08/17/2023, 9:24 PM
Try using:
Copy code
result.output_for_node(
            node_str=NAME_OF_ASSET,
            output_name=SPECIFIC_OUTPUT_NAME,
        )
🌈 1
If you do:
Copy code
yield Output(df, output_name=SPECIFIC_OUTPUT_NAME)
from the asset body for 1 of your multi asset outputs
🌈 1
m

Mark Raj

08/17/2023, 10:10 PM
Ahhh that's perfect I just pulled both of them in the test since I did use the yield for each - thanks so much @Daniel Kilcoyne!!
🙌 1