1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 06:20:57 +08:00

safe remove file and more friendly log (#967)

* save remove file and more friendly log

* fix pylint
This commit is contained in:
you-n-g
2022-03-13 11:11:41 +08:00
committed by GitHub
parent 0f519f6053
commit 921c13cc90
2 changed files with 5 additions and 4 deletions

View File

@@ -2,7 +2,6 @@
# Licensed under the MIT License.
import numpy as np
import pandas as pd
from typing import Union
from sklearn.decomposition import PCA, FactorAnalysis

View File

@@ -351,14 +351,16 @@ class MLflowRecorder(Recorder):
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):
# for saving disk space
# For safety, only remove redundant file for specific ArtifactRepository
shutil.rmtree(Path(path).absolute().parent)
return data
except Exception as e:
raise LoadObjectError(str(e)) from e
@AsyncCaller.async_dec(ac_attr="async_log")
def log_params(self, **kwargs):