https://prefect.io logo
m

Manik Singh

02/23/2021, 3:14 AM
Hi all, I'm having trouble finding any documentation around instantiating flow runs from a server app (fastapi). At present, here's the setup: 1. cloud as the backend 2. local agent + executor 3. web service (fastapi) running inside a docker container on my local machine If I've already registered some tasks by manually running a script, how am I supposed to instantiate flow runs from the web service? The python scripts with the task and flow definitions are also available for flask app
I think what i probably need is
prefect.tasks.prefect.flow_run.StartFlowRun
but where and how do i configure the access tokens for this function to run as expected?
z

Zanie

02/23/2021, 3:51 AM
The
StartFlowRun
task is actually for starting a flow run from a flow run. I believe you're just looking for https://docs.prefect.io/orchestration/concepts/flow_runs.html#core-client
m

Manik Singh

02/23/2021, 3:56 AM
thanks for replying. Through the client, can I create a flow run just on the basis of the flow name, and the latest un-archived version gets instantiated?
z

Zanie

02/23/2021, 4:00 AM
It requires the
flow_id
which you'd get when you register the flow. You can query for the latest unarchived run by flow name beforehand if you'd like. There's a user-contributed PR in progress to do this query for you (https://github.com/PrefectHQ/prefect/pull/4146) but you can also just look at the source code at
prefect.cli.run.flow
to see an example of the query needed
m

Manik Singh

02/23/2021, 4:04 AM
oh okay. Yes, already had a look at the code for the
run
cli command. Thanks for the guidance.