Skip to content

Commit d1c08b3

Browse files
authored
Merge pull request #762 from hubmapconsortium/yuanzhou/remove-assaytype
Yuanzhou/remove assaytype
2 parents e58fbff + bc65fb6 commit d1c08b3

File tree

5 files changed

+1
-141
lines changed

5 files changed

+1
-141
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.27
1+
2.3.28

src/app.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,13 +3338,6 @@ def get_prov_info():
33383338
if user_in_hubmap_read_group(request):
33393339
published_only = False
33403340

3341-
# Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description
3342-
# because that would require using a urllib request for each dataset
3343-
3344-
# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
3345-
# having to access the resource for every dataset.
3346-
assay_types_dict = schema_manager.get_assay_types()
3347-
33483341
# Processing and validating query parameters
33493342
accepted_arguments = ['format', 'organ', 'has_rui_info', 'dataset_status', 'group_uuid']
33503343
return_json = False
@@ -3705,13 +3698,6 @@ def get_prov_info_for_dataset(id):
37053698
HEADER_PROCESSED_DATASET_STATUS, HEADER_PROCESSED_DATASET_PORTAL_URL, HEADER_DATASET_SAMPLES
37063699
]
37073700

3708-
# Parsing the organ types yaml has to be done here rather than calling schema.schema_triggers.get_organ_description
3709-
# because that would require using a urllib request for each dataset
3710-
3711-
# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
3712-
# having to access the resource for every dataset.
3713-
assay_types_dict = schema_manager.get_assay_types()
3714-
37153701
hubmap_ids = schema_manager.get_hubmap_ids(id)
37163702

37173703
# Get the target uuid if all good
@@ -3942,10 +3928,6 @@ def sankey_data():
39423928
# because that would require using a urllib request for each dataset
39433929
organ_types_dict = schema_manager.get_organ_types()
39443930

3945-
# As above, we parse te assay type yaml here rather than calling the special method for it because this avoids
3946-
# having to access the resource for every dataset.
3947-
assay_types_dict = schema_manager.get_assay_types()
3948-
39493931
# Instantiation of the list dataset_sankey_list
39503932
dataset_sankey_list = []
39513933

src/schema/schema_constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class SchemaConstants(object):
1818
UUID_API_ID_ENDPOINT = '/uuid'
1919
INGEST_API_FILE_COMMIT_ENDPOINT = '/file-commit'
2020
INGEST_API_FILE_REMOVE_ENDPOINT = '/file-remove'
21-
ONTOLOGY_API_ASSAY_TYPES_ENDPOINT = '/assaytype?application_context=HUBMAP'
2221
ONTOLOGY_API_ORGAN_TYPES_ENDPOINT = '/organs/by-code?application_context=HUBMAP'
2322

2423
DOI_BASE_URL = 'https://doi.org/'

src/schema/schema_manager.py

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,69 +2248,6 @@ def get_organ_types():
22482248
return _organ_types
22492249

22502250

2251-
"""
2252-
Retrive the assay types from ontology-api
2253-
2254-
Returns
2255-
-------
2256-
dict
2257-
The available assay types by name in the following format:
2258-
2259-
{
2260-
"10x-multiome": {
2261-
"contains_pii": true,
2262-
"description": "10x Multiome",
2263-
"name": "10x-multiome",
2264-
"primary": true,
2265-
"vis_only": false,
2266-
"vitessce_hints": []
2267-
},
2268-
"AF": {
2269-
"contains_pii": false,
2270-
"description": "Autofluorescence Microscopy",
2271-
"name": "AF",
2272-
"primary": true,
2273-
"vis_only": false,
2274-
"vitessce_hints": []
2275-
},
2276-
...
2277-
}
2278-
"""
2279-
def get_assay_types():
2280-
global _ontology_api_url
2281-
2282-
target_url = _ontology_api_url + SchemaConstants.ONTOLOGY_API_ASSAY_TYPES_ENDPOINT
2283-
2284-
# Use Memcached to improve performance
2285-
response = make_request_get(target_url, internal_token_used = True)
2286-
2287-
# Invoke .raise_for_status(), an HTTPError will be raised with certain status codes
2288-
response.raise_for_status()
2289-
2290-
if response.status_code == 200:
2291-
assay_types_by_name = {}
2292-
result_dict = response.json()
2293-
2294-
# Due to the json envelop being used int the json result
2295-
assay_types_list = result_dict['result']
2296-
for assay_type_dict in assay_types_list:
2297-
assay_types_by_name[assay_type_dict['name']] = assay_type_dict
2298-
2299-
return assay_types_by_name
2300-
else:
2301-
# Log the full stack trace, prepend a line with our message
2302-
logger.exception("Unable to make a request to query the assay types via ontology-api")
2303-
2304-
logger.debug("======get_assay_types() status code from ontology-api======")
2305-
logger.debug(response.status_code)
2306-
2307-
logger.debug("======get_assay_types() response text from ontology-api======")
2308-
logger.debug(response.text)
2309-
2310-
# Also bubble up the error message from ontology-api
2311-
raise requests.exceptions.RequestException(response.text)
2312-
2313-
23142251
####################################################################################################
23152252
## Internal functions
23162253
####################################################################################################

src/schema/schema_triggers.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,61 +2204,3 @@ def _delete_files(target_property_key, property_key, normalized_type, user_token
22042204

22052205
return generated_dict
22062206

2207-
2208-
"""
2209-
Get the assay type description based on the given assay type
2210-
2211-
Parameters
2212-
----------
2213-
assay_type : str
2214-
The assay type name
2215-
2216-
Returns
2217-
-------
2218-
str: The corresponding assay type description
2219-
"""
2220-
def _get_assay_type_description(assay_type):
2221-
assay_types_dict = schema_manager.get_assay_types()
2222-
2223-
if assay_type in assay_types_dict:
2224-
return assay_types_dict[assay_type]['description'].lower()
2225-
2226-
2227-
"""
2228-
Compose the assay type description based on the given assay types
2229-
2230-
Parameters
2231-
----------
2232-
data_types : list
2233-
A list of dataset data types
2234-
2235-
Returns
2236-
-------
2237-
str: The combined and formatted assay type description
2238-
"""
2239-
def _get_combined_assay_type_description(data_types):
2240-
assay_types = []
2241-
assay_type_desc = ''
2242-
2243-
for data_type in data_types:
2244-
assay_types.append(_get_assay_type_description(data_type))
2245-
2246-
# Formatting based on the number of items in the list
2247-
if assay_types:
2248-
if len(assay_types) == 1:
2249-
assay_type_desc = assay_types[0]
2250-
elif len(assay_types) == 2:
2251-
# <assay_type1> and <assay_type2>
2252-
assay_type_desc = ' and '.join(assay_types)
2253-
else:
2254-
# <assay_type1>, <assay_type2>, and <assay_type3>
2255-
assay_type_desc = f"{', '.join(assay_types[:-1])}, and {assay_types[-1]}"
2256-
else:
2257-
msg = "Empty list of assay_types"
2258-
2259-
logger.error(msg)
2260-
2261-
raise ValueError(msg)
2262-
2263-
return assay_type_desc
2264-

0 commit comments

Comments
 (0)