This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
submissions: authors initial implementation Co-authored-by: DonHaul <[email protected]>
- Loading branch information
Showing
14 changed files
with
245 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from os import environ | ||
|
||
import requests | ||
from django.http import JsonResponse | ||
from requests.exceptions import RequestException | ||
from rest_framework import status | ||
|
||
AIRFLOW_BASE_URL = environ.get("AIRFLOW_BASE_URL") | ||
|
||
AIRFLOW_HEADERS = {"Content-Type": "application/json", "Authorization": f"Basic {environ.get('AIRFLOW_TOKEN')}"} | ||
|
||
|
||
def trigger_airflow_dag(dag_id, workflow_id, extra_data=None): | ||
"""Triggers an airflow dag. | ||
:param dag_id: name of the dag to run | ||
:param workflow_id: id of the workflow being triggered | ||
:returns: request response | ||
""" | ||
|
||
data = {"dag_run_id": workflow_id, "conf": {"workflow_id": workflow_id}} | ||
|
||
if extra_data is not None: | ||
data["conf"].update(extra_data) | ||
|
||
url = f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns" | ||
|
||
try: | ||
response = requests.post(url, json=data, headers=AIRFLOW_HEADERS) | ||
response.raise_for_status() | ||
return JsonResponse(response.json()) | ||
except RequestException as req_err: | ||
data = {"error": req_err} | ||
return JsonResponse(data, status=status.HTTP_500_INTERNAL_SERVER_ERROR) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
backoffice/workflows/migrations/0008_alter_workflow_status_alter_workflow_workflow_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 4.2.6 on 2024-07-09 12:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("workflows", "0007_alter_workflow_core_alter_workflow_is_update"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="workflow", | ||
name="status", | ||
field=models.CharField( | ||
choices=[ | ||
("running", "Running"), | ||
("approval", "Waiting for approva"), | ||
("completed", "Completed"), | ||
("error", "Error"), | ||
], | ||
default="running", | ||
max_length=30, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="workflow", | ||
name="workflow_type", | ||
field=models.CharField( | ||
choices=[ | ||
("HEP_CREATE", "HEP create"), | ||
("HEP_UPDATE", "HEP update"), | ||
("AUTHOR_CREATE", "Author create"), | ||
("AUTHOR_UPDATE", "Author update"), | ||
], | ||
default="HEP_CREATE", | ||
max_length=30, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.