Skip to content

Commit 031f1a5

Browse files
committed
Unpack .tgz files to target_path dir
1 parent 9ad5b1a commit 031f1a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

benchmark/dataset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ def _download_file(self, relative_path: str, url: str):
195195
self._extract_or_move_file(tmp_path, target_path)
196196

197197
def _extract_or_move_file(self, tmp_path, target_path):
198+
# If the file is a .tgz or .tar.gz archive, always extract to a directory named target_path
198199
if tmp_path.endswith(".tgz") or tmp_path.endswith(".tar.gz"):
199-
print(f"Extracting: {tmp_path} -> {target_path}")
200-
(DATASETS_DIR / self.config.path).mkdir(exist_ok=True, parents=True)
200+
print(f"Extracting: {tmp_path} -> {target_path}/")
201+
# Ensure target_path is a directory
202+
Path(target_path).mkdir(exist_ok=True, parents=True)
201203
with tarfile.open(tmp_path) as file:
202204
file.extractall(target_path)
203205
os.remove(tmp_path)

0 commit comments

Comments
 (0)