ek

    ek

    4 months ago
    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:
    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
    Anna Geller

    Anna Geller

    4 months ago
    ek

    ek

    4 months ago
    in case anyone wants this exact solution, here is the query to get the latest flow_id version from project_id
    query {
      flow (
        where: {project_id: {_eq: "PROJECT_ID"}}
        order_by: {version: desc}, limit: 1
      ) {
        id
        name
        version
        created
      }
      
    }
    Anna Geller

    Anna Geller

    4 months ago
    thanks for sharing!
    ek

    ek

    4 months ago
    thank you for pointing me to the right direction! šŸ˜‰