https://prefect.io logo
l

Lee Cullen

02/18/2022, 2:21 AM
Hi all! I keep running into an issue when registering a flow to prefect cloud. I can successfully do it when running via CLI but when I switch to registering through flow.register() i get
Invalid Project!
even though the project exists.
k

Kevin Kho

02/18/2022, 2:31 AM
That is the first time I’ve seen it. Did you recently delete this project? Does the CLI work?
l

Lee Cullen

02/18/2022, 2:38 AM
Hey Kevin. The project exists on the cloud UI. When running it via CLI it works fine but when i register after my flow definition it doesn't work (see code sample above). Error:
Invalid project!
When i run
prefect get projects
on the cli I can see the project. I have also authenticated via service account so Im not sure what I'm doing wrong.
k

Kevin Kho

02/18/2022, 2:39 AM
Can you try moving the register outside of the Flow block? I dunno if it will make a difference
l

Lee Cullen

02/18/2022, 2:40 AM
I've tried that but still getting the same error. I'll try again just to be sure.
k

Kevin Kho

02/18/2022, 2:45 AM
Oof! It should be
project_name
inside register or you can just not name the argument
l

Lee Cullen

02/18/2022, 2:49 AM
Sorry that was a typo in my sample code. I can confirm I was using
project_name
.
k

Kevin Kho

02/18/2022, 2:50 AM
Ah can you try just leaving it unnamed?
l

Lee Cullen

02/18/2022, 2:51 AM
Running
flow.register()
still gives me invalid project. Weird!
k

Kevin Kho

02/18/2022, 2:52 AM
No I mean
flow.register("project1")
. Just empty?
Do you use your API key in the CLI or something? I’m wondering about authentication to a different tenant?
Maybe you can try:
Copy code
from prefect import Client
Client().get_available_tenants()
and see where you are authenticated?
l

Lee Cullen

02/18/2022, 2:56 AM
prefect auth list-tenants
only lists one tenant,.
k

Kevin Kho

02/18/2022, 2:58 AM
I am wondering if the Client is getting another token or something rather than the CLI (which I can’t imagine but I have no better ideas at the moment)
I find your log weird because mine is:
Copy code
ValueError: Project test not found. Run `prefect create project 'test'` to create it.
What version of Prefect are you on?
l

Lee Cullen

02/18/2022, 3:03 AM
This is rather embarrassing 😅. So the error I was getting was related to one of my own arg parser functions (used to run specific flows from the cli). Once I resolved that issue then the flow registered successfully. Thanks anyway for your help, it was really informative.
k

Kevin Kho

02/18/2022, 3:04 AM
No worries man I’m that you solved it cuz I was grasping for solutions here. That’s good to know!
🙌 2
4 Views