Skip to content

Commit

Permalink
[logger] added flush to DiskLogger (#1078)
Browse files Browse the repository at this point in the history
Co-authored-by: Felipe Mello <felipemello@fb.com>
  • Loading branch information
felipemello1 and Felipe Mello authored Jun 12, 2024
1 parent 74fb5e4 commit a1fa0fd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchtune/utils/metric_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ def path_to_log_file(self) -> Path:

def log(self, name: str, data: Scalar, step: int) -> None:
self._file.write(f"Step {step} | {name}:{data}\n")
self._file.flush()

def log_dict(self, payload: Mapping[str, Scalar], step: int) -> None:
self._file.write(f"Step {step} | ")
for name, data in payload.items():
self._file.write(f"{name}:{data} ")
self._file.write("\n")
self._file.flush()

def __del__(self) -> None:
self._file.close()
Expand Down

0 comments on commit a1fa0fd

Please sign in to comment.