Drew Broadley
03/13/2024, 2:06 AMScout
03/13/2024, 2:06 AMOpExecutionContext
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: 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.Drew Broadley
03/13/2024, 2:07 AM