Tate Wilks
05/29/2024, 5:50 PMresult = run_deployment(
timeout=0,
name="submit-tasks/local-deploy",
scheduled_time=(datetime.now() + timedelta(minutes=2)),
parameters={
"a": randint(1, 5),
"b": randint(1, 5),
"c": randint(1, 5),
},
as_subflow=False,
)
It should reschedule the flow to run 2 minutes later, but the newly created flow executes immediately. Why is that?Marvin
05/29/2024, 5:50 PMscheduled_time
directly in run_deployment
may not work the way you expect due to the intricacies of the Prefect Scheduler and its scheduling mechanisms.
Here are some critical points from the documentation:
1. Scheduler Service:
- The Scheduler service in Prefect works on a loop, revisiting deployments per its schedule. It evaluates each deployment's schedules and creates new runs appropriately, usually up to three runs in advance.
- Recently modified deployments are checked more frequently, but there is still a delay.
2. Running Deployments:
- Immediate execution might be the default behavior if the schedule isn't properly accounted for or if there is a timing mismatch with the Scheduler service loop.
To ensure the flow runs at the desired time, consider using a dedicated scheduling mechanism within the deployment configuration or adjust the deployment's schedule more explicitly.
Here's a documentation link that might provide more insight:
Prefect Schedules
Is that suitably depressing?Chris White
import pendulum
...
scheduled_time=pendulum.now("utc").add(minutes=2)
Tate Wilks
05/29/2024, 5:55 PMChris White