Is there a quick way to determine via context if a...
# ask-community
c
Is there a quick way to determine via context if an asset has ever been materialized?
s
Hey @Charlie Bini - I created a discussion to answer this, because I suspect others might be curious too: https://github.com/dagster-io/dagster/discussions/12666
c
very nice!
@sandy uncovered a potential bug related to this. I have an asset using
context.instance.get_latest_materialization_event
to change some parameters if this is the first time the asset has been materialized. The function works as expected, but the initial run failed, and then upon retry, it actually returned a materialization record, even though the asset had not been successfully materialized.
I can send you the debug logs for the run in DMs if you want
e
Charlie isn't an asset that had a run failure a different state than one that has never materialized? The behavior you describe is what I would expect. It did materialize, just not successfully. There could be many reasons for this, but I would expect to look at the status of the materialization for more info, not to have it show up as never materialized.
p
Hi all, I am wondering if there has been any success using the provided GitHub code? I have asset A being updated daily. Then, end of week I want to save a snapshot of asset A as asset B for use with an op that compares the changes of asset B weekly. It looks like my issue is only on the instantiation of the pipeline similar to the above: the provided code fails, then returns a materialization record upon retry but fails because asset B does not yet exist. So my full question is, is it possible to do something along the lines of the below?
Copy code
if context.instance.get_latest_materialization_event(asset_A_key) is None:
           return empty_dataframe
else:
           return asset_b_dataframe