In an op, what variable under context holds the ex...
# ask-ai
d
In an op, what variable under context holds the execution datetime object?
s
In an op, the
OpExecutionContext
does not directly hold an execution datetime object as a dedicated variable. However, you can access the current time within the op by using Python's standard library, specifically the
datetime
module. Here's an example of how you might do this within an op:
Copy code
python from datetime import datetime from dagster import op  @op def my_op(context):     execution_time = datetime.now()     <http://context.log.info|context.log.info>(f"The current execution time is: {execution_time}")
In this example,
execution_time
is a variable that holds the current datetime when the op is executed. If you are looking for the scheduled execution time in the context of a scheduled job, you would typically pass this information into the op via config or resources, as the
OpExecutionContext
itself does not provide this information directly.
d
How do I get the datetime of when the job was run?