question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IntervalSchedule with start_date=now starts at now+interval

See original GitHub issue

When initializing a IntervalSchedule with start_date=datetime.now() argument I would expect that the flow the schedule is attached to starts immediately but instead the first run is scheduled at now + interval.

I think the problem results from the fact that between initializing the schedule and running the flow (when the next function of the schedule is called) the time difference between after and start_date for calculating the skip here https://github.com/PrefectHQ/prefect/blob/3d2a26f1f147ce8a613493dd60de4b4e451300d3/src/prefect/schedules/clocks.py#L104 becomes positive.

Maybe this is intended but I think it is confusing behavior.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jlowincommented, Aug 17, 2020

@johalnes Prefect doesn’t share Airflow’s strict conflation of “execution date” and “run date”, so there’s a few ways to achieve this. The most straightforward is just to trigger multiple runs of your flow, appropriately parameterized for the period you want the flow to act on.

For example, if your flow bases its logic on the scheduled_start_time, just create flow runs that are scheduled in the past:

client.create_flow_run(flow_id, scheduled_start_time=past_dt)

Alternatively, if you’re parameterized, you could do something like:

client.create_flow_run(flow_id, parameters=dict(execution_date=past_dt)

(You can also do this via the UI or GraphQL API).

We have facilities for kicking off the scheduler logic via API but they only start from now, not from a past date… perhaps we could look at adding that parameter logic.

0reactions
johalnescommented, Aug 17, 2020

@jlowin is there a way to trigger Airflow’s way of trigger schedules in the past? I understand the frustration when it comes to this being default behavior. But for instance when changing some ETL processes, one would often like to truncate everything and apply improved logic. How would you solve this with Prefect?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found