Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
restart actions: added test for airflow utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Jul 29, 2024
1 parent 80e05d3 commit 1d03468
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 1,043 deletions.
13 changes: 6 additions & 7 deletions backoffice/backoffice/workflows/airflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os import environ

import requests
from django.http import JsonResponse
from django.http import HttpResponse, JsonResponse
from requests.exceptions import RequestException
from rest_framework import status

Expand Down Expand Up @@ -57,7 +57,6 @@ def restart_failed_tasks(workflow):
"""

dag_id = find_failed_dag(workflow)

# assumes current task is one of the failed tasks
data = {
"dry_run": False,
Expand Down Expand Up @@ -94,7 +93,7 @@ def find_executed_dags(workflow):
headers=AIRFLOW_HEADERS,
)
if response.status_code == status.HTTP_200_OK:
executed_dags_for_workflow[dag_id] = response.content
executed_dags_for_workflow[dag_id] = response.json()

return executed_dags_for_workflow

Expand All @@ -109,7 +108,7 @@ def find_failed_dag(workflow):
executed_dags_for_workflow = find_executed_dags(workflow)

for dag, dag_data in executed_dags_for_workflow.items():
if dag_data["status"] == "failed":
if dag_data["state"] == "failed":
return dag


Expand All @@ -125,12 +124,12 @@ def delete_workflow_dag(dag_id, workflow):
headers=AIRFLOW_HEADERS,
)
response.raise_for_status()
return HttpResponse()
except RequestException:
data = {"error": response.json()}
return JsonResponse(data, status=status.HTTP_424_FAILED_DEPENDENCY)
return HttpResponse(status=status.HTTP_424_FAILED_DEPENDENCY)


def restart_workflow_dags(workflow, params):
def restart_workflow_dags(workflow, params=None):
"""Restarts dags of a given workflow.
:param workflow: workflow whoose dags should be restarted
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1d03468

Please sign in to comment.