How to use work queues and agents in Prefect 2.0? I'm switching from Prefect 1.0 and wonder how agents differ between 1.0 and 2.0

View in #prefect-server on Slack

Egil_Bugge @Egil_Bugge: Hey all!

Tested out Prefect Orion in the cloud yesterday and had the following scenario:
• Made a simple hello world flow with a deployment spec

@flow
def hello_world(name="world"):
    print(f"Hello {name}!")

DeploymentSpec(
    flow = hello_world,
    name="hello-world",
)

• Made a work queue and connected the work queue to this deployment
• Span up an agent locally and connected it to this work queue
• Clicked into the Deployments tab in the UI and selected “Quick run” which scheduled a run of my flow
Then nothing happened, my local agent didn’t pick up the flow. I then made a new work queue which I did not connect to the deployment and connected my agent to this new work queue instead. Now it immediately picked up the flow that I had started earlier and ran it.

Is there something more I need to do to get an agent to pick up flows connected to a deployment?

Anna_Geller @Anna_Geller: If you are switching from Prefect 1.0 agents to Prefect 2.0 work-queues and agents, a good mental model would be treating a work-queue as a way to assign a label to your agent. For a local agent, you could assign a tag called local:

prefect work-queue create local -t local
prefect agent start QUEUE_ID

and then, on your DeploymentSpec use the same tag local:

DeploymentSpec(
    flow=hello_world,
    name="sandbox",
    tags=["local"]
)

Egil_Bugge @Egil_Bugge: Ah, okey! Thank you :slight_smile:

Related topics