Skip to content

Commit 50463fa

Browse files
Change compression fn to save empty metadata dir
This commit fixes an issue when storing checkpoints with no metadata. Now the metadata folder is stored in the compressed checkpoint even if there are no files inside. This avoids an error when trying to load the checkpoint.
1 parent 3fa0c64 commit 50463fa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/nn_core/serialization.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ def compress_checkpoint(src_dir: Path, dst_file: Path, delete_dir: bool = True):
9595
with zipfile.ZipFile(_normalize_path(dst_file), "w") as zip_file:
9696
for folder, subfolders, files in os.walk(src_dir):
9797
folder: Path = Path(folder)
98+
for subfolder in subfolders:
99+
zip_file.write(
100+
folder / subfolder,
101+
(folder / subfolder).relative_to(src_dir),
102+
compress_type=zipfile.ZIP_DEFLATED,
103+
)
104+
98105
for file in files:
99106
zip_file.write(
100107
folder / file,

0 commit comments

Comments
 (0)