Fabrice Toussaint
05/25/2021, 12:19 PMKevin Kho
flow_runs
from the graphQL API, and I don’t know if this deletes the logs.Fabrice Toussaint
05/25/2021, 1:24 PMKevin Kho
query {
flow_run (where: {state: {_eq: "Success"}}){
id
name
state
}
}
mutation {
delete_flow_run(input: {
flow_run_id: "02a4cd19-50cd-49b2-bf1b-ff632f0ded3a",
}) {
success
}
}
Kevin Kho
Fabrice Toussaint
05/25/2021, 2:51 PMFabrice Toussaint
05/25/2021, 2:52 PMKevin Kho
Fabrice Toussaint
05/25/2021, 2:54 PMKevin Kho
Fabrice Toussaint
05/26/2021, 6:42 AMKevin Kho
Client.graphql
here: https://docs.prefect.io/api/latest/client/client.htmlFabrice Toussaint
05/26/2021, 1:23 PMKevin Kho
Client.graphql
inside a flow to run a GraphQL query..Fabrice Toussaint
05/26/2021, 1:24 PMKevin Kho
client = Client()
def build_query(days: int = 7) -> str:
"""
Returns GraphQL query to get flows and state in
last couple of days
"""
begin_date = date.today() - timedelta(days=days)
query = """
query {
flow_run(where: { end_time: {_gt: \"""" + str(begin_date) + """\"} }) {
id
name
state
end_time
}
}
"""
return query
@task(retry_delay=timedelta(seconds=60), max_retries=3)
def get_flows(query: str) -> list:
result = json.loads(client.graphql(query).to_json())
return result["data"]["flow_run"]
Kevin Kho
Fabrice Toussaint
05/27/2021, 7:01 AMFabrice Toussaint
05/27/2021, 7:03 AMFabrice Toussaint
05/27/2021, 7:05 AM