https://prefect.io logo
j

Jon Ruhnke

11/02/2022, 8:46 PM
I'm testing flows locally during development by simply typing "py .\flow.py" in powershell, and the results are inadvertently getting communicated up to my prefect cloud UI without an agent running. How is this possible?
1
b

Bianca Hoch

11/02/2022, 8:48 PM
Hey Jon, assuming you are running a flow using 2.0, agents and work queues are only required if you want to trigger flows via UI or API.
r

Ryan Peden

11/02/2022, 8:48 PM
If you ran
prefect cloud login
or manually set
PREFECT_API_URL
and
PREFECT_API_KEY
, then local Prefect runs will send results to Prefect Cloud.
🙌 1
j

Jon Ruhnke

11/02/2022, 8:52 PM
That's wild. So what's the best practice for separating my local test runs from say flows that have been promoted to DEV or PROD status? Is that where different named work queues come in? Or tags? Or can I even differentiate them in the UI based on which API key was used to login?
r

Ryan Peden

11/02/2022, 8:57 PM
You can use profiles for that if you want to avoid sending anything to the Cloud account. For example:
Copy code
prefect profile create dev
then:
Copy code
prefect profile use dev
And you'll have a fresh profile that will only store results locally. Then you can switch back to the default profile or create a production profile you can use when you want to do things like deploy to production.
j

Jon Ruhnke

11/02/2022, 9:01 PM
But what if I want my local runs and my dev and prod runs to all show up on the cloud ui, but be filterable? I see the cloud "flow run" webpage has filters for "deployment" and "tags" that seem useful for something like that
Looks like the whole concept of tags may be deprecated?
r

Ryan Peden

11/02/2022, 9:06 PM
Ah - understood. In Organization accounts, separate workspaces for dev, production, etc. can be a good way to keep things separate. Otherwise, separate dev and production deployments are one option. Flow tags are another. Work queue tags are deprecated, but now flow run tags.
If you wanted to run a flow using a 'test' tag without altering the flow's code, you could do something like:
Copy code
def test_my_flows():
    my_flow.with_options(tags=["test"])
    my_other_flow.with_options(tags=["test"])
j

Jon Ruhnke

11/02/2022, 9:28 PM
That code didn't work for me. Is it like this now?
Copy code
from prefect import tags
with tags("db", "blue"):
    my_flow("foo")
r

Ryan Peden

11/02/2022, 9:29 PM
Yes, I believe so - sorry, my mistake on that.