Skip to main content

Configuring job behavior based on scheduled run time

This example demonstrates how to use run config to vary the behavior of a job based on its scheduled run time.

@op(config_schema={"scheduled_date": str})
def configurable_op(context: OpExecutionContext):
context.log.info(context.op_config["scheduled_date"])


@job
def configurable_job():
configurable_op()


@schedule(job=configurable_job, cron_schedule="0 0 * * *")
def configurable_job_schedule(context: ScheduleEvaluationContext):
scheduled_date = context.scheduled_execution_time.strftime("%Y-%m-%d")
return RunRequest(
run_key=None,
run_config={
"ops": {"configurable_op": {"config": {"scheduled_date": scheduled_date}}}
},
tags={"date": scheduled_date},
)

APIs in this example