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

Robert Wade

06/22/2023, 7:13 PM
If my multi-asset-sensor detects materializations of assets A and B and then issues a RunRequest that kicks off a job, which itself materializes asset C, can asset C have access to the materialization results of A and B?
s

sandy

06/23/2023, 8:12 PM
when you say "access to materialization results" do you mean load the values using an IO manager? if so, the following should work for accessing the materialization results, independent of how C is triggered
Copy code
@asset
def asset_c(asset_a, asset_b):
    ...
r

Robert Wade

06/23/2023, 8:14 PM
In my case I want asset C to execute when A or B materializes. So I can't define it as you have written. So I figured the best approach would be a m-a-s then triggers on either A or B and then provides the materialized data to C
s

sandy

06/23/2023, 8:15 PM
I wouldn't expect those to be mutually exclusive. i.e. you should be able to do what I wrote and also use a multi-asset-sensor to trigger C
r

Robert Wade

06/23/2023, 8:16 PM
if A is materialized, but not B, then C, as you have written, will wait for B to materialize before it executes, correct?
s

sandy

06/23/2023, 8:17 PM
it won't - it just means that, when C is materialized (by the sensor), it will load the contents of both A and B
r

Robert Wade

06/23/2023, 8:18 PM
but B isn't materialized, and we can't force it to be. It has it's own schedule. C needs to be de-coupled in that way.
sorry... B
s

sandy

06/23/2023, 8:18 PM
is it possible to materialize C even if B has never been materialized before?
r

Robert Wade

06/23/2023, 8:19 PM
yes. The idea is that C will materialize when 1 or more of it's "dependencies" are materialized. They aren't true dependencies in that they all aren't required. Just 1.
s

sandy

06/23/2023, 8:19 PM
ahh I see
r

Robert Wade

06/23/2023, 8:19 PM
so I figured a m-a-s using the "any" strategy works great
s

sandy

06/23/2023, 8:19 PM
are you using IO managers?
r

Robert Wade

06/23/2023, 8:20 PM
but the trick is to pass the actual materialized data from A or B or any of the other ones (that I haven't included in this example) into C
right now we are just using the default I/O
s

sandy

06/23/2023, 8:20 PM
one option would be something like this (but loading a different asset): https://github.com/dagster-io/dagster/discussions/14805
another option would be writing your own IO manager that doesn't error if the upstream data is missing
or just not using IO managers at all and handling IO inside your code
r

Robert Wade

06/23/2023, 8:21 PM
where would our own IO code inside of C get the paths to the materialized data?
s

sandy

06/26/2023, 5:00 AM
the IO manager decides based on the asset key, so your code could basically do the same
21 Views