From d63b25a328938296a58e3a66ca737afdb56dd416 Mon Sep 17 00:00:00 2001 From: yuanzhou Date: Mon, 27 Nov 2023 19:50:03 -0500 Subject: [PATCH] Remove parsing on alt-names --- src/app.py | 45 ++++++++++++---------------------- src/schema/schema_constants.py | 4 +-- src/schema/schema_manager.py | 6 ++--- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/app.py b/src/app.py index 00f1d523..5e18cb59 100644 --- a/src/app.py +++ b/src/app.py @@ -2794,17 +2794,12 @@ def get_prov_info(): for item in dataset['data_types']: try: assay_description_list.append(assay_types_dict[item]['description']) - # Some data types aren't given by their code in the assay types yaml and are instead given as an alt name. - # In these cases, we have to search each assay type and see if the given code matches any alternate names. except KeyError: - valid_key = False - for each in assay_types_dict: - if valid_key is False: - if item in assay_types_dict[each]['alt-names']: - assay_description_list.append(assay_types_dict[each]['description']) - valid_key = True - if valid_key is False: - assay_description_list.append(item) + logger.exception(f"Data type {item} not found in resulting assay types via ontology-api") + + # Just use the data type value + assay_description_list.append(item) + dataset['data_types'] = assay_description_list internal_dict[HEADER_DATASET_DATA_TYPES] = dataset['data_types'] @@ -3116,17 +3111,12 @@ def get_prov_info_for_dataset(id): for item in dataset['data_types']: try: assay_description_list.append(assay_types_dict[item]['description']) - # Some data types aren't given by their code in the assay types yaml and are instead given as an alt name. - # In these cases, we have to search each assay type and see if the given code matches any alternate names. except KeyError: - valid_key = False - for each in assay_types_dict: - if valid_key is False: - if item in assay_types_dict[each]['alt-names']: - assay_description_list.append(assay_types_dict[each]['description']) - valid_key = True - if valid_key is False: - assay_description_list.append(item) + logger.exception(f"Data type {item} not found in resulting assay types via ontology-api") + + # Just use the data type value + assay_description_list.append(item) + dataset['data_types'] = assay_description_list internal_dict[HEADER_DATASET_DATA_TYPES] = dataset['data_types'] if return_json is False: @@ -3342,17 +3332,12 @@ def sankey_data(): assay_description = "" try: assay_description = assay_types_dict[dataset[HEADER_DATASET_DATA_TYPES]]['description'] - # Some data types aren't given by their code in the assay types yaml and are instead given as an alt name. - # In these cases, we have to search each assay type and see if the given code matches any alternate names. except KeyError: - valid_key = False - for each in assay_types_dict: - if valid_key is False: - if dataset[HEADER_DATASET_DATA_TYPES] in assay_types_dict[each]['alt-names']: - assay_description = assay_types_dict[each]['description'] - valid_key = True - if valid_key is False: - assay_description = dataset[HEADER_DATASET_DATA_TYPES] + logger.exception(f"Data type {dataset[HEADER_DATASET_DATA_TYPES]} not found in resulting assay types via ontology-api") + + # Just use the data type value + assay_description = dataset[HEADER_DATASET_DATA_TYPES] + internal_dict[HEADER_DATASET_DATA_TYPES] = assay_description # Replace applicable Group Name and Data type with the value needed for the sankey via the mapping_dict diff --git a/src/schema/schema_constants.py b/src/schema/schema_constants.py index 111f1ed1..6a471587 100644 --- a/src/schema/schema_constants.py +++ b/src/schema/schema_constants.py @@ -14,8 +14,8 @@ class SchemaConstants(object): UUID_API_ID_ENDPOINT = '/uuid' INGEST_API_FILE_COMMIT_ENDPOINT = '/file-commit' INGEST_API_FILE_REMOVE_ENDPOINT = '/file-remove' - ONTOLOGY_API_ASSAY_TYPES_ENDPOINT = '/assaytype?application_context=HuBMAP' - ONTOLOGY_API_ORGAN_TYPES_ENDPOINT = '/organs/by-code?application_context=HuBMAP' + ONTOLOGY_API_ASSAY_TYPES_ENDPOINT = '/assaytype?application_context=HUBMAP' + ONTOLOGY_API_ORGAN_TYPES_ENDPOINT = '/organs/by-code?application_context=HUBMAP' DOI_BASE_URL = 'https://doi.org/' diff --git a/src/schema/schema_manager.py b/src/schema/schema_manager.py index a4f36612..bba74e03 100644 --- a/src/schema/schema_manager.py +++ b/src/schema/schema_manager.py @@ -1804,9 +1804,8 @@ def get_organ_types(): if response.status_code == 200: return response.json() else: - msg = "Unable to make a request to query the organ types via ontology-api: {id}" # Log the full stack trace, prepend a line with our message - logger.exception(msg) + logger.exception("Unable to make a request to query the organ types via ontology-api") logger.debug("======get_organ_types() status code from ontology-api======") logger.debug(response.status_code) @@ -1868,9 +1867,8 @@ def get_assay_types(): return assay_types_by_name else: - msg = "Unable to make a request to query the assay types via ontology-api" # Log the full stack trace, prepend a line with our message - logger.exception(msg) + logger.exception("Unable to make a request to query the assay types via ontology-api") logger.debug("======get_assay_types() status code from ontology-api======") logger.debug(response.status_code)