From 3dee5854bd15b7a5af3b96b57a5a02c2b050143d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 22 Dec 2022 21:52:24 +0200 Subject: [PATCH] Fix `StorageManager.get_file_size_bytes()` returns `ClientError` instead of `None` for invalid S3 links --- clearml/storage/helper.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clearml/storage/helper.py b/clearml/storage/helper.py index e6ffd3df..9d1a1e75 100644 --- a/clearml/storage/helper.py +++ b/clearml/storage/helper.py @@ -619,6 +619,13 @@ class StorageHelper(object): if isinstance(self._driver, _HttpDriver) and obj: obj = self._driver._get_download_object(obj) # noqa size = int(obj.headers.get("Content-Length", 0)) + elif isinstance(self._driver, _Boto3Driver) and obj: + # noinspection PyBroadException + try: + # To catch botocore exceptions + size = obj.content_length # noqa + except Exception: + pass elif hasattr(obj, "size"): size = obj.size # Google storage has the option to reload the object to get the size