https://prefect.io logo
h

Hugo Kitano

02/11/2022, 7:42 PM
whats the best way to get the most recent failed flow runs for a specific flow in Python?
k

Kevin Kho

02/11/2022, 7:45 PM
You have to use the graphql API I think with something like:
Copy code
query{
  flow(where:{name:{_eq:"some name"}}){
    name
    flow_runs(where:{state:{_eq:"Failed"}}){
      state
    }
  }
}
🙌 1
h

Hugo Kitano

02/11/2022, 8:01 PM
awesome, i’m getting a return of this like so, how would i return the parameters of each flow?
Copy code
{
  "data": {
    "flow": [
      {
        "name": "prefect-flow",
        "flow_runs": [
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          },
          {
            "state": "Failed"
          }
        ]
      }
    ]
  }
}
k

Kevin Kho

02/11/2022, 8:02 PM
Add
parameters
inside the
flow_runs
I think:
Copy code
query{
  flow(where:{name:{_eq:"some name"}}){
    name
    flow_runs(where:{state:{_eq:"Failed"}}){
      parameters
      state
    }
  }
}