https://prefect.io logo
Title
d

Dylan McReynolds

08/30/2022, 5:25 PM
Hi. I using prefect 2.2. I have a use case that looks something like this: • A data file has been created, I create a flow_run using the client API with the file path as a parameter • At the end of the flow, if it has not errored, then I want more tasks to run, but I need it to wait for a particular interval (day, week) I could do this with my own external scheduling system (that I have not written), but I would love to do that within prefect if possible. So my question…within a
flow
, is there a way to schedule a subflow to start at a particular time in the future? Or some other way to accomplish a long-delayed subflow/task?
t

Taylor Curran

08/30/2022, 7:07 PM
Yes Dylan, there are many ways this could be accomplished!
Have you checked out
prefect.client
from our Python API? https://docs.prefect.io/api-ref/prefect/client/
This is an example in which a flow can run inside of a flow.
d

Dylan McReynolds

08/30/2022, 7:14 PM
@tc_prefect Yes, thanks. I’m using the Orion client to kick of the initial flows. However, I don’t see a way to schedule the flow_run to not start until, say, 1 day from now.
And I also don’t see a way to schedule a flow to launch a subflow…but not until 1 day from now. I suppose I could simply put a 24 hour pause in the parent flow, but it seems like I’d start backing up hundreds of flows a day.
t

Taylor Curran

08/30/2022, 7:18 PM
I wonder if you create a new deployment with the desired schedule 24h+now?
d

Dylan McReynolds

08/30/2022, 7:20 PM
Hmmmm…but then I’d be creating hundreds of deployments a day…for the same flow
or maybe I misunderstood
t

Taylor Curran

08/30/2022, 7:36 PM
I’m pretty sure we’ve set up deployments to handle complex scheduling like you’re describing. I’ve actually reached out to a colleague that might know more than me. We’ll get back to you later, sorry I couldn’t answer of the top of my head!
And do let us know if you’ve found something!
Hi @Dylan McReynolds another person named @Dylan has come in clutch with a possible solution. Could you use the state argument in the create_flow_run()/from_deployment() method to set state=Scheduled(scheduled_time=now+24) something like:
client.create_flow_run(state=Scheduled(scheduled_time={}))
Will you let us know how this goes?
🙌 3
d

Dylan

08/30/2022, 8:26 PM
@Marvin open “Document Creating Scheduled Flow Run for Deployment”
❤️ 2
🔥 2
d

Dylan McReynolds

08/30/2022, 10:11 PM
@tc_prefect @Dylan this solution looks like it’s working for me!
t

Taylor Curran

08/30/2022, 11:50 PM
YAYYY! 😛anda-dancing: