Skip to content

Commit e2a030a

Browse files
committed
provide route for passing profiles_path to rocrate validator call
1 parent afa0354 commit e2a030a

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/ro_crates/routes/post_routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apiflask import APIBlueprint, Schema
88
from apiflask.fields import String, Boolean
99
from marshmallow.fields import Nested
10-
from flask import Response
10+
from flask import Response, current_app
1111

1212
from app.services.validation_service import (
1313
queue_ro_crate_validation_task,
@@ -81,7 +81,10 @@ def validate_ro_crate_via_id(json_data, crate_id) -> tuple[Response, int]:
8181
else:
8282
profile_name = None
8383

84-
return queue_ro_crate_validation_task(minio_config, crate_id, root_path, profile_name, webhook_url)
84+
profiles_path = current_app.config["PROFILES_PATH"]
85+
86+
return queue_ro_crate_validation_task(minio_config, crate_id, root_path, profile_name,
87+
webhook_url, profiles_path)
8588

8689

8790
@post_routes_bp.post("/validate_metadata")

app/services/validation_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626

2727
def queue_ro_crate_validation_task(
28-
minio_config, crate_id, root_path=None, profile_name=None, webhook_url=None
28+
minio_config, crate_id, root_path=None, profile_name=None, webhook_url=None,
29+
profiles_path=None
2930
) -> tuple[Response, int]:
3031
"""
3132
Queues an RO-Crate for validation with Celery.
@@ -51,7 +52,8 @@ def queue_ro_crate_validation_task(
5152
raise InvalidAPIUsage(f"No RO-Crate with prefix: {crate_id}", 400)
5253

5354
try:
54-
process_validation_task_by_id.delay(minio_config, crate_id, root_path, profile_name, webhook_url)
55+
process_validation_task_by_id.delay(minio_config, crate_id, root_path,
56+
profile_name, webhook_url, profiles_path)
5557
return jsonify({"message": "Validation in progress"}), 202
5658

5759
except Exception as e:

app/tasks/validation_tasks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
@celery.task
3131
def process_validation_task_by_id(
32-
minio_config: dict, crate_id: str, root_path: str, profile_name: str | None, webhook_url: str | None
32+
minio_config: dict, crate_id: str, root_path: str, profile_name: str | None,
33+
webhook_url: str | None, profiles_path: str | None
3334
) -> None:
3435
"""
3536
Background task to process the RO-Crate validation by ID.
@@ -56,7 +57,7 @@ def process_validation_task_by_id(
5657
logging.info(f"Processing validation task for {file_path}")
5758

5859
# Perform validation:
59-
validation_result = perform_ro_crate_validation(file_path, profile_name)
60+
validation_result = perform_ro_crate_validation(file_path, profile_name, profiles_path=profiles_path)
6061

6162
if isinstance(validation_result, str):
6263
logging.error(f"Validation failed: {validation_result}")

0 commit comments

Comments
 (0)