Dominik Lotz
02/26/2024, 3:38 PMScout
02/26/2024, 3:38 PMtest
is materialized: python from dagster import AssetKey, RunRequest, asset_sensor, SensorEvaluationContext @asset_sensor(asset_key=AssetKey("test"), job=my_job) def my_asset_sensor(context: SensorEvaluationContext): yield RunRequest(run_key=None)
In this example, my_job
should be replaced with the actual job you want to trigger. The RunRequest
object is yielded without a run_key
or run_config
, which means it will trigger a new run with the default configuration each time the sensor detects a new materialization for the asset with the key test
. Please ensure that you have defined my_job
elsewhere in your code, and it is the job you intend to run when the asset is materialized.Dominik Lotz
02/27/2024, 6:25 AMScout
02/27/2024, 6:25 AMpython from dagster import AssetKey, RunRequest, asset_sensor, SensorEvaluationContext # Replace `my_graph` with the actual graph you want to orchestrate from my_project import my_graph @asset_sensor(asset_key=AssetKey("trottel"), job=my_graph.to_job()) def trottel_asset_sensor(context: SensorEvaluationContext): # You can access the materialization event and use it to customize the run request if needed materialization_event = context.latest_materialization_records[0] # Optionally, you can use the materialization event to pass specific configuration # to the job being triggered, for example: # run_config = {"solids": {"my_solid": {"config": {"param": materialization_event.dagster_event.event_specific_data}}}} # Trigger the job without any custom run configuration yield RunRequest(run_key=None)
In this example, my_graph
should be replaced with the actual graph you want to orchestrate when the asset "trottel" is materialized. The my_graph.to_job()
method converts the graph into a job, which is the executable unit in Dagster that can be triggered by the sensor. Please ensure that you have defined my_graph
elsewhere in your code, and it represents the graph you intend to run. If you need to pass specific configuration to the job based on the materialization event, you can construct a run_config
dictionary and pass it to the RunRequest
.