ReproNim / neurodocker

Generate custom Docker and Singularity images, and minimize existing containers
https://www.repronim.org/neurodocker/
Apache License 2.0
330 stars 97 forks source link

Minify error: No such file `_trace.sh` #451

Closed mateuszpawlik closed 2 years ago

mateuszpawlik commented 2 years ago

I'm trying to minify a container using your documentation.

Steps to install neurodocker:

python3 -m venv env
source env/bin/activate
pip3 install -U pip
pip3 install neurodocker[minify]

Steps to reproduce the error (it's difficult for me to provide reproducible steps at this point):

sudo docker run --rm -itd --name anc-acq-container --mount type=bind,source="$(pwd)",target=/data anc-acq_fsl-6.0.5.1 /bin/bash
cmd="/usr/local/bin/pydeface /data/test/tmp/sub-s001_acq-norm_T1w.nii"
sudo ./env/bin/neurodocker minify --container anc-acq-container --dir /opt "$cmd"

After the last command, I get the following error:

Traceback (most recent call last):
  File "./env/bin/neurodocker", line 8, in <module>
    sys.exit(cli())
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/neurodocker/cli/minify/trace.py", line 126, in minify
    copy_file_to_container(container, _trace_script, "/tmp/")
  File "/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/neurodocker/cli/minify/trace.py", line 67, in copy_file_to_container
    tar.add(src, arcname=filename, recursive=False)
  File "/usr/lib/python3.7/tarfile.py", line 1930, in add
    tarinfo = self.gettarinfo(name, arcname)
  File "/usr/lib/python3.7/tarfile.py", line 1809, in gettarinfo
    statres = os.lstat(name)
FileNotFoundError: [Errno 2] No such file or directory: '/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/neurodocker/cli/minify/_trace.sh'

Related issues: https://github.com/ReproNim/neurodocker/issues/450 https://github.com/poldracklab/pydeface/issues/44

mateuszpawlik commented 2 years ago

I don't know if it's related but I've found _trace.sh in this line: https://github.com/ReproNim/neurodocker/blob/65067b63335c782265fec32d46253c7eae2e80ba/setup.cfg#L66 but I can't find reprozip/_trace.sh path in the project.

mateuszpawlik commented 2 years ago

Copying file https://github.com/ReproNim/neurodocker/blob/master/neurodocker/cli/minify/_trace.sh into the directory from the error message (/home/mpawlik/Remote/anc-data-acquisition/env/lib/python3.7/site-packages/neurodocker/cli/minify/) helped.

Update: The minify tool executed. Files were successfully removed.

kaczmarj commented 2 years ago

@mateuszpawlik - thanks for the report. here's _trace.sh https://github.com/ReproNim/neurodocker/blob/master/neurodocker/cli/minify/_trace.sh

that is odd that _trace.sh is not included... i'll take a look. thanks again. we might have to push a new version to pypi.