https://prefect.io logo
Title
m

Matthew Roeschke

04/05/2022, 3:10 PM
Hello. Is there a Python API to get the flow version given a flow name? Or is flow version only accessible via the
prefect get flows
cli command?
:discourse: 1
k

Kyle McChesney

04/05/2022, 3:22 PM
k

Kevin Kho

04/05/2022, 3:23 PM
I am not sure any of those actually hold the flow version. You mean that number that just increases right? I think you need to hit the GraphQL API with
client.graphql
to retrieve it
from prefect.client import Client 

client = Client()
query="""
query {
  flow(where: {name: {_eq: "schedule_test"}, archived: {_eq: false}}) {
    name
    project{
      name
    }
    version
    archived
  }
}
"""
print(client.graphql(query)["data"]["flow"][0]["version"])
m

Matthew Roeschke

04/05/2022, 3:27 PM
You mean that number that just increases right?
Yes, okay I’ll use that. Thanks!