https://prefect.io logo
Title
t

Tushar Gupta

02/22/2023, 4:03 PM
Hello everyone Quick question, I want to ask please help me out, I am unable to find out. I have a project named ABC in which flow name is let say XYZ now whenever I run my XYZ flow as everyone knows prefect give random names to the runs. Now I want to get the time at which the latest success run occurred using python. Please help me out. Thanks in advance!
@Joshua Grant Using prefect v1 version 1.2.4
j

Joshua Grant

02/22/2023, 4:29 PM
are you using cloud? deleted my comment because I don't know anything about cloud. If you can access the orion API, you can query there
t

Tushar Gupta

02/22/2023, 4:31 PM
Yes we use cloud to run our flow. Need python code to get latest success flow run
j

Joshua Grant

02/22/2023, 4:40 PM
if you can use the API, you can post this graphql query using requests (you can add some other adjustments to narrow it down, this query gives all the flow runs named "XYZ"):
query FlowRuns {
  flow_run(where: {flow: {name: {_eq: "XYZ"}}}) {
   id
   state
   flow {
     name
   }
   name
   flow_id
   parameters
 }
}
:thank-you: 1
if you have the interactive API available, you can test/adjust the query there to give you exactly what you want and then adjust the python requests payload
t

Tushar Gupta

02/22/2023, 4:45 PM
Thank you very much
👍 1