Hi everyone, I want to register a flow and then cr...
# ask-community
s
Hi everyone, I want to register a flow and then create deployments later on using the API. I saw that there’s a
prefect_client.create_deployment
method in the Python Client SDK, but it requires the Flow ID. How would I get the flow ID? Also, I’m not using the
serve
method, I wanna use workers, and use docker compose to run everything. I have a prefect server container, and a worker container which starts a worker using the
prefect worker
command. After these two are running the flow is not registered with the API yet which makes sense. So I guess my question is, how should I register the flow and get the flow ID, so that I can later call the
create_deployment
method to create deployments whenever needed programmatically.
j
To get a flow id you similarly can use the
prefect_client
Copy code
@flow
def foo():
    pass
    
flow_id_1 = await prefect_client.create_flow(foo)
s
Oh okay makes sense, I’ll try that out. A follow up question: given I’m programmatically making deployments from my app logic, how can I run the task runners or something equivalent so that a pool of “workers” are available to run whenever I create a flow run? I don’t think the simple
serve
would cover this case?
Because from what I understood a serve is tied to a deployment.
a
@Sumit Ghosh you can start a worker that polls a given work pool. That worker will then execute any flow runs scheduled in that work pool, so you’d want to create your deployments in that same work pool. Depending on the infrastructure you use, you might be able to use a push work pool, which means you wouldn’t need to host your own worker.
1