Darin Douglass
05/06/2022, 8:27 PMAnna Geller
Darin Douglass
05/06/2022, 8:28 PMAnna Geller
Darin Douglass
05/06/2022, 8:33 PMAnna Geller
Anna Geller
Darin Douglass
05/06/2022, 8:43 PMQueued
was canceled
• the run before that diedDarin Douglass
05/06/2022, 8:45 PMit should trigger immediately the next runthis is our end-goal. right now it’s (a dbt sync) scheduled hourly but often (always) runs over that hour. the task limit is to avoid two of the flows running at the same time
Darin Douglass
05/06/2022, 8:45 PMAnna Geller
from prefect import task, Flow
from prefect.tasks.prefect import create_flow_run
import time
@task(log_stdout=True)
def hello_world():
print("Sleeping...")
time.sleep(4) # to have enough time to kill it
return "hello world"
def never_ending_state_handler(obj, old_state, new_state):
if new_state.is_successful():
create_flow_run.run(flow_name="never-ending-flow", project_name="community")
return new_state
with Flow("never-ending-flow", state_handlers=[never_ending_state_handler]) as flow:
hello_task = hello_world()
Darin Douglass
05/06/2022, 8:52 PMDarin Douglass
05/06/2022, 8:53 PMcreate_flow_run
after waiting for the others to be done. i like the state_handlers
betterDarin Douglass
05/06/2022, 8:55 PMAnna Geller
Anna Geller
Kevin Kho
query {
task_run (where: {state: {_eq: "Running"},
task: {tags: {_contains: "tag"}}}) {
id
flow_run{
name
id
}
task{
name
tags
}
}
}
Darin Douglass
05/06/2022, 9:45 PMDarin Douglass
05/06/2022, 9:45 PM{
"data": {
"task_run": [
{
"id": "2caa3558-931c-4243-8713-f3189831f4cc",
"flow_run": {
"name": "sensible-shellfish-main",
"id": "a1c3ccd1-89e1-4657-8a0c-5d47b211987b"
},
"task": {
"name": "dbt_run",
"tags": [
"dbt-run",
"dbt-run-main"
]
}
},
{
"id": "3ebcb221-f333-438c-a962-2d86f0f51103",
"flow_run": {
"name": "brass-hog-main",
"id": "34b08fe9-14e2-4f33-835e-b3df2a96f466"
},
"task": {
"name": "dbt_run",
"tags": [
"dbt-run",
"dbt-run-main"
]
}
}
]
}
}
Darin Douglass
05/06/2022, 9:45 PMDarin Douglass
05/06/2022, 9:46 PMDarin Douglass
05/06/2022, 9:46 PMKevin Kho
Darin Douglass
05/06/2022, 9:48 PMfinally
after the dbt run not shutting down / waiting incorrectlyKevin Kho
Darin Douglass
05/06/2022, 9:48 PM