Skip to content

Commit 748195e

Browse files
authored
Merge pull request #100 from diningphil/plotter_metric_storage_fix
minor on plotter
2 parents 8084a8c + 89efe0c commit 748195e

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## [1.5.9] Minor fix
3+
4+
## Changed
5+
- Replaced torch.save with atomic_save of PyDGN to handle cases where metrics data storage corrupted the file
6+
7+
28
## [1.5.8] Minor fix
39

410
## Fixed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
author = "Federico Errica"
2525

2626
# The full version, including alpha/beta/rc tags
27-
release = "1.5.8"
27+
release = "1.5.9"
2828

2929

3030
# -- General configuration ---------------------------------------------------

pydgn/training/callback/plotter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33

44
import torch
5+
from pydgn.training.util import atomic_save
56
from torch.utils.tensorboard import SummaryWriter
67

78
from pydgn.static import *
@@ -33,7 +34,7 @@ def __init__(self,
3334
self.writer = SummaryWriter(log_dir=Path(self.exp_path, "tensorboard"))
3435

3536
self.stored_metrics = {"losses": {}, "scores": {}}
36-
self.stored_metrics_path = Path(self.exp_path, "metrics_data.torch")
37+
self.stored_metrics_path = Path(self.exp_path, "metrics_data.pt")
3738
if os.path.exists(self.stored_metrics_path):
3839
self.stored_metrics = torch.load(self.stored_metrics_path)
3940

@@ -87,11 +88,7 @@ def on_epoch_end(self, state: State):
8788
self.stored_metrics[t][k].append(v.item())
8889

8990
if self.store_on_disk:
90-
try:
91-
torch.save(self.stored_metrics, self.stored_metrics_path)
92-
except RuntimeError as e:
93-
print(e)
94-
91+
atomic_save(self.stored_metrics, self.stored_metrics_path)
9592

9693
def on_fit_end(self, state: State):
9794
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pydgn"
7-
version = "1.5.8"
7+
version = "1.5.9"
88
description = "A Python Package for Deep Graph Networks"
99
authors = [ { name="Federico Errica", email="f.errica@protonmail.com" } ]
1010
readme = "README.md"

0 commit comments

Comments
 (0)