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

Lilian GARCIA PAILLE

06/21/2023, 1:57 PM
Hello, I have a job that contains several assets. Each asset extract data with an API call. I would like to know if Dagster can launch a dbt task when it detects that every assets have finished their task. I have a constraint : If an asset fails I want to launch my dbt task anyway. Thank you for your help ! 🙂
t

Tim Castillo

06/21/2023, 4:29 PM
Hi! Have you had an opportunity to look Run status sensors? If you make a job of your dbt models, then you can use a run status sensor for each of the different states (success or failure) to run your dbt job afterward. You can use a factory pattern to make your code more DRY and pass the states you want to listen to into it and generate a sensor per state.
l

Lilian GARCIA PAILLE

06/22/2023, 9:09 AM
Thanks. I didn't like sensors because I thought that I had to create two sensors. One if my job has failed and one if it has succeed. However, RunsFilter allowed me to get records in both cases.
Copy code
run_records = context.instance.get_run_records(
      filters=RunsFilter(
job_name="%%%",
statuses=[DagsterRunStatus.SUCCESS, DagsterRunStatus.FAILURE],
))