What is the right way to invoke a flow from anothe...
# best-practices
e
What is the right way to invoke a flow from another flow? Not a subflow. Another flow simply deployed on the same server
n
hey @Edmondo Porcu - you can use
run_deployment
, let me find an example
which, will actually behave like a subflow with respect to your parent flow.... unless you wrap
run_deployment
in a
@task
so that you can
.map
and / or
wait_for
those calls like you can with tasks
h
Interesting approach @Nate. I was going to suggest using the client - I have used that to reschedule stuff, and triggering once was fairly straightforward as well. I added the
run_deployment
approach to my example as well, although I haven’t been able to wrap it correctly to avoid it behaving like a subflow: https://github.com/radbrt/orion_flows/blob/c654c7589d02c9cdb777d2833ee862452b0b19dc/projects/jottings/reschedule/flow.py#L34
thank you 1
n
ah - i guess it wasnt accurate to suggest that it wouldnt technically be a subflow if wrapped in a task. i do see that it still shows up in the UI as as subflow even if
run_deployment
is wrapped in a task. yeah, using the API is always an option otherwise if you want to avoid the subflow bit
h
@Nate I tried to create a deployment run scheduled at a given time in the future, like this:
client.create_flow_run_from_deployment(deployment.id, state=Scheduled(scheduled_time=pendulum.datetime(2024, 1, 2, 3, 0, 0, 0, tz="Europe/Oslo")))
, following the example from https://discourse.prefect.io/t/how-to-schedule-a-flow-run-from-a-deployment-for-a-specific-date/1654. It seems the flow starts immediately instead of running at the scheduled time. Any idea why?
n
hmm i wonder if it could be some TZ weirdness - im not sure off the top of my head without more info hm oh wait did you use the client or server schemas for filters and stuff? coincidentally, I just opened a PR for docs on rescheduling Late flow runs with the client - maybe that could be helpful?
run_deployment
should definitely work for this though
h
Whow, that is a great addition to the docs. I have yet to figure out what the salient difference is, but using the docs I was able to programatically schedule a run in the future.
❤️ 1