Slackbot
03/10/2024, 2:01 PMScout
03/10/2024, 2:01 PMasset_a
to asset_b
using an asset_sensor
, you can follow these steps: 1. Define the Asset Sensor: When defining your asset_sensor
, you can access the latest materialization records, which include partition information. The sensor can then create a RunRequest
for asset_b
with the appropriate partition key. 2. Access Partition Information: Within the sensor, you can access the partition key from the latest materialization of asset_a
using the latest_materialization_records_by_partition
method or by accessing the event_log_entry
for the materialization event, which contains the partition key. 3. Create a RunRequest: Use the partition information to create a RunRequest
for asset_b
. You can set the partition key in the RunRequest
by including it in the tags
dictionary with the key dagster/partition
. Here's a conceptual example based on the documentation: python from dagster import asset_sensor, RunRequest, AssetKey @asset_sensor(asset_key=AssetKey("asset_a")) def asset_a_sensor(context): materialization_records = context.latest_materialization_records_by_partition(AssetKey("asset_a")) for partition, materialization in materialization_records.items(): # Access the partition key from the materialization record partition_key = materialization.partition # Create a RunRequest for asset_b with the partition key yield RunRequest( run_key=f"asset_b_{partition_key}", run_config={ # Your run config here }, tags={ "dagster/partition": partition_key } )
In this example, latest_materialization_records_by_partition
is used to get the latest materialization records for asset_a
, and for each partition, a RunRequest
is created for asset_b
with the corresponding partition key. Please note that the exact implementation details may vary based on your specific use case and the version of Dagster you are using. If you need to access additional metadata from the materialization event, you can do so by reading it off of the event_log_entry
as mentioned in the documentation. Remember to replace the placeholder comments and values with your actual run configuration and logic as needed. If you have further questions or need more detailed guidance, please refer to the [Dagster documentation](https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors) on sensors and asset materialization.