Skip to content

Commit

Permalink
Fix potential error of close method
Browse files Browse the repository at this point in the history
  • Loading branch information
RangeKing committed Sep 4, 2023
1 parent 3b0fb1b commit 48224a7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions mmengine/visualization/vis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,16 +1280,18 @@ def close(self) -> None:
if not hasattr(self, '_dvclive'):
return

file_paths = dict()
for filename in scandir(self.cfg.work_dir, self._artifact_suffix,
True):
file_path = osp.join(self.cfg.work_dir, filename)
relative_path = os.path.relpath(file_path, self.cfg.work_dir)
dir_path = os.path.dirname(relative_path)
file_paths[file_path] = dir_path
if (hasattr(self, 'cfg')
and osp.isdir(getattr(self.cfg, 'work_dir', ''))):
file_paths = dict()
for filename in scandir(self.cfg.work_dir, self._artifact_suffix,
True):
file_path = osp.join(self.cfg.work_dir, filename)
relative_path = os.path.relpath(file_path, self.cfg.work_dir)
dir_path = os.path.dirname(relative_path)
file_paths[file_path] = dir_path

for file_path, dir_path in file_paths.items():
self._dvclive.log_artifact(file_path, dir_path)
for file_path, dir_path in file_paths.items():
self._dvclive.log_artifact(file_path, dir_path)

self._dvclive.end()

Expand Down

0 comments on commit 48224a7

Please sign in to comment.