Skip to content

Commit

Permalink
Implement pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehsurfer committed Aug 22, 2023
1 parent 2b48c8d commit 9d68233
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/main.py
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
9 changes: 3 additions & 6 deletions app/utilities.py
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 9d68233

Please sign in to comment.