https://prefect.io logo
d

Dolor Oculus

10/01/2020, 7:08 PM
Hi, is there a way to see if a project already exists?
Copy code
from prefect import Client
client = Client()
client.create_project(project_name="Hello, World")
# client.get_project(project_name="Hello, World")
When registering a flow, it looks a project is required in later versions of prefect, but for automation purposes I'd like to see if the project already exists before trying to create.
n

nicholas

10/01/2020, 7:16 PM
Hi @Dolor Oculus - definitely! You can use the client
.graphql
method to query for projects to see if the one you're trying to register to exists, so something like this:
Copy code
query = """
  query {
  project {
    id
    name
  }
}
"""
projects = client.graphql(query=query)
# check that project you want is listed in the data returned in projects
d

Dolor Oculus

10/01/2020, 7:18 PM
nice ty
👍 1