Hello everyone! Is there a way to attach a hook to...
# ask-community
r
Hello everyone! Is there a way to attach a hook to a job built from a software-defined asset?
dagster bot resolve to issue 1
p
Hi Romain. If you are looking for a way to fire an alert or perform some action based on a run failure of an asset job, you can set up a run status sensor. You can point it at a specific job, including an asset job. For example,
Copy code
from dagster import asset, build_assets_job, run_failure_sensor

@asset
def asset1():
    return 1

@asset
def asset2():
    return 2

my_asset_job = build_assets_job("my_assets_job", assets=[asset1, asset2])

@run_failure_sensor(job_selection=[my_asset_job])
def perform_on_asset_job_failure(context):
    ...
r
Yep that's the one, thanks a lot!
p
@Dagster Bot discussion Adding run failure sensors to software-defined asset jobs
d
Question in the thread has been surfaced to GitHub Discussions for future discoverability: https://github.com/dagster-io/dagster/discussions/7774