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

Commit

Permalink
user actions: review cassettes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Jul 30, 2024
1 parent 3a4ce92 commit e45de6c
Show file tree
Hide file tree
Showing 15 changed files with 443 additions and 225 deletions.
17 changes: 8 additions & 9 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 HttpResponse, JsonResponse
from django.http import JsonResponse
from requests.exceptions import RequestException
from rest_framework import status

Expand Down Expand Up @@ -35,10 +35,9 @@ def trigger_airflow_dag(dag_id, workflow_id, extra_data=None):

try:
logger.info(
"Triggering DAG %s with data: %s and %s %s",
"Triggering DAG %s with data: %s and %s",
dag_id,
data,
AIRFLOW_HEADERS,
url,
)
response = requests.post(url, json=data, headers=AIRFLOW_HEADERS)
Expand Down Expand Up @@ -69,10 +68,9 @@ def restart_failed_tasks(workflow_id, workflow_type):

try:
logger.info(
"Clearing Failed Tasks of DAG %s with data: %s and %s %s",
"Clearing Failed Tasks of DAG %s with data: %s and %s",
dag_id,
data,
AIRFLOW_HEADERS,
url,
)
response = requests.post(
Expand Down Expand Up @@ -132,19 +130,20 @@ def delete_workflow_dag(dag_id, workflow_id):
url = f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns/{str(workflow_id)}"
try:
logger.info(
"Deketing dag Failed Tasks of DAG %s with no data and %s %s",
"Deleting dag Failed Tasks of DAG %s with no data and %s",
dag_id,
AIRFLOW_HEADERS,
url,
)
response = requests.delete(
url,
headers=AIRFLOW_HEADERS,
)
response.raise_for_status()
return HttpResponse()
return JsonResponse({"message": "Successfully deleted DAG"})
except RequestException:
return HttpResponse(status=status.HTTP_424_FAILED_DEPENDENCY)
return JsonResponse(
{"error": "Failed to delete DAG"}, status=status.HTTP_424_FAILED_DEPENDENCY
)


def restart_workflow_dags(workflow_id, workflow_type, params=None):
Expand Down
1 change: 1 addition & 0 deletions backoffice/backoffice/workflows/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def resolve(self, request, pk=None):
ResolutionDags[serializer.validated_data["value"]],
pk,
)

return airflow_utils.trigger_airflow_dag(
ResolutionDags[serializer.validated_data["value"]].label, pk, extra_data
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.362977+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:29:54.362977+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T08:29:54.362977+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.362977+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:13:41.736880+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:13:41.736880+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T12:13:41.736880+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:13:41.736880+00:00\",\n
\ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n
\ \"state\": \"queued\"\n}\n"
headers:
Expand All @@ -33,7 +33,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:41 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -65,7 +65,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:41 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -101,7 +101,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:41 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.646527+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:29:54.646527+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T08:29:54.646527+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.646527+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:13:42.009672+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:13:42.009672+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T12:13:42.009672+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:13:42.009672+00:00\",\n
\ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n
\ \"state\": \"queued\"\n}\n"
headers:
Expand All @@ -33,7 +33,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand All @@ -58,10 +58,10 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.646527+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:29:54.646527+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T08:29:54.646527+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.646527+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:13:42.009672+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:13:42.009672+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T12:13:42.009672+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:13:42.009672+00:00\",\n
\ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n
\ \"state\": \"queued\"\n}\n"
headers:
Expand All @@ -72,7 +72,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -106,7 +106,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -140,7 +140,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -172,7 +172,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:54 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:55.039650+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:29:55.039650+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T08:29:55.039650+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:55.039650+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:13:42.394528+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:13:42.394528+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T12:13:42.394528+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:13:42.394528+00:00\",\n
\ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n
\ \"state\": \"queued\"\n}\n"
headers:
Expand All @@ -33,7 +33,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:29:55 GMT
- Tue, 30 Jul 2024 12:13:42 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand All @@ -58,12 +58,12 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:55.039650+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:29:55.039650+00:00\",\n \"end_date\":
\"2024-07-30T08:30:12.831165+00:00\",\n \"execution_date\": \"2024-07-30T08:29:55.039650+00:00\",\n
\ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T08:30:12.828982+00:00\",\n
\ \"logical_date\": \"2024-07-30T08:29:55.039650+00:00\",\n \"note\": null,\n
\ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T08:29:55.206573+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:13:42.394528+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:13:42.394528+00:00\",\n \"end_date\":
\"2024-07-30T12:14:01.291731+00:00\",\n \"execution_date\": \"2024-07-30T12:13:42.394528+00:00\",\n
\ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T12:14:01.290717+00:00\",\n
\ \"logical_date\": \"2024-07-30T12:13:42.394528+00:00\",\n \"note\": null,\n
\ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T12:13:43.261644+00:00\",\n
\ \"state\": \"failed\"\n}\n"
headers:
Connection:
Expand All @@ -73,7 +73,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:15 GMT
- Tue, 30 Jul 2024 12:14:02 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -107,7 +107,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:30:15 GMT
- Tue, 30 Jul 2024 12:14:02 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -141,7 +141,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:30:15 GMT
- Tue, 30 Jul 2024 12:14:02 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -173,7 +173,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:15 GMT
- Tue, 30 Jul 2024 12:14:02 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:15.450284+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:30:15.450284+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:15.450284+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:14:02.777854+00:00\",\n \"end_date\":
null,\n \"execution_date\": \"2024-07-30T12:14:02.777854+00:00\",\n \"external_trigger\":
true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n
\ \"state\": \"queued\"\n}\n"
headers:
Expand All @@ -33,7 +33,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:15 GMT
- Tue, 30 Jul 2024 12:14:02 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand All @@ -58,12 +58,12 @@ interactions:
body:
string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n
\ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:15.450284+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T08:30:15.450284+00:00\",\n \"end_date\":
\"2024-07-30T08:30:33.523185+00:00\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n
\ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T08:30:33.521865+00:00\",\n
\ \"logical_date\": \"2024-07-30T08:30:15.450284+00:00\",\n \"note\": null,\n
\ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T08:30:15.499846+00:00\",\n
\"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"data_interval_start\": \"2024-07-30T12:14:02.777854+00:00\",\n \"end_date\":
\"2024-07-30T12:14:20.320392+00:00\",\n \"execution_date\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T12:14:20.318638+00:00\",\n
\ \"logical_date\": \"2024-07-30T12:14:02.777854+00:00\",\n \"note\": null,\n
\ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T12:14:03.400650+00:00\",\n
\ \"state\": \"failed\"\n}\n"
headers:
Connection:
Expand All @@ -73,7 +73,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:35 GMT
- Tue, 30 Jul 2024 12:14:22 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -107,7 +107,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:30:35 GMT
- Tue, 30 Jul 2024 12:14:22 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -141,7 +141,7 @@ interactions:
Content-Type:
- application/problem+json
Date:
- Tue, 30 Jul 2024 08:30:35 GMT
- Tue, 30 Jul 2024 12:14:22 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -169,16 +169,16 @@ interactions:
body:
string: "{\n \"task_instances\": [\n {\n \"dag_id\": \"author_create_initialization_dag\",\n
\ \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\":
\"2024-07-30T08:30:15.450284+00:00\",\n \"task_id\": \"set_workflow_status_to_running\"\n
\"2024-07-30T12:14:02.777854+00:00\",\n \"task_id\": \"create_author_create_user_ticket\"\n
\ },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n
\ \"task_id\": \"set_schema\"\n },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n
\ \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\":
\"2024-07-30T08:30:15.450284+00:00\",\n \"task_id\": \"create_author_create_user_ticket\"\n
\ },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n
\ \"task_id\": \"set_author_create_workflow_status_to_approval\"\n }\n
\ ]\n}\n"
\"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"task_id\": \"set_author_create_workflow_status_to_approval\"\n },\n
\ {\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\":
\"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T12:14:02.777854+00:00\",\n
\ \"task_id\": \"set_workflow_status_to_running\"\n },\n {\n \"dag_id\":
\"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n
\ \"execution_date\": \"2024-07-30T12:14:02.777854+00:00\",\n \"task_id\":
\"set_schema\"\n }\n ]\n}\n"
headers:
Connection:
- close
Expand All @@ -187,7 +187,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:35 GMT
- Tue, 30 Jul 2024 12:14:23 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down Expand Up @@ -219,7 +219,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 30 Jul 2024 08:30:35 GMT
- Tue, 30 Jul 2024 12:14:23 GMT
Server:
- gunicorn
X-Robots-Tag:
Expand Down
Loading

0 comments on commit e45de6c

Please sign in to comment.