Datalad containers-run error: no such file or directory

I’m using datalad on HPC and running into a problem with the containers-run command.

I think the singularity image is not opening up in the correct place for example I have a script in my project code directory: code/ which is actually located at:
/om2/user/jsmentch/projects/nat_img where nat_img is my datalad dataset
but it tries to find it in my home directory instead: /home/jsmentch/code/

(datalad_env) bash-4.2$ datalad containers-run -m "test bash script in code dir" --container-name feature-extraction "code/"
[INFO   ] Making sure inputs are available (this may take some time)
[INFO   ] == Command start (output follows) =====
FATAL:   stat /home/jsmentch/code/ no such file or directory
[INFO   ] == Command exit (modification check follows) =====
[INFO   ] The command had a non-zero exit code. If this is expected, you can save the changes with 'datalad save -d . -r -F .git/COMMIT_EDITMSG'
CommandError: 'singularity exec .datalad/environments/feature-extraction/image code/' failed with exitcode 255 under /om2/user/jsmentch/projects/nat_img

Not that I want to run with an absolute path to the script but that also does not work maybe because singularity is then missing the -B to the /om2 drive.

Does anyone know if this might be an issue with my datalad setup or maybe on the singularity side?

“need more data”.
what singularity version would it be - may be it fails to bind mount /om2 since it doesn’t exist in the container (IIRC 2.6.x and some early 3.x had that issue)? you could indeed adjust .datalad/config to provide explicit options for singularity invocation – datalad containers-run is just running that command, so no magic done by datalad here. So you can just run singularity run directly and see what you get. Re magic: In comparison, in GitHub - ReproNim/containers: Containers "distribution" for reproducible neuroimaging containers are executed by containers/singularity_cmd at master · ReproNim/containers · GitHub helper which would do some extra cleansing and specification of bind mounts.

1 Like

This is with singularity 3.6.3. I’ve adjusted the .datalad/config ‘cmdexec’ for my containers to explicitly bind the directory and it seems to be working now. So it was just not binding the directoery and I didn’t know how to do that within datalad-containers. Thanks for the pointers and the script I should be able to use that so that it will run / rerun wherever it is installed!

To avoid hardcoding or needing custom script, I believe you can use {dspath} placeholder there in the command which datalad run (used by containers-run) would expand: datalad run — DataLad 0.13.7 documentation

1 Like

Even better! So in case someone else encounters this, {dspath} didn’t work for me
[Unrecognized cmdexec placeholder: 'dspath'. See containers-add for information on known ones: img, cmd, img_dspath]

and despite having singularity 3.x img_dspath (relative) was not working. But from this issue this command works:

cmdexec = singularity exec --bind $PWD/{img_dspath} {img} {cmd}

d’oh – right – didn’t check, but since indeed those (like dspath) to be passed to be “formatted” by datalad run you would need to “double {}” them, ie use {{dspath}} form, so that {dspath} would be passed into datalad run invocation which would then format it. Would be all the same if dspath and img_dspath are the same of cause

1 Like