https://dagster.io/ logo
#ask-ai
Title
# ask-ai
t

Tara Larrue

02/12/2024, 2:33 PM
How do I get the last sensor run time of a sensor instance?
s

Scout

02/12/2024, 2:33 PM
To get the last sensor run time of a sensor instance, you can refer to the
last_tick_completion_time
attribute available in the
SensorEvaluationContext
. This attribute represents the last time that the sensor completed an evaluation, and it is provided as a float representing a UTC timestamp. Here is an example of how you might access this attribute within a sensor definition:
Copy code
python from dagster import sensor, SensorEvaluationContext  @sensor def the_sensor(context: SensorEvaluationContext):     last_run_time = context.last_tick_completion_time     # You can use last_run_time here to inform your sensor's logic     ...
The
last_tick_completion_time
is one of the properties you can use to understand when the sensor was last evaluated. Keep in mind that this timestamp is in UTC, so you may need to convert it to your local timezone if necessary.
4 Views