how is the cursor of an `@asset_sensor` updated?
# ask-community
b
how is the cursor of an
@asset_sensor
updated?
p
Hi Bernardo. Our
asset_sensor
implementation is a wrapper around this event query:
Copy code
event_records = context.instance.get_event_records(
    EventRecordsFilter(
        event_type=DagsterEventType.ASSET_MATERIALIZATION,
        asset_key=self._asset_key,
        after_cursor=after_cursor,
    ),
    ascending=False,
    limit=1,
)
event_record = event_records[0]
... # body of asset sensor is evaluated here
context.update_cursor(str(event_record.storage_id))
The cursor is updated with the record id of the most recent asset materialization event. Reference: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/core/definitions/sensor_definition.py#L570
🙏 1