# ask-ai

Jerry Bao

02/27/2024, 5:10 AM
is it possible to get the asset selection of a sensor when the sensor is evaluated? not the assets being monitored, but the asset that will be materialized on a run request


02/27/2024, 5:10 AM
The documentation does not explicitly state whether you can get the asset selection of a sensor when the sensor is evaluated. However, it does provide information on how to define an asset sensor and how to test it, including how to build a sensor context for testing purposes. An asset sensor in Dagster is designed to monitor for new
events for a particular asset key. When defining an asset sensor, you specify the asset key that the sensor will monitor and the job that should be triggered when the sensor fires. The sensor's evaluation function can yield a
based on a single asset materialization, and this
can include a run configuration that specifies the operations to be performed. The documentation also mentions the use of
for scenarios where you want to monitor multiple assets and potentially trigger runs based on the materialization of those assets. In the context of a
, you can access the latest materialization records for the monitored assets and make decisions based on that information. However, regarding the specific asset selection that will be materialized on a run request, the documentation does not provide a direct method to retrieve this information during sensor evaluation. The asset selection is typically defined when setting up the sensor and is used to determine which assets' materializations should trigger the sensor. If you need to access specific details about the asset selection during sensor evaluation, you might need to infer this information from the context provided to the sensor's evaluation function or from the configuration of the job that the sensor is set to trigger. If this is a requirement for your use case and is not covered by the current capabilities of Dagster, it might be worth exploring the possibility of a feature request or discussing it further with the Dagster community for potential workarounds.