Hi - I have a job which runs every hour to collect...
# ask-community
a
Hi - I have a job which runs every hour to collect and report on any/all runs which have failed in the last hour. I am attempting to gather the assets from any job which materializes assets that were affected by the failure and did not successfully materialize. (Yes, I know there's a run failure sensor but it would send an email for each failure during that period while I need a single email containing all failures during that period) To that end, I need to write a unit test which can test fetching context and failure event data from (hopefully mocked) failed assets. Anyone have any suggestions on how I could accomplish this?
🤖 1
s
Hi Adam, There’s a function called
instance_for_test
that’s part of our public API. We use this extensively internally as well. You use it like this:
Copy code
from dagster import instance_for_test

with instance_for_test() as instance:
    some_job.execute_in_process(instance=instance)
    ...
You can use this approach to populate the test instance with various failed runs. This should allow you to set it up appropriately to test your job.
a
That is fantastic! Thank you!
Are the event logs all in memory or are they stored in the same default Sqlite DB?