Question: I am able to create a flow run from REST...
# prefect-community
c
Question: I am able to create a flow run from REST API, I can see the flow run in the prefect cloud UI. but the flow does not run until the workpool is started. I would like the work pool to be always running so when I submit a job it runs. What is the right way to think about this and the right way to do this in prefect cloud ?
Copy code
curl --location --request POST '<https://api.prefect.cloud/api/accounts/xxx/workspaces/xxx/flow_runs/>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--header 'X-PREFECT-API-VERSION: 0.8.4' \
--data-raw '{
    "name": "my-flow-run",
    "flow_id": "xxx",
    "deployment_id": "xxx"
}'
1
b
Hey Chandan! Work pools organize scheduled flow runs for execution, and agents/workers poll their respective work pools for new runs that need to be executed. As long as you have an agent or worker running somewhere in you execution environment, and the work pool is enabled in the UI, you should be able to run the flow run to completion. You can find a bit more information on work pools and agents here.
c
Thank you Bianca, Ill read up on Work Pools and agents
@Bianca Hoch question. I read the docs and as you mentioned I see you need to have an agent running. When I use preflect cloud. Can i set an agent to be running all the time in the prefect cloud.
I am lost on why I need to start an agent for perfect cloud. I assumed it would always be running awaiting jobs/flow-runs
b
The agent wouldn't be running in Prefect Cloud, it would be hosted in the execution environment or cloud infrastructure where your workflows will be executed.
c
aah I see
b
Workers/agents and workpools bridge the gap between your execution environment and Prefect's Cloud orchestration environment
c
I am using an infrastructure block (docker container) so I would need to start the prefect agent from within the docker container?
b
You certainly can, and if you want the agent to be a long running process, you can daemonize it with Docker. Here's an example of how to do that.
c
Ok got it, Ill read this link and revert if i still have a question.Thank you
1
🙌 1
I think I get it now. Agents need to be running separately from Prefect Cloud. and I found a few recipes to run agents. https://github.com/PrefectHQ/prefect-recipes/tree/main/devops/infrastructure-as-code/aws/cli-prefect2-ecs-agent Earlier, I assumed the agents are part of the Prefect cloud and always running, That was incorrect.
1
b
Correct! Glad you found our recipes too, that's a good starting point to get an idea of common orchestration patterns and guides.
🙌 1
n
hi @Bianca Hoch! I've been learning the same thing in the last day. I'm curious if you have any recipes where flows themselves are included. I am following the terrafrom-ecs-fargate recipe (same repo), and I am able to get start a flow from a deployment, but they are crashing and the logs are confusing. It seems like my agent isn't creating I feel like I am missing a step where the agent provisions the tasks in separate container on ECS. Are there any recipe examples with flows included so I can see the whole process?