From 1e7b35456da1ee9a642f5d8abb36aaf0df359f65 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 12 May 2021 15:42:02 +0300 Subject: [PATCH] Protect against wrong file object type when auto-binding models --- clearml/binding/frameworks/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clearml/binding/frameworks/__init__.py b/clearml/binding/frameworks/__init__.py index 093ea42f..90c1a140 100644 --- a/clearml/binding/frameworks/__init__.py +++ b/clearml/binding/frameworks/__init__.py @@ -168,7 +168,12 @@ class WeightsFileHandler(object): if task is None: return filepath - local_model_path = os.path.abspath(filepath) if filepath else filepath + try: + local_model_path = os.path.abspath(filepath) if filepath else filepath + except TypeError: + # not a recognized type, we just return it back + return filepath + model_info = WeightsFileHandler.ModelInfo( model=None, upload_filename=None, local_model_path=local_model_path, local_model_id=filepath, framework=framework, task=task) @@ -319,7 +324,12 @@ class WeightsFileHandler(object): # WeightsFileHandler._model_out_store_lookup.pop(id(model)) # trains_out_model, ref_model = None, None - local_model_path = os.path.abspath(saved_path) if saved_path else saved_path + try: + local_model_path = os.path.abspath(saved_path) if saved_path else saved_path + except TypeError: + # not a recognized type: + return saved_path + model_info = WeightsFileHandler.ModelInfo( model=trains_out_model, upload_filename=None, local_model_path=local_model_path, local_model_id=saved_path, framework=framework, task=task)