mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 23:06:58 +08:00
Fix log object bug (#977)
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user