Thread
#prefect-community
    David Haynes

    David Haynes

    5 months ago
    Hey folks. If I register a flow, I get an identifier back. How do I use that identifier to get the flow state information back from the service? I am probably just looking in the wrong place, but I can't find it in the docs.
    Kevin Kho

    Kevin Kho

    5 months ago
    What information are you looking for specifically?
    David Haynes

    David Haynes

    5 months ago
    Like the state returned from flow.run(), specifically the success/fail of the flow and, optionally, the success/fail of the tasks in the flow.
    Kevin Kho

    Kevin Kho

    5 months ago
    So there is a distinction between the flow id and flow run id. The flow id is the one you register, and one flow id corresponds to multiple runs so you want the flow run id. You would need to hit the GraphQL API to fetch the information. Could you tell me though what the intention is? Are you looking for this to run after every Flow to get an alert? Are you only interested in Failure?
    David Haynes

    David Haynes

    5 months ago
    Right now, the use case is a flow with tasks a, b and c. Let's say, task b raises an exception. Is there some way to query the server to ask 'Did that flow succeed or fail?'
    I guess that would be the flow run id. I'm not sure how to get that from a registered flow either.
    BTW 1.0 not Orion.
    You know what? Never mind. I think using a state handler will do everything I need. Thanks for helping.
    Kevin Kho

    Kevin Kho

    5 months ago
    Ok I am in the middle of typing a query but let me list the options:1. State handlers -> the flow will report itself if a task succeeds or fails 2. Automations -> Prefect Cloud sees something failed then sends a message 3. Your own query after the flow runs (am working on an example)
    query {
      flow (where: {id: {_eq: "2c5a1658-8b21-4d4e-924a-e9e4f5e56786"}}) {
        id
        name
        flow_runs (order_by: {start_time:desc},
                   limit:1){
          id
          name
          start_time
        }
      }
    }
    This query gets the latest flow run for a given flow id. And then with that flow_run you can query the state of the task runs
    David Haynes

    David Haynes

    5 months ago
    Thanks. That may come in useful in my next flow.
    Anna Geller

    Anna Geller

    5 months ago
    Is there some way to query the server to ask 'Did that flow succeed or fail?'
    You could also answer those questions by going to the UI - it might be easier that way
    David Haynes

    David Haynes

    5 months ago
    I don't think the UI would help in this case since I need the values programmatically.
    Kevin Kho

    Kevin Kho

    5 months ago
    Yeah the state handler will be easier because you can just use
    prefect.context.flow_run_id