Skip to content

Commit 2a47e95

Browse files
v0.5.17
tensorboard clean
1 parent 67d47c5 commit 2a47e95

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

pyproject.toml

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

88
[project]
99
name = "spotPython"
10-
version = "0.5.16"
10+
version = "0.5.17"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/utils/init.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import lightning as L
3+
import datetime
34

45
# PyTorch TensorBoard support
56
from torch.utils.tensorboard import SummaryWriter
@@ -10,7 +11,8 @@ def fun_control_init(
1011
_L_in=None,
1112
_L_out=None,
1213
enable_progress_bar=False,
13-
spot_tensorboard_path="runs_spot/",
14+
spot_tensorboard_path=None,
15+
TENSORBOARD_CLEAN=False,
1416
num_workers=0,
1517
device=None,
1618
seed=1234,
@@ -82,10 +84,19 @@ def fun_control_init(
8284
os.makedirs(RESULTS_PATH, exist_ok=True)
8385
# Path to the folder where the tensorboard files are saved
8486
TENSORBOARD_PATH = os.environ.get("PATH_TENSORBOARD", "runs/")
87+
if TENSORBOARD_CLEAN:
88+
# if the folder "runs" exists, move it to "runs_Y_M_D_H_M_S" to avoid overwriting old tensorboard files
89+
if os.path.exists(TENSORBOARD_PATH):
90+
now = datetime.datetime.now()
91+
# use [:-1] to remove "/" from the end of the path
92+
TENSORBOARD_PATH_OLD = TENSORBOARD_PATH[:-1] + now.strftime("%Y_%m_%d_%H_%M_%S")
93+
os.rename(TENSORBOARD_PATH[:-1], TENSORBOARD_PATH_OLD)
8594
os.makedirs(TENSORBOARD_PATH, exist_ok=True)
8695
if spot_tensorboard_path is not None:
8796
os.makedirs(spot_tensorboard_path, exist_ok=True)
8897
spot_writer = SummaryWriter(spot_tensorboard_path)
98+
else:
99+
spot_writer = None
89100

90101
if not os.path.exists("./figures"):
91102
os.makedirs("./figures")

0 commit comments

Comments
 (0)