[Fix] Close MLflowVisBackend only if active (#1144) (#1151)

This commit is contained in:
zimonitrome 2023-05-25 17:54:00 +02:00 committed by GitHub
parent 426a565908
commit 277b530880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -797,6 +797,9 @@ class MLflowVisBackend(BaseVisBackend):
def close(self) -> None:
"""Close the mlflow."""
if not hasattr(self, '_mlflow'):
return
file_paths = dict()
for filename in scandir(self.cfg.work_dir, self._artifact_suffix,
True):
@ -808,8 +811,7 @@ class MLflowVisBackend(BaseVisBackend):
for file_path, dir_path in file_paths.items():
self._mlflow.log_artifact(file_path, dir_path)
if hasattr(self, '_mlflow'):
self._mlflow.end_run()
self._mlflow.end_run()
def _flatten(self, d, parent_key='', sep='.') -> dict:
"""Flatten the dict."""