https://prefect.io logo
#prefect-community
Title
# prefect-community
e

ek

04/29/2022, 5:39 PM
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

Anna Geller

04/29/2022, 5:45 PM
šŸ‘€ 1
e

ek

05/05/2022, 2:42 AM
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

Anna Geller

05/05/2022, 10:49 AM
thanks for sharing!
e

ek

05/05/2022, 12:21 PM
thank you for pointing me to the right direction! šŸ˜‰
šŸ‘ 1
4 Views