https://prefect.io logo
Title
a

Aniruddha Sengupta

03/02/2022, 12:42 PM
Hi All, I am trying to run a flow with some labels with
["aniruddhas", "parallel_example"]
. I have an Agent whose label's are dynamically updated every time a flow is registered so that any new labels on flows are added to the agent. So now my Agent contains these labels :
["aniruddhas", "prefect_spider", "simple_news_spider", "parallel_example"]
. I have now experimented with it and found that when my flow has just the label
["aniruddhas"]
, the Agent is able to pick them up and run them. But if the flow run has its original labels:
["aniruddhas", "parallel_example"]
, the Agent is not able to pick them up. Why is this the case? Thanks, Aniruddha
a

Anna Geller

03/02/2022, 12:55 PM
This is indeed a bit puzzling, perhaps you could restart your agent or reregister your flow? In general, the labels on your flow run config must be a subset of your agent labels in order for that agent to pick this up. Do you happen to use a local agent? Any time you use a local agent, by default Prefect adds a hostname as an extra-label, and then when you register your flow with local storage, Prefect also adds the hostname as a label to your flow. Could it be that you started your local agent without a hostname label:
prefect agent local start --no-hostname-label
and your flow with local storage does have it, causing that this agent cannot pick up flow runs of this flow? To disable adding the hostname label to your flow, you can set it either directly on your Local storage or on `flow.register()`:
flow.storage = Local(..., add_default_labels=False)
 # or during registration
 flow.register(add_default_labels=False)
Also, you can inspect the labels directly in the UI in the flow page to see whether the hostname label got added or not:
a

Aniruddha Sengupta

03/02/2022, 6:11 PM
Hi Anna Thanks for your reply. I think the problem was that when the Agent first started, it only had the label`["aniruddhas"]`. Even though the process used GraphQL mutations to update the agent's labels in the UI, the Agent running in the terminal didn't update its labels, it remained stuck at just
["aniruddhas"]
. When I restarted the agent in the terminal with the labels
["aniruddhas", "parallel_example"]
the agent is then able to pick it up and schedule it. So the interesting point I learned here is that you are able to use GraphQL mutations to change flow runs, labels on flows, flow_runs and agents. But the underleying agent itself, which was started in the terminal, needs to be restarted with the relevant labels in order to pick up flows.
a

Anna Geller

03/02/2022, 6:22 PM
You're spot on, there are at least 4 different ways to change flow labels but to change labels on the agent, you would need to restart it with new or updated labels
👍 1