Is there a way to use Prefect Client to get a late...
# ask-community
e
Is there a way to use Prefect Client to get a latest flow_id within a project?
here is an example code of what I’m trying to do:
Copy code
from prefect import Client

api_server="<http://prefect-server-apollo:4200>"
tenant_id="XXXX"
flow_id="XXXX" 

client = Client(api_server=api_server,tenant_id=tenant_id)
flow_run = client.create_flow_run(
    flow_id=flow_id,
    parameters={"KEY": "VALUE"}
)
print(flow_run)
flow_status = client.get_flow_run_state(flow_run)
print(flow_status)
I want to make
flow_id
to reflect the latest from from the project
a
šŸ‘€ 1
e
in case anyone wants this exact solution, here is the query to get the latest flow_id version from project_id
Copy code
query {
  flow (
    where: {project_id: {_eq: "PROJECT_ID"}}
    order_by: {version: desc}, limit: 1
  ) {
    id
    name
    version
    created
  }
  
}
a
thanks for sharing!
e
thank you for pointing me to the right direction! šŸ˜‰
šŸ‘ 1