I saw Franznist gave a great answer. Are you good now? The main issue in your Flow is that you are calling a Flow from within a task - this is not supported, especially not using
flow.run()
since this is meant only for local development.
Anna Geller
04/12/2022, 11:14 AM
Some additional notes:
• scheduling a flow every second is not possible 🙂 the lowest we can do is every 1 minute in Prefect 1.0
• when you print in your tasks, you need to add log_stdout arg:
@task(log_stdout=True)
• to add parameters for the "sleep time" in between runs, you can also use a Parameter task
• instead of calling a flow, you could also call a normal parametrized Python function when looping - perhaps that would be easier to manage?
Anna Geller
04/12/2022, 11:18 AM
btw your use case seems better suited for Prefect 2.0 - perhaps it's easier to do it directly with 2.0 if you're just getting started?
a
Alexander Belikov
04/12/2022, 12:36 PM
Thanks a lot! Franznist's answer is great indeed. I was wondering if there is a "prefectonic" way of doing
sleep
Calling a task from a flow is not supported, but it works (and the reference I gave cite prefect slack as the source of recommendation), so will you called a hack that should be avoided?
instead of calling a flow, you could also call a normal parametrized Python function when looping
Indeed it would easier
Alexander Belikov
04/12/2022, 12:37 PM
thanks!
a
Anna Geller
04/12/2022, 12:44 PM
Calling a task from a flow is not supported, but it works
Calling a task from a Flow is supported, but calling a Flow from a task is not - perhaps you misread my message? 🙂
Regarding Gaetan's StackOverflow answer, this is not a pattern I would recommend.
I was wondering if there is a "prefectonic" way of doing
sleep
You can alternatively use the
create_flow_run
task with a custom
scheduled_start_time
but this will have the same effect.
a
Alexander Belikov
04/12/2022, 12:49 PM
oh, yes - it's typo, I was referring to your words and I meant to say calling a flow from a task. Gotcha.
thank you, using
scheduled_start_time
sounds great, will check it out
a
Anna Geller
04/12/2022, 1:02 PM
to be transparent, I don't think that using
scheduled_start_time
is the right solution to your problem, it was only to answer your question
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.