Skip to content

Commit

Permalink
Let /bin/sh parse the args.
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-delverme committed Jan 7, 2022
1 parent ce55592 commit 35676c3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions milatools/datasets/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ def fetch_imagenet(local_directory=None):
train_directory = os.path.join(dataset_home, "train")
validation_directory = os.path.join(dataset_home, "val")

subprocess.run(f"mkdir -p {train_directory}/ {validation_directory}/")
subprocess.run(f"tar -xf /network/datasets/imagenet/ILSVRC2012_img_train.tar -C {train_directory}")
subprocess.run(f"mkdir -p {train_directory}/ {validation_directory}/", shell=True)
subprocess.run(f"tar -xf /network/datasets/imagenet/ILSVRC2012_img_train.tar -C {train_directory}", shell=True)

p = subprocess.Popen(['cp', '-r', f'/network/datasets/imagenet.var/imagenet_torchvision/val {dataset_home}/'])
subprocess.run(
'find ' + train_directory + ' -name "*.tar" | while read NAME ; do mkdir -p "${NAME%.tar}"; tar -xf "${NAME}" -C "${NAME%.tar}"; rm -f "${NAME}"; done', shell=True
)
'find ' + train_directory +
' -name "*.tar" | while read NAME ; do mkdir -p "${NAME%.tar}"; tar -xf "${NAME}" -C "${NAME%.tar}"; rm -f "${NAME}"; done',
shell=True)
p.wait()
return train_directory, validation_directory
else:
Expand Down Expand Up @@ -49,8 +50,8 @@ def __init__(self, local_directory: str = None, *dataset_args, **dataset_kwargs)
if milatools.running_on_mila_cluster:
local_directory = os.path.join(os.environ["SLURM_TMPDIR"], "MNIST")
mnist_path = DATASET_PATH.format("mnist", "mnist")
subprocess.run(f"mkdir -p {local_directory}/")
subprocess.run(f"tar -xf {mnist_path} -C {mnist_path}")
subprocess.run("mkdir -p {local_directory}/", shell=True)
subprocess.run(f"tar -xf {mnist_path} -C {mnist_path}", shell=True)
super().__init__(local_directory, *dataset_args, **dataset_kwargs)


Expand Down

0 comments on commit 35676c3

Please sign in to comment.