From 6ed6b9721cb1f881e08585a54c6413fd234b01a8 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Fri, 9 Aug 2024 14:07:23 +0200 Subject: [PATCH] set-schema: fix * ref: cern-sis/issues-inspire/issues/525 --- backoffice/backoffice/workflows/airflow_utils.py | 2 +- workflows/dags/author/author_create/author_create_init.py | 7 +++++-- workflows/scripts/variables/variables.json | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backoffice/backoffice/workflows/airflow_utils.py b/backoffice/backoffice/workflows/airflow_utils.py index 5806a5e5..8ebe9ab8 100644 --- a/backoffice/backoffice/workflows/airflow_utils.py +++ b/backoffice/backoffice/workflows/airflow_utils.py @@ -29,7 +29,7 @@ def trigger_airflow_dag(dag_id, workflow_id, extra_data=None): data = {"dag_run_id": str(workflow_id), "conf": {"workflow_id": str(workflow_id)}} if extra_data is not None: - data["conf"].update(extra_data) + data["conf"]["data"] = extra_data url = f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns" diff --git a/workflows/dags/author/author_create/author_create_init.py b/workflows/dags/author/author_create/author_create_init.py index 9fbfb207..18982b03 100644 --- a/workflows/dags/author/author_create/author_create_init.py +++ b/workflows/dags/author/author_create/author_create_init.py @@ -2,6 +2,7 @@ import logging from airflow.decorators import dag, task +from airflow.models import Variable from airflow.models.param import Param from hooks.backoffice.workflow_management_hook import AUTHORS, WorkflowManagementHook from hooks.backoffice.workflow_ticket_management_hook import ( @@ -50,10 +51,12 @@ def set_workflow_status_to_running(**context): @task() def set_schema(**context): - schema = "https://inspirehep.net/schemas/records/authors.json" + schema = Variable.get("author_schema") workflow_management_hook.partial_update_workflow( workflow_id=context["params"]["workflow_id"], - workflow_partial_update_data={"data": {"$schema": schema}}, + workflow_partial_update_data={ + "data": {**context["params"]["data"], "$schema": schema} + }, collection=AUTHORS, ) diff --git a/workflows/scripts/variables/variables.json b/workflows/scripts/variables/variables.json index 95ce3561..1e3d9ea5 100644 --- a/workflows/scripts/variables/variables.json +++ b/workflows/scripts/variables/variables.json @@ -1,4 +1,5 @@ { "backoffice_token": "2e04111a61e8f5ba6ecec52af21bbb9e81732085", - "inspire_token": "CHANGE_ME" + "inspire_token": "CHANGE_ME", + "author_schema": "https://inspirehep.net/schemas/records/authors.json" }