Clovis Warlop
04/11/2023, 3:47 AMclaire
04/11/2023, 6:03 PMevent_records = context.instance.get_event_records(
EventRecordsFilter(
DagsterEventType.ASSET_MATERIALIZATION, asset_key=AssetKey("some_asset")
),
limit=1,
)
if event_records:
step_stats = next(
iter(context.instance.get_run_step_stats(event_records[0].run_id, ["some_asset"]))
)
step_time = step_stats.end_time - step_stats.start_time
<http://context.log.info|context.log.info>(f"step_time: {step_time}")
which basically fetches the latest run id for a given asset, and fetches the step stats from the run to calculate how long the step took