diff --git a/qlib/workflow/record_temp.py b/qlib/workflow/record_temp.py index 5e817c2e0..161da1bb6 100644 --- a/qlib/workflow/record_temp.py +++ b/qlib/workflow/record_temp.py @@ -96,11 +96,12 @@ class RecordTemp: """ try: return self.recorder.load_object(self.get_path(name)) - except LoadObjectError: + except LoadObjectError as e: if parents: if self.depend_cls is not None: with class_casting(self, self.depend_cls): return self.load(name, parents=True) + raise e def list(self): """ diff --git a/qlib/workflow/recorder.py b/qlib/workflow/recorder.py index 67759e590..94cbac425 100644 --- a/qlib/workflow/recorder.py +++ b/qlib/workflow/recorder.py @@ -347,17 +347,17 @@ class MLflowRecorder(Recorder): """ assert self.uri is not None, "Please start the experiment and recorder first before using recorder directly." + path = None try: path = self.client.download_artifacts(self.id, name) with Path(path).open("rb") as f: data = unpickler(f).load() return data except Exception as e: - logger.exception(f"Fail to load data '{name}'") raise LoadObjectError(str(e)) from e finally: ar = self.client._tracking_client._get_artifact_repo(self.id) - if isinstance(ar, AzureBlobArtifactRepository): + if isinstance(ar, AzureBlobArtifactRepository) and path is not None: # for saving disk space # For safety, only remove redundant file for specific ArtifactRepository shutil.rmtree(Path(path).absolute().parent) diff --git a/qlib/workflow/task/collect.py b/qlib/workflow/task/collect.py index 8d7b6a71c..1866344c4 100644 --- a/qlib/workflow/task/collect.py +++ b/qlib/workflow/task/collect.py @@ -10,6 +10,7 @@ from qlib.log import TimeInspector from typing import Callable, Dict, Iterable, List from qlib.log import get_module_logger from qlib.utils.serial import Serializable +from qlib.utils.exceptions import LoadObjectError from qlib.workflow import R from qlib.workflow.exp import Experiment from qlib.workflow.recorder import Recorder @@ -228,9 +229,10 @@ class RecorderCollector(Collector): else: try: artifact = rec.load_object(self.artifacts_path[key]) - except Exception as e: + except LoadObjectError as e: if only_exist: # only collect existing artifact + logger.warning(f"Fail to load {self.artifacts_path[key]} and it is ignored.") continue raise e # give user some warning if the values are overridden