From f8fb07486f35d06018bcd67a1b3538973bc2267d Mon Sep 17 00:00:00 2001 From: yuanzhou Date: Thu, 7 Nov 2024 09:55:40 -0500 Subject: [PATCH 1/2] Bump version to 2.3.28 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e487952b..f7fb770b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.27 +2.3.28 From bc65fb675f56a1faf2733d937a223ea2e69ddfe7 Mon Sep 17 00:00:00 2001 From: yuanzhou Date: Thu, 7 Nov 2024 09:59:51 -0500 Subject: [PATCH 2/2] Remove assay type references and methods --- src/app.py | 18 ---------- src/schema/schema_constants.py | 1 - src/schema/schema_manager.py | 63 ---------------------------------- src/schema/schema_triggers.py | 58 ------------------------------- 4 files changed, 140 deletions(-) diff --git a/src/app.py b/src/app.py index bd2a7451..bb4a6396 100644 --- a/src/app.py +++ b/src/app.py @@ -3338,13 +3338,6 @@ def get_prov_info(): if user_in_hubmap_read_group(request): published_only = False - # Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description - # because that would require using a urllib request for each dataset - - # As above, we parse te assay type yaml here rather than calling the special method for it because this avoids - # having to access the resource for every dataset. - assay_types_dict = schema_manager.get_assay_types() - # Processing and validating query parameters accepted_arguments = ['format', 'organ', 'has_rui_info', 'dataset_status', 'group_uuid'] return_json = False @@ -3705,13 +3698,6 @@ def get_prov_info_for_dataset(id): HEADER_PROCESSED_DATASET_STATUS, HEADER_PROCESSED_DATASET_PORTAL_URL, HEADER_DATASET_SAMPLES ] - # Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description - # because that would require using a urllib request for each dataset - - # As above, we parse te assay type yaml here rather than calling the special method for it because this avoids - # having to access the resource for every dataset. - assay_types_dict = schema_manager.get_assay_types() - hubmap_ids = schema_manager.get_hubmap_ids(id) # Get the target uuid if all good @@ -3942,10 +3928,6 @@ def sankey_data(): # because that would require using a urllib request for each dataset organ_types_dict = schema_manager.get_organ_types() - # As above, we parse te assay type yaml here rather than calling the special method for it because this avoids - # having to access the resource for every dataset. - assay_types_dict = schema_manager.get_assay_types() - # Instantiation of the list dataset_sankey_list dataset_sankey_list = [] diff --git a/src/schema/schema_constants.py b/src/schema/schema_constants.py index 7096f93d..e7fcbc3f 100644 --- a/src/schema/schema_constants.py +++ b/src/schema/schema_constants.py @@ -18,7 +18,6 @@ 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' DOI_BASE_URL = 'https://doi.org/' diff --git a/src/schema/schema_manager.py b/src/schema/schema_manager.py index 5738d6cf..14d482fe 100644 --- a/src/schema/schema_manager.py +++ b/src/schema/schema_manager.py @@ -2248,69 +2248,6 @@ def get_organ_types(): return _organ_types -""" -Retrive the assay types from ontology-api - -Returns -------- -dict - The available assay types by name in the following format: - - { - "10x-multiome": { - "contains_pii": true, - "description": "10x Multiome", - "name": "10x-multiome", - "primary": true, - "vis_only": false, - "vitessce_hints": [] - }, - "AF": { - "contains_pii": false, - "description": "Autofluorescence Microscopy", - "name": "AF", - "primary": true, - "vis_only": false, - "vitessce_hints": [] - }, - ... - } -""" -def get_assay_types(): - global _ontology_api_url - - target_url = _ontology_api_url + SchemaConstants.ONTOLOGY_API_ASSAY_TYPES_ENDPOINT - - # Use Memcached to improve performance - response = make_request_get(target_url, internal_token_used = True) - - # Invoke .raise_for_status(), an HTTPError will be raised with certain status codes - response.raise_for_status() - - if response.status_code == 200: - assay_types_by_name = {} - result_dict = response.json() - - # Due to the json envelop being used int the json result - assay_types_list = result_dict['result'] - for assay_type_dict in assay_types_list: - assay_types_by_name[assay_type_dict['name']] = assay_type_dict - - return assay_types_by_name - else: - # Log the full stack trace, prepend a line with our message - 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) - - logger.debug("======get_assay_types() response text from ontology-api======") - logger.debug(response.text) - - # Also bubble up the error message from ontology-api - raise requests.exceptions.RequestException(response.text) - - #################################################################################################### ## Internal functions #################################################################################################### diff --git a/src/schema/schema_triggers.py b/src/schema/schema_triggers.py index e5a1a556..e8fee43b 100644 --- a/src/schema/schema_triggers.py +++ b/src/schema/schema_triggers.py @@ -2204,61 +2204,3 @@ def _delete_files(target_property_key, property_key, normalized_type, user_token return generated_dict - -""" -Get the assay type description based on the given assay type - -Parameters ----------- -assay_type : str - The assay type name - -Returns -------- -str: The corresponding assay type description -""" -def _get_assay_type_description(assay_type): - assay_types_dict = schema_manager.get_assay_types() - - if assay_type in assay_types_dict: - return assay_types_dict[assay_type]['description'].lower() - - -""" -Compose the assay type description based on the given assay types - -Parameters ----------- -data_types : list - A list of dataset data types - -Returns -------- -str: The combined and formatted assay type description -""" -def _get_combined_assay_type_description(data_types): - assay_types = [] - assay_type_desc = '' - - for data_type in data_types: - assay_types.append(_get_assay_type_description(data_type)) - - # Formatting based on the number of items in the list - if assay_types: - if len(assay_types) == 1: - assay_type_desc = assay_types[0] - elif len(assay_types) == 2: - # and - assay_type_desc = ' and '.join(assay_types) - else: - # , , and - assay_type_desc = f"{', '.join(assay_types[:-1])}, and {assay_types[-1]}" - else: - msg = "Empty list of assay_types" - - logger.error(msg) - - raise ValueError(msg) - - return assay_type_desc -