From 438da316e69e53a35169b677091987f4513a0ec6 Mon Sep 17 00:00:00 2001 From: Alex Burlacu Date: Thu, 23 Mar 2023 14:53:11 +0200 Subject: [PATCH] Fix StorageManager incorrectly identifying the bucket as additional folder for MinIO --- clearml/storage/manager.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/clearml/storage/manager.py b/clearml/storage/manager.py index 5f1dd250..14c01217 100644 --- a/clearml/storage/manager.py +++ b/clearml/storage/manager.py @@ -291,11 +291,20 @@ class StorageManager(object): :return: Path to downloaded file or None on error """ + + def remove_prefix_from_str(target_str, prefix_to_be_removed): + # type: (str, str) -> str + if target_str.startswith(prefix_to_be_removed): + return target_str[len(prefix_to_be_removed):] + return target_str + + longest_configured_url = StorageHelper._resolve_base_url(remote_url) # noqa + bucket_path = remove_prefix_from_str(remote_url[len(longest_configured_url):], "/") + if not local_folder: local_folder = CacheManager.get_cache_manager().get_cache_folder() - local_path = os.path.join( - str(Path(local_folder).absolute()), str(Path(urlparse(remote_url).path)).lstrip(os.path.sep) - ) + local_path = str(Path(local_folder).expanduser().absolute() / bucket_path) + helper = StorageHelper.get(remote_url) return helper.download_to_file( remote_url,