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

Walid El Bouchikhi

02/02/2023, 11:09 PM
Hello! Is there a way to trigger a slack message on a failed software-defined asset materialization?
Thanks but unfortunately I couldn't get it to work with an @asset Can you give me an example ?
I have dbt assets loaded thanks to dagster-dbt and I want to post slack message on dbt job failure
f

Fraser Marlow

02/02/2023, 11:22 PM
Could you assign a sensor to that asset’s job? dagster_slack.make_slack_on_run_failure_sensor
Sorry, I am not sure - I would assume the sensor would work on both
Op
and
asset
? https://docs.dagster.io/concepts/partitions-schedules-sensors/asset-sensors
w

Walid El Bouchikhi

02/02/2023, 11:26 PM
This doesn't seem to work on asset. Here is my Definition
Copy code
def message_fn(context: RunFailureSensorContext) -> str:
    return f"Error: {context.failure_event.message}"


defs = Definitions(
    assets=load_assets_from_package_module(assets),
    resources={
        "dbt": dbt_cli_resource.configured(
            {
                "project_dir": DBT_PROJECT_PATH,
                "profiles_dir": DBT_PROFILES,
            },
        ),
    },
    sensors=[
        make_slack_on_run_failure_sensor(
            channel="#dagster-dev",
            slack_token="token",
            text_fn=message_fn,
            dagit_base_url="<http://localhost:3000>",
        )
    ],
)
j

jamie

02/03/2023, 3:27 PM
Hey @Walid El Bouchikhi the slack message run failure sensor should still work with sdas. When you run the sensor are you seeing that it gets skipped? some other failure?
w

Walid El Bouchikhi

02/03/2023, 3:49 PM
Hello @jamie I'm new to dagster, do I need to run the sensor? And if so, how? Because I just registered it in
Definitions
object as you can see in the code I don't know where to check for registered sensors on dagit interface, also dagster outputs this (even after job fails)
dagster.daemon.SensorDaemon - INFO - Not checking for any runs since no sensors have been started.
I was able to make it work. I had to manually activate the sensor on the dagit interface
🙌 1
Do you know if there is a way to enable sensors by default? Is it related to a local deployment?
j

jamie

02/03/2023, 4:08 PM
you can set the
default_status
parameter of
make_slack_on_failure_sensor_
to `DefaultSensorStatus.RUNNING`s
🙏 1
7 Views