Skip to content

Commit

Permalink
workflows: fix author submissions not erroring
Browse files Browse the repository at this point in the history
also some small config fixes for easy testing with docker

* ref: cern-sis/issues-inspire#643
  • Loading branch information
DonHaul committed Dec 18, 2024
1 parent 3942899 commit 798f4bb
Show file tree
Hide file tree
Showing 9 changed files with 1,190 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ run: services start-inspirehep sleep setup-inspirehep start-backoffice sleep set
run-inspirehep: services start-inspirehep sleep setup-inspirehep
run-backoffice: services start-backoffice sleep setup-backoffice

start: services start-inspirehep start-backoffice

start-inspirehep:
echo -e "\033[0;32m Starting HEP. \033[0m"
Expand Down
6 changes: 3 additions & 3 deletions backend/inspirehep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
FEATURE_FLAG_ENABLE_ORCID_PUSH = False
FEATURE_FLAG_ENABLE_REDIRECTION_OF_PIDS = False
FEATURE_FLAG_ENABLE_ASSIGN_AUTHOR_PAPERS = False
FEATURE_FLAG_ENABLE_SEND_TO_BACKOFFICE = False
FEATURE_FLAG_ENABLE_SEND_TO_BACKOFFICE = True
# Only push to ORCIDs that match this regex.
# Examples:
# any ORCID -> ".*"
Expand All @@ -51,8 +51,8 @@
INSPIRE_NEXT_URL = "http://localhost:5000"
LEGACY_BASE_URL = "https://old.inspirehep.net"
LEGACY_RECORD_URL_PATTERN = "http://inspirehep.net/record/{recid}"
INSPIRE_BACKOFFICE_URL = "https://backoffice.dev.inspirebeta.net"
AUTHENTICATION_TOKEN_BACKOFFICE = "CHANGE_ME"
INSPIRE_BACKOFFICE_URL = "http://host.docker.internal:8001"
AUTHENTICATION_TOKEN_BACKOFFICE = "2e04111a61e8f5ba6ecec52af21bbb9e81732085"
MAX_API_RESULTS = 10000
REST_MIMETYPE_QUERY_ARG_NAME = "format"

Expand Down
3 changes: 2 additions & 1 deletion workflows/dags/author/author_create/author_create_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
params={
"workflow_id": Param(type="string", default=""),
"data": Param(type="object", default={}),
"collection": Param(type="string", default=AUTHORS),
},
start_date=datetime.datetime(2024, 5, 5),
schedule=None,
catchup=False,
# TODO: what if callback fails? Data in backoffice not up to date!
on_failure_callback=set_workflow_status_to_error,
tags=["authors"],
tags=[AUTHORS],
)
def author_create_initialization_dag():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_workflow(self, workflow_id: str, workflow_data: dict) -> Response:
return self.run_with_advanced_retry(
_retry_args=self.tenacity_retry_kwargs,
method="PUT",
data=workflow_data,
json=workflow_data,
endpoint=endpoint,
)

Expand All @@ -61,6 +61,6 @@ def partial_update_workflow(
return self.run_with_advanced_retry(
_retry_args=self.tenacity_retry_kwargs,
method="PATCH",
data=workflow_partial_update_data,
json=workflow_partial_update_data,
endpoint=endpoint,
)
10 changes: 5 additions & 5 deletions workflows/plugins/include/utils/set_workflow_status.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from hooks.backoffice.workflow_management_hook import AUTHORS, WorkflowManagementHook
from hooks.backoffice.workflow_management_hook import WorkflowManagementHook
from requests import Response

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -36,10 +36,10 @@ def set_workflow_status_to_error(context: dict) -> None:
workflow_id (str): The identifier for the workflow.
"""
logger.info("Setting workflow status to error")
response = WorkflowManagementHook().set_workflow_status(
status_name="error",
workflow_id=context["params"]["workflow_id"],
collection=AUTHORS,
response = WorkflowManagementHook(
collection=context["params"]["collection"]
).set_workflow_status(
status_name="error", workflow_id=context["params"]["workflow_id"]
)
try:
response.raise_for_status()
Expand Down
Loading

0 comments on commit 798f4bb

Please sign in to comment.