From 9d68233841a4c0b2b7d8ebd2baa799e6da2b8eeb Mon Sep 17 00:00:00 2001 From: Jesse Khorasanee Date: Tue, 22 Aug 2023 13:57:13 +1200 Subject: [PATCH] Implement pr feedback --- app/main.py | 4 ++-- app/utilities.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/main.py b/app/main.py index c0b8198..86c133d 100644 --- a/app/main.py +++ b/app/main.py @@ -44,7 +44,7 @@ from app.scicrunch_process_results import process_results, process_get_first_scaffold_info, reform_aggregation_results, \ reform_curies_results, reform_dataset_results, reform_related_terms, reform_anatomy_results from app.serializer import ContactRequestSchema -from app.utilities import img_to_base64_str, check_path_in_mangled_list +from app.utilities import img_to_base64_str, get_path_from_mangled_list from app.osparc.osparc import start_simulation as do_start_simulation from app.osparc.osparc import check_simulation as do_check_simulation from app.biolucida_process_results import process_results as process_biolucida_results @@ -452,7 +452,7 @@ def direct_download_url(path, bucket_name=Config.DEFAULT_S3_BUCKET_NAME): # If the file does not exist, check if the name was mangled if response[0] == 404: - s3_path_modified = check_path_in_mangled_list(path) + s3_path_modified = get_path_from_mangled_list(path) if s3_path_modified == s3_path: abort(404, description=f'Provided path was not found on the s3 resource') # Abort if path did not change diff --git a/app/utilities.py b/app/utilities.py index 829d0c2..c6a6540 100644 --- a/app/utilities.py +++ b/app/utilities.py @@ -2,17 +2,14 @@ from io import BytesIO from app.manifest_name_to_discover_name import name_map -def check_path_in_mangled_list(s3_path): +def get_path_from_mangled_list(s3_path): # Split out the file part of the path s3_paths = s3_path.split('files/') - s3_paths[1] = 'files/' + s3_paths[1] # Add the part we split on back + file_path = 'files/' + s3_paths[1] # Add the part we split on back # Switch the path to the mapped one if it is listed - if s3_paths[1] in name_map: - s3_paths[1] = name_map[s3_paths[1]] - - return s3_paths[0] + s3_paths[1] # Return the path with dataset info at the front + return s3_paths[0] + name_map.get(file_path, file_path) def img_to_base64_str(img): """