Raúl Mansilla
10/19/2021, 9:58 AMAnna Geller
10/19/2021, 11:38 AMRaúl Mansilla
10/19/2021, 11:40 AMquery {
flow_run(
where: { state: { _eq: "Failed" }, }
order_by: { state_timestamp: desc, }
limit: 10
) {
start_time
#end_time
name
state
state_message
agent {
name
#type
}
#parameters
}
}
Anna Geller
10/19/2021, 11:40 AM{
flow_run(where: {state: {_eq: "Scheduled"},
start_time: {_is_null: true}}) {
id
name
flow {
name
id
}
agent {
type
name
}
start_time
end_time
}
}
Raúl Mansilla
10/19/2021, 11:41 AMAnna Geller
10/19/2021, 11:42 AMfrom prefect.client.client import Client
client = Client()
flow_id = {"flow_id": "uuid-of-your-flow"}
response = client.graphql(
"""
mutation($flow_id: UUID!) {
set_schedule_inactive(input: {flow_id: $flow_id}) {
success
error
}
}""",
variables=flow_id,
raise_on_error=True,
)
print(response)
Raúl Mansilla
10/19/2021, 11:44 AMAnna Geller
10/19/2021, 11:49 AMRaúl Mansilla
10/19/2021, 11:49 AMAnna Geller
10/19/2021, 12:27 PM{
flow_run(where: {state: {_eq: "Scheduled"},
start_time: {_is_null: true},
scheduled_start_time: {_lt: "2021-10-19T12:27:45"}}) {
id
name
scheduled_start_time
auto_scheduled
flow {
name
id
}
agent {
type
name
}
start_time
end_time
}
}
Raúl Mansilla
10/19/2021, 1:14 PMAnna Geller
10/19/2021, 1:44 PMRaúl Mansilla
10/19/2021, 3:07 PMAnna Geller
10/19/2021, 8:24 PMlast_queried
from agent
will be most helpful in your use caseRaúl Mansilla
10/19/2021, 9:20 PM{
flow_run(where: {state: {_eq: "Scheduled"},
start_time: {_is_null: true},
scheduled_start_time: {_lt: "2021-10-20T22:35:45"}}) {
id
name
state
state_message
scheduled_start_time
auto_scheduled
flow {
name
id
}
agent {
type
name
}
start_time
end_time
}
}
{
"flow_run": [
{
"id": "aacb0885-fcc2-4c48-bc41-4268ff7a0cac",
"name": "uptight-tody",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:25:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "Ext Adv Ingest Trigger",
"id": "0d89687e-8670-4538-a3ef-690715fce719",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "36147eda-7f51-45ec-bf00-54823aed4ba0",
"name": "fierce-turkey",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:44:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Priority Status Update Trigger",
"id": "aaf63191-b68c-4051-ac2b-a65b0df58ee6",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "6789c8d8-a93c-4072-8da3-61fd9a22b939",
"name": "positive-seal",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:44:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "Ext Adv Update Trigger",
"id": "a449c748-1fc8-438d-9f2a-5d090013a6b1",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "f3b8064b-f896-4817-a6ee-3bc6e7de6175",
"name": "spiked-poodle",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:03:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Status Update Trigger",
"id": "10244167-da97-4b2e-be7a-80c4b7c1896d",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "c9f57e32-827e-4836-8e23-cb14411c6bbc",
"name": "beige-ibex",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:00:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Status Update Trigger",
"id": "10244167-da97-4b2e-be7a-80c4b7c1896d",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "0ea9a312-8f93-4456-a59b-ce2bf0536b41",
"name": "rare-jackdaw",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T20:57:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Status Update Trigger",
"id": "10244167-da97-4b2e-be7a-80c4b7c1896d",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "afd16122-9c4b-4217-836c-669b529f856d",
"name": "manipulative-swine",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:20:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "Ext Adv Ingest Trigger",
"id": "0d89687e-8670-4538-a3ef-690715fce719",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "129986a5-3925-40e0-b6bc-bce5a4280f93",
"name": "stylish-boa",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:37:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Priority Status Update Trigger",
"id": "aaf63191-b68c-4051-ac2b-a65b0df58ee6",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "4ad5c1e9-ca75-499f-8fec-d2413cf99336",
"name": "kind-albatross",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T21:37:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "Ext Adv Update Trigger",
"id": "a449c748-1fc8-438d-9f2a-5d090013a6b1",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
},
{
"id": "8b6d0f8b-b8f6-4883-951f-daa28a30e313",
"name": "amiable-dolphin",
"state": "Scheduled",
"state_message": "Flow run scheduled.",
"scheduled_start_time": "2021-10-20T20:51:00+00:00",
"auto_scheduled": true,
"flow": {
"name": "MediatorX Status Update Trigger",
"id": "10244167-da97-4b2e-be7a-80c4b7c1896d",
"__typename": "flow"
},
"agent": null,
"start_time": null,
"end_time": null,
"__typename": "flow_run"
}
]
}
Kevin Kho
10/20/2021, 8:44 PMstart_time
is null and scheduled_start_time
is before the current time?Raúl Mansilla
10/20/2021, 8:44 PMKevin Kho
10/20/2021, 8:45 PMRaúl Mansilla
10/20/2021, 8:47 PMKevin Kho
10/20/2021, 8:49 PMRaúl Mansilla
10/20/2021, 8:55 PMKevin Kho
10/20/2021, 8:58 PMRaúl Mansilla
10/20/2021, 9:10 PMKevin Kho
10/20/2021, 9:15 PMRaúl Mansilla
10/21/2021, 9:40 AMAnna Geller
10/21/2021, 9:50 AMstate
is Scheduled
• scheduled_start_time
is in the past
• start_time
is null
There could be some nuance related to agents as well, e.g. if the agent picked it up but for some reason couldn’t start, with this definition it would still be a late run, even though the agent actually picked up the scheduled FlowRun.Raúl Mansilla
10/21/2021, 10:54 AMquery = gql(
"""
query FlowRuns($projectId: uuid, $heartbeat: timestamptz, $start: timestamptz, $end: timestamptz) {
SuccessTotal: flow_run_aggregate(
where: {
flow: { project_id: { _eq: $projectId } }
scheduled_start_time: { _gte: $heartbeat }
state: { _eq: "Success" }
}
) {
aggregate {
count
}
}
Success1h: flow_run_aggregate(
where: {
flow: { project_id: { _eq: $projectId } }
_and: [
{scheduled_start_time: { _gt: $start }},
{end_time: { _lt: $end }},
]
state: { _eq: "Success" }
}
) {
aggregate {
count
}
}
Anna Geller
11/02/2021, 5:07 PMKevin Kho
11/02/2021, 5:09 PMgte $heartbeat
?Raúl Mansilla
11/02/2021, 5:09 PMAnna Geller
11/02/2021, 5:11 PMRaúl Mansilla
11/02/2021, 5:14 PMAnna Geller
11/02/2021, 5:15 PM