View in #prefect-community on Slack
@Matthew_Roeschke: 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?
@Kyle_McChesney: This thread covers a number of options. https://prefect-community.slack.com/archives/C014Z8DPDSR/p1646856094674219
[March 9th, 2022 12:01 PM] shuchitatripathi2088: to run a flow frrom any code, we need to know the flow_id. how can we get the flow id programmatically?
@Kevin_Kho: 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"])
@Matthew_Roeschke: > You mean that number that just increases right?
Yes, okay I’ll use that. Thanks!