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

Commit

Permalink
author consolidation: renamed typ to colleciton
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 5, 2024
1 parent 56fd71c commit a7c1dcd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ x-airflow-common: &airflow-common
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: "true"
AIRFLOW__CORE__LOAD_EXAMPLES: "false"
AIRFLOW__API__AUTH_BACKENDS: "airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session"
# AIRFLOW__WEBSERVER__RELOAD_ON_PLUGIN_CHANGE: "true" # used when modifying plugins
AIRFLOW__WEBSERVER__RELOAD_ON_PLUGIN_CHANGE: "true" # used when modifying plugins
# yamllint disable rule:line-length
# Use simple http server on scheduler for health checks
# See https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/check-health.html#scheduler-health-check-server
Expand Down
6 changes: 3 additions & 3 deletions workflows/dags/author/author_create/author_create_approved.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_workflow_status_to_running(**context):
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

@task.branch()
Expand Down Expand Up @@ -134,7 +134,7 @@ def set_author_create_workflow_status_to_completed(**context: dict) -> None:
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

@task
Expand All @@ -150,7 +150,7 @@ def set_author_create_workflow_status_to_error(**context: dict) -> None:
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

# task definitions
Expand Down
6 changes: 3 additions & 3 deletions workflows/dags/author/author_create/author_create_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_workflow_status_to_running(**context):
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

@task()
Expand All @@ -54,7 +54,7 @@ def set_schema(**context):
workflow_management_hook.partial_update_workflow(
workflow_id=context["params"]["workflow_id"],
workflow_partial_update_data={"data": {"$schema": schema}},
typ=AUTHORS,
collection=AUTHORS,
)

@task()
Expand Down Expand Up @@ -85,7 +85,7 @@ def set_author_create_workflow_status_to_approval(**context: dict) -> None:
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

# task dependencies
Expand Down
6 changes: 3 additions & 3 deletions workflows/dags/author/author_update/author_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def set_author_update_workflow_status_to_running(**context):
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

@task()
Expand Down Expand Up @@ -96,7 +96,7 @@ def set_author_update_workflow_status_to_completed(**context):
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

@task.branch(provide_context=True)
Expand All @@ -116,7 +116,7 @@ def set_author_update_workflow_status_to_error(**context):
workflow_management_hook.set_workflow_status(
status_name=status_name,
workflow_id=context["params"]["workflow_id"],
typ=AUTHORS,
collection=AUTHORS,
)

# task definitions
Expand Down
10 changes: 6 additions & 4 deletions workflows/plugins/hooks/backoffice/workflow_management_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class WorkflowManagementHook(BackofficeHook):
"""

def set_workflow_status(
self, status_name: str, workflow_id: str, typ: str
self, status_name: str, workflow_id: str, collection: str
) -> Response:
"""
Updates the status of a workflow in the backoffice system.
Expand All @@ -32,7 +32,9 @@ def set_workflow_status(
"status": status_name,
}
return self.partial_update_workflow(
workflow_partial_update_data=request_data, workflow_id=workflow_id, typ=typ
workflow_partial_update_data=request_data,
workflow_id=workflow_id,
collection=collection,
)

def get_workflow(self, workflow_id: str) -> dict:
Expand All @@ -53,9 +55,9 @@ def update_workflow(self, workflow_id: str, workflow_data: dict) -> Response:
)

def partial_update_workflow(
self, workflow_id: str, workflow_partial_update_data: dict, typ: str
self, workflow_id: str, workflow_partial_update_data: dict, collection: str
) -> Response:
endpoint = f"api/workflows/{typ}/{workflow_id}/"
endpoint = f"api/workflows/{collection}/{workflow_id}/"
return self.run_with_advanced_retry(
_retry_args=self.tenacity_retry_kwargs,
method="PATCH",
Expand Down
4 changes: 3 additions & 1 deletion workflows/plugins/include/utils/set_workflow_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def set_workflow_status_to_error(context: dict) -> None:
"""
logger.info("Setting workflow status to error")
response = WorkflowManagementHook().set_workflow_status(
status_name="error", workflow_id=context["params"]["workflow_id"], typ=AUTHORS
status_name="error",
workflow_id=context["params"]["workflow_id"],
collection=AUTHORS,
)
try:
response.raise_for_status()
Expand Down

0 comments on commit a7c1dcd

Please sign in to comment.