https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Alexander Belikov

04/12/2022, 8:59 AM
Hi! I have a question about using two schedules in the flow of flows construct: I posted it here https://stackoverflow.com/questions/71839812/prefect-loop-over-flows-two-schedules
a

Anna Geller

04/12/2022, 10:54 AM
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.
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?
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
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
8 Views