From b1c27dc09e62edbe175f4819a7702602b8bc7965 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Fri, 9 Aug 2024 10:37:23 +0200 Subject: [PATCH] author update: airflow dag fixes * ref: cern-sis/issues-inspire/issues/517 --- backoffice/backoffice/workflows/api/views.py | 4 ++-- workflows/dags/author/author_update/author_update.py | 6 +++--- .../hooks/inspirehep/inspire_http_record_management_hook.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index ca78ae8e..3da7ab6e 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -104,8 +104,8 @@ class AuthorWorkflowViewSet(viewsets.ViewSet): serializer_class = WorkflowAuthorSerializer @extend_schema( - summary="Create a New Author", - description="Creates a new author, launches the required airflow dags.", + summary="Create/Update an Author", + description="Creates/Updates an author, launches the required airflow dags.", request=serializer_class, ) def create(self, request): diff --git a/workflows/dags/author/author_update/author_update.py b/workflows/dags/author/author_update/author_update.py index 9776ce31..0e319a9a 100644 --- a/workflows/dags/author/author_update/author_update.py +++ b/workflows/dags/author/author_update/author_update.py @@ -53,7 +53,7 @@ def set_author_update_workflow_status_to_running(**context): @task() def create_ticket_on_author_update(**context): - endpoint = "/tickets/create-with-template" + endpoint = "/api/tickets/create" request_data = { "functional_category": "Author updates", "template": "curator_update_author", @@ -80,9 +80,9 @@ def update_author_on_inspire(**context): record_data = inspire_http_record_management_hook.get_record( pid_type="authors", control_number=control_number ) - updated_record_data = record_data["metadata"].update(workflow_data["data"]) + record_data["metadata"].update(workflow_data["data"]) response = inspire_http_record_management_hook.update_record( - data=updated_record_data, + data=record_data["metadata"], pid_type="authors", control_number=control_number, revision_id=record_data["revision_id"] + 1, diff --git a/workflows/plugins/hooks/inspirehep/inspire_http_record_management_hook.py b/workflows/plugins/hooks/inspirehep/inspire_http_record_management_hook.py index 4cd57ba3..d8b2b7d8 100644 --- a/workflows/plugins/hooks/inspirehep/inspire_http_record_management_hook.py +++ b/workflows/plugins/hooks/inspirehep/inspire_http_record_management_hook.py @@ -15,7 +15,7 @@ def update_record( method="PUT", headers=update_headers, json=data, - endpoint=f"{pid_type}/{control_number}", + endpoint=f"/api/{pid_type}/{control_number}", ) def get_record(self, pid_type: str, control_number: int) -> Response: @@ -23,7 +23,7 @@ def get_record(self, pid_type: str, control_number: int) -> Response: _retry_args=self.tenacity_retry_kwargs, method="GET", headers=self.headers, - endpoint=f"/{pid_type}/{control_number}", + endpoint=f"/api/{pid_type}/{control_number}", ) return response.json() @@ -32,7 +32,7 @@ def get_record_revision_id(self, pid_type: str, control_number: int) -> int: _retry_args=self.tenacity_retry_kwargs, method="GET", headers=self.headers, - endpoint=f"/{pid_type}/{control_number}", + endpoint=f"/api/{pid_type}/{control_number}", ) response.raise_for_status() return response.json()["revision_id"]