Skip to content

Commit 744ee00

Browse files
committed
Make parent directory for download_file if it doesn't exist
1 parent 9b7ab1f commit 744ee00

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: black
2020
types: [python]
2121

22-
- repo: https://gitlab.com/pycqa/flake8
22+
- repo: https://gitlab.com/pycqa/flake8.git
2323
rev: 3.7.9
2424
hooks:
2525
- id: flake8

speechbrain/utils/data_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import collections.abc
1313
import torch
1414
import tqdm
15+
import pathlib
1516

1617

1718
def undo_padding(batch, lengths):
@@ -261,6 +262,9 @@ def update_to(self, b=1, bsize=1, tsize=None):
261262
self.total = tsize
262263
self.update(b * bsize - self.n)
263264

265+
# Create the destination directory if it doesn't exist
266+
dest_dir = pathlib.Path(dest).resolve().parent
267+
dest_dir.mkdir(parents=True, exist_ok=True)
264268
if "http" not in source:
265269
shutil.copyfile(source, dest)
266270

0 commit comments

Comments
 (0)