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

Commit

Permalink
user actions: fix approve and restart
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 8, 2024
1 parent ee49892 commit ff1d918
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions backoffice/backoffice/workflows/airflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ def restart_failed_tasks(workflow_id, workflow_type):
:param workflow_type: type of workflow to retrieve
:returns: request response
"""

dag_id = find_failed_dag(workflow_id, workflow_type)
print("workflow is is")
print(str(workflow_id))
dag_id = find_failed_dag(str(workflow_id), workflow_type)
if dag_id is None:
return JsonResponse({"message": "There are no failing tasks, skipping restart"})

print("dag_id is")
print(dag_id)
# assumes current task is one of the failed tasks
data = {
"dry_run": False,
"dag_run_id": str(workflow_id),
"reset_dag_runs": False,
"reset_dag_runs": True,
"only_failed": True,
}

Expand Down
4 changes: 3 additions & 1 deletion backoffice/backoffice/workflows/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def restart(self, request, pk=None):
workflow = Workflow.objects.get(id=pk)

if request.data.get("restart_current_task"):
return airflow_utils.restart_failed_tasks(workflow)
return airflow_utils.restart_failed_tasks(
workflow.id, workflow.workflow_type
)

return airflow_utils.restart_workflow_dags(
workflow.id, workflow.workflow_type, request.data.get("params")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def create_author_on_inspire(**context: dict) -> str:
workflow_management_hook.partial_update_workflow(
workflow_id=context["params"]["workflow_id"],
workflow_partial_update_data={"data": workflow_data["data"]},
collection=AUTHORS,
)
return status

Expand Down

0 comments on commit ff1d918

Please sign in to comment.