2020 get_validation_status_from_minio ,
2121 get_minio_client ,
2222 find_rocrate_object_on_minio ,
23- find_validation_object_on_minio
23+ find_validation_object_on_minio ,
2424)
2525from app .utils .webhook_utils import send_webhook_notification
2626
2929
3030@celery .task
3131def process_validation_task_by_id (
32- minio_config : dict , crate_id : str , root_path : str , profile_name : str | None ,
33- webhook_url : str | None , profiles_path : str | None
32+ minio_config : dict ,
33+ crate_id : str ,
34+ root_path : str ,
35+ profile_name : str | None ,
36+ webhook_url : str | None ,
37+ profiles_path : str | None ,
3438) -> None :
3539 """
3640 Background task to process the RO-Crate validation by ID.
@@ -52,12 +56,16 @@ def process_validation_task_by_id(
5256
5357 try :
5458 # Fetch the RO-Crate from MinIO using the provided ID:
55- file_path = fetch_ro_crate_from_minio (minio_client , minio_config ["bucket" ], crate_id , root_path )
59+ file_path = fetch_ro_crate_from_minio (
60+ minio_client , minio_config ["bucket" ], crate_id , root_path
61+ )
5662
5763 logging .info (f"Processing validation task for { file_path } " )
5864
5965 # Perform validation:
60- validation_result = perform_ro_crate_validation (file_path , profile_name , profiles_path = profiles_path )
66+ validation_result = perform_ro_crate_validation (
67+ file_path , profile_name , profiles_path = profiles_path
68+ )
6169
6270 if isinstance (validation_result , str ):
6371 logging .error (f"Validation failed: { validation_result } " )
@@ -70,7 +78,13 @@ def process_validation_task_by_id(
7078 logging .info (f"RO Crate { crate_id } is invalid." )
7179
7280 # Update the validation status in MinIO:
73- update_validation_status_in_minio (minio_client , minio_config ["bucket" ], crate_id , root_path , validation_result .to_json ())
81+ update_validation_status_in_minio (
82+ minio_client ,
83+ minio_config ["bucket" ],
84+ crate_id ,
85+ root_path ,
86+ validation_result .to_json (),
87+ )
7488
7589 # TODO: Prepare the data to send to the webhook, and send the webhook notification.
7690
@@ -98,7 +112,10 @@ def process_validation_task_by_id(
98112
99113@celery .task
100114def process_validation_task_by_metadata (
101- crate_json : str , profile_name : str | None , webhook_url : str | None , profiles_path : Optional [str ] = None
115+ crate_json : str ,
116+ profile_name : str | None ,
117+ webhook_url : str | None ,
118+ profiles_path : Optional [str ] = None ,
102119) -> ValidationResult | str :
103120 """
104121 Background task to process the RO-Crate validation for a given json metadata string.
@@ -116,10 +133,9 @@ def process_validation_task_by_metadata(
116133 logging .info ("Processing validation task for provided metadata string" )
117134
118135 # Perform validation:
119- validation_result = perform_metadata_validation (crate_json ,
120- profile_name ,
121- profiles_path
122- )
136+ validation_result = perform_metadata_validation (
137+ crate_json , profile_name , profiles_path = profiles_path
138+ )
123139
124140 if isinstance (validation_result , str ):
125141 logging .error (f"Validation failed: { validation_result } " )
@@ -150,7 +166,10 @@ def process_validation_task_by_metadata(
150166
151167
152168def perform_ro_crate_validation (
153- file_path : str , profile_name : str | None , skip_checks_list : Optional [list ] = None , profiles_path : Optional [str ] = None
169+ file_path : str ,
170+ profile_name : str | None ,
171+ skip_checks_list : Optional [list ] = None ,
172+ profiles_path : Optional [str ] = None ,
154173) -> ValidationResult | str :
155174 """
156175 Validates an RO-Crate using the provided file path and profile name.
@@ -177,7 +196,7 @@ def perform_ro_crate_validation(
177196 rocrate_uri = full_file_path ,
178197 ** ({"profile_identifier" : profile_name } if profile_name else {}),
179198 ** ({"skip_checks" : skip_checks_list } if skip_checks_list else {}),
180- ** ({"profiles_path" : profiles_path } if profiles_path else {})
199+ ** ({"profiles_path" : profiles_path } if profiles_path else {}),
181200 )
182201
183202 return services .validate (settings )
@@ -188,7 +207,10 @@ def perform_ro_crate_validation(
188207
189208
190209def perform_metadata_validation (
191- crate_json : str , profile_name : str | None , skip_checks_list : Optional [list ] = None , profiles_path : Optional [str ] = None
210+ crate_json : str ,
211+ profile_name : str | None ,
212+ skip_checks_list : Optional [list ] = None ,
213+ profiles_path : Optional [str ] = None ,
192214) -> ValidationResult | str :
193215 """
194216 Validates only RO-Crate metadata provided as a json string.
@@ -210,7 +232,7 @@ def perform_metadata_validation(
210232 ** ({"metadata_dict" : json .loads (crate_json )}),
211233 ** ({"profile_identifier" : profile_name } if profile_name else {}),
212234 ** ({"skip_checks" : skip_checks_list } if skip_checks_list else {}),
213- ** ({"profiles_path" : profiles_path } if profiles_path else {})
235+ ** ({"profiles_path" : profiles_path } if profiles_path else {}),
214236 )
215237
216238 return services .validate (settings )
@@ -221,10 +243,10 @@ def perform_metadata_validation(
221243
222244
223245def check_ro_crate_exists (
224- minio_client : object ,
225- bucket_name : str ,
226- crate_id : str ,
227- root_path : str ,
246+ minio_client : object ,
247+ bucket_name : str ,
248+ crate_id : str ,
249+ root_path : str ,
228250) -> bool :
229251 """
230252 Checks for the existence of an RO-Crate using the provided Crate ID.
@@ -245,10 +267,10 @@ def check_ro_crate_exists(
245267
246268
247269def check_validation_exists (
248- minio_client : object ,
249- bucket_name : str ,
250- crate_id : str ,
251- root_path : str ,
270+ minio_client : object ,
271+ bucket_name : str ,
272+ crate_id : str ,
273+ root_path : str ,
252274) -> bool :
253275 """
254276 Checks for the existence of a validation result using the provided Crate ID.
@@ -269,10 +291,10 @@ def check_validation_exists(
269291
270292
271293def return_ro_crate_validation (
272- minio_client : object ,
273- bucket_name : str ,
274- crate_id : str ,
275- root_path : str ,
294+ minio_client : object ,
295+ bucket_name : str ,
296+ crate_id : str ,
297+ root_path : str ,
276298) -> dict | str :
277299 """
278300 Retrieves the validation result for an RO-Crate using the provided Crate ID.
@@ -284,4 +306,6 @@ def return_ro_crate_validation(
284306
285307 logging .info (f"Fetching validation result for RO-Crate { crate_id } " )
286308
287- return get_validation_status_from_minio (minio_client , bucket_name , crate_id , root_path )
309+ return get_validation_status_from_minio (
310+ minio_client , bucket_name , crate_id , root_path
311+ )
0 commit comments