Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for attr self._writer in case of import errors on TensorboardLogger #2092

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions torchtune/training/metric_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,13 @@ def log_dict(self, payload: Mapping[str, Scalar], step: int) -> None:
self.log(name, data, step)

def __del__(self) -> None:
if self._writer:
# extra check for when there is an import error
if hasattr(self, "_writer"):
self._writer.close()
self._writer = None

def close(self) -> None:
if self._writer:
if hasattr(self, "_writer"):
self._writer.close()
self._writer = None

Expand Down