Skip to content

Commit 70cc4e1

Browse files
committed
Ensure GGUF split output directories exist
1 parent d4d75b1 commit 70cc4e1

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

gguf-py/gguf/gguf_writer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,13 @@ def open_output_file(self, path: Path | None = None) -> None:
358358

359359
if self.path is not None:
360360
filenames = self.print_plan()
361-
self.fout = [
362-
open(filename, "wb") if self._should_materialize_shard(i) else None
363-
for i, filename in enumerate(filenames)
364-
]
361+
self.fout = []
362+
for i, filename in enumerate(filenames):
363+
if self._should_materialize_shard(i):
364+
filename.parent.mkdir(parents=True, exist_ok=True)
365+
self.fout.append(open(filename, "wb"))
366+
else:
367+
self.fout.append(None)
365368
self.output_file_advise_offsets = [0 for _ in filenames]
366369
self.state = WriterState.EMPTY
367370

0 commit comments

Comments
 (0)