If my multi-asset-sensor detects materializations ...
# ask-community
r
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
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
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
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
if A is materialized, but not B, then C, as you have written, will wait for B to materialize before it executes, correct?
s
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
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
is it possible to materialize C even if B has never been materialized before?
r
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
ahh I see
r
so I figured a m-a-s using the "any" strategy works great
s
are you using IO managers?
r
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
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
where would our own IO code inside of C get the paths to the materialized data?
s
the IO manager decides based on the asset key, so your code could basically do the same