Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for dags to refresh before triggering them #81

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions slackbot/airflow_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,24 @@ def __run_dag(dag_id):
return trigger_dag(dag_id)


def wait_for_dag_refresh(dag_id):
last_parsed_time = None
for _ in range(10):
dag = DagModel.get_dagmodel(dag_id)
if not last_parsed_time:
last_parsed_time = dag.last_parsed_time
else:
if dag.last_parsed_time > last_parsed_time:
print(dag.last_parsed_time)
print(last_parsed_time)
return
time.sleep(5)


def run_dag(dag_id, wait_for_completion=False):
dags_need_refresh = ["segmentation", "chunkflow_worker"]
if dag_id in dags_need_refresh:
wait_for_dag_refresh(dag_id)
dagrun = run_in_executor(__run_dag, dag_id)
if wait_for_completion:
while True:
Expand Down
Loading