Skip to content

Commit 954c16c

Browse files
committed
Fix: ensure checkpoint filepath exists before training
Previously choosing a non-existant directory as checkpoint_filepath would lead to silently not saving at all.
1 parent d582111 commit 954c16c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bayesflow/workflows/basic_workflow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def __init__(
125125
file_ext = self.checkpoint_name + ".weights.h5"
126126
else:
127127
file_ext = self.checkpoint_name + ".keras"
128+
129+
# If the directory checkpoint_filepath does not exist yet, create it.
130+
os.makedirs(self.checkpoint_filepath, exist_ok=True)
131+
128132
checkpoint_full_filepath = os.path.join(self.checkpoint_filepath, file_ext)
129133
if os.path.exists(checkpoint_full_filepath):
130134
msg = (

0 commit comments

Comments
 (0)