Josh Greenhalgh
01/28/2021, 7:09 PMJeremiah
execution_date
, so there’s a need for “backfills” that effectively hack around that to simulate runs that took place in the past.
In Prefect, we make no assumptions about the relationship between your workflow and time. Instead, if your workflow does depend on a specific time, best practice is to introduce that dependency as a parameter or via context. We think of workflows as functions, so in this case your execution_date
is simply an argument to that function. For most runs you might use a default value like the current date or the run’s scheduled_start_time
, but you could always pass a historical date for backfill semantics.
Here’s a more complete explanation from stack overflow with some sample code: https://stackoverflow.com/questions/64029629/is-there-a-way-to-backfill-historical-data-once-for-a-new-flow-in-prefectflow.schedule.next(n=50, after=pendulum.datetime(2021, 1, 1))
This will generate the next 50 scheduled start times for this flow’s schedule, beginning after 1/1/21Josh Greenhalgh
01/28/2021, 7:36 PMJeremiah