https://dagster.io/ logo
#ask-ai
Title
# ask-ai
j

Jerry Bao

02/29/2024, 9:58 AM
is it possible to check if an asset materialization was successful or failed in an asset sensor?
s

Scout

02/29/2024, 9:58 AM
Based on the documentation, an asset sensor is designed to check for new
AssetMaterialization
events for a particular asset key. This can be used to trigger downstream computations or notify stakeholders when an asset has been materialized. However, the documentation does not explicitly state that an asset sensor can check for the success or failure of an asset materialization. In the context of asset sensors, the documentation provides an example of how to create a sensor that generates a
RunRequest
for every materialization of a specified asset key. The example does not include logic for determining the success or failure of the materialization. Additionally, there are discussions and issues raised in the Dagster community that suggest the need for a feature to detect asset materialization failures, similar to a
run_failure_sensor
for jobs. These discussions indicate that, as of the last update, there is no built-in sensor specifically for detecting asset materialization failures. For more detailed and specific use cases, it would be advisable to refer to the latest Dagster documentation or community discussions, as the platform is actively developed and new features or patterns may have been introduced after my knowledge cutoff date.
j

Jerry Bao

02/29/2024, 10:04 AM
@Scout can a run_status_sensor have resources?
s

Scout

02/29/2024, 10:04 AM
Yes, a
run_status_sensor
can have resources. In the documentation, it is mentioned that you can provide resource definitions to a sensor, including a
run_status_sensor
, using the
resources
parameter. This allows you to pass in resources that the sensor might need during its execution, such as database connections, logging configurations, or any other external services or configurations that are required. Here's an example of how you might define a
run_status_sensor
with resources, based on the documentation's structure for sensors:
Copy code
python from dagster import run_status_sensor, DagsterRunStatus, RunRequest, sensor  @run_status_sensor(     run_status=DagsterRunStatus.SUCCESS,     request_job=my_job,     resources={'my_resource': my_resource_config}, ) def my_run_status_sensor(context):     # Access the resource within the sensor function     my_resource_instance = context.resources.my_resource     # ... additional logic using the resource ...     return RunRequest(run_key=None, run_config={})
In this example,
my_resource
is a resource that you have defined elsewhere in your codebase, and
my_resource_config
is the configuration for that resource. The
context.resources.my_resource
expression is used to access the resource within the sensor function. Please note that the actual implementation and usage of resources may vary depending on the specific version of Dagster you are using and the resources you need. Always refer to the latest documentation for the most accurate and up-to-date information.
j

Jerry Bao

02/29/2024, 10:05 AM
@Scout can a
run_failure_sensor
have resources
s

Scout

02/29/2024, 10:05 AM
As of the last update in the documentation,
run_failure_sensor
does not support resources in the same way that other sensors do. There was an issue reported where a user encountered an error when trying to use resources with a
run_failure_sensor
. The error indicated that the sensor was missing a required positional argument for the resource, suggesting that resources were not being injected as expected. The issue was acknowledged, and a maintainer mentioned that run failure sensors weren't fully integrated with all sensor functionalities, such as yielding run requests or supporting resources in the constructor. This implies that, at least up to the point of the last update, you could not directly use resources with
run_failure_sensor
in the same way you could with other sensors. For the most current capabilities and any potential workarounds, please refer to the latest Dagster documentation or check for any updates on the relevant GitHub issues or discussions.
2 Views