From 384078bb700157939d6d633ec7cd795cc51495d4 Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Fri, 15 Dec 2023 10:25:04 -0500 Subject: [PATCH 1/2] Prepare for subtype update --- src/routes/validation/validation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/validation/validation.py b/src/routes/validation/validation.py index 79a8be31..65cbd030 100644 --- a/src/routes/validation/validation.py +++ b/src/routes/validation/validation.py @@ -112,7 +112,7 @@ def validate_tsv(schema='metadata', path=None): 'entities_url': f"{commons_file_helper.ensureTrailingSlashURL(current_app.config['ENTITY_WEBSERVICE_URL'])}entities/" } result = iv_utils.get_tsv_errors(path, schema_name=schema_name, report_type=table_validator.ReportType.JSON, - cedar_api_key=current_app.config['CEDAR_API_KEY'], globus_token=get_groups_token(), app_context=app_context) + globus_token=get_groups_token(), app_context=app_context) except Exception as e: result = rest_server_err(e, True) return json.dumps(result) @@ -164,8 +164,9 @@ def check_cedar(entity_type, sub_type, upload): records = get_metadata(upload.get('fullpath')) if len(records) > 0: if equals(entity_type, Ontology.ops().entities().SAMPLE) and 'metadata_schema_id' in records[0]: - cedar_sample_sub_type_ids = get_cedar_schema_ids() - return equals(records[0]['metadata_schema_id'], cedar_sample_sub_type_ids[sub_type]) + # TODO: check type of value schema for subtype + schema = iv_utils.get_schema_version(upload.get('fullpath'), encoding='ascii', globus_token=get_groups_token()) + return equals(schema, f"{entity_type}-{sub_type}") return True def determine_schema(entity_type, sub_type): From 73186b230cef26a5747b5a15f3efcdc51da32f90 Mon Sep 17 00:00:00 2001 From: Lisa-Ann B Date: Mon, 18 Dec 2023 11:39:36 -0500 Subject: [PATCH 2/2] Update handling of response from get_tsv_errors --- src/routes/validation/validation.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/routes/validation/validation.py b/src/routes/validation/validation.py index 65cbd030..3547efa4 100644 --- a/src/routes/validation/validation.py +++ b/src/routes/validation/validation.py @@ -113,6 +113,11 @@ def validate_tsv(schema='metadata', path=None): } result = iv_utils.get_tsv_errors(path, schema_name=schema_name, report_type=table_validator.ReportType.JSON, globus_token=get_groups_token(), app_context=app_context) + if 'CEDAR Validation Errors' in result: + if path in result['CEDAR Validation Errors']: + result = result['CEDAR Validation Errors'][path] + else: + result = result['CEDAR Validation Errors'] except Exception as e: result = rest_server_err(e, True) return json.dumps(result) @@ -165,8 +170,10 @@ def check_cedar(entity_type, sub_type, upload): if len(records) > 0: if equals(entity_type, Ontology.ops().entities().SAMPLE) and 'metadata_schema_id' in records[0]: # TODO: check type of value schema for subtype - schema = iv_utils.get_schema_version(upload.get('fullpath'), encoding='ascii', globus_token=get_groups_token()) - return equals(schema, f"{entity_type}-{sub_type}") + # schema = iv_utils.get_schema_version(upload.get('fullpath'), encoding='ascii', globus_token=get_groups_token()) + # return equals(schema, f"{entity_type}-{sub_type}") + cedar_sample_sub_type_ids = get_cedar_schema_ids() + return equals(records[0]['metadata_schema_id'], cedar_sample_sub_type_ids[sub_type]) return True def determine_schema(entity_type, sub_type):