Search code examples
pythonsingularity-container

Bind and run a Python module with singularity from a remote directory


I need to run a personnal Python module from a singularity container. I usually run it with the following command :

singularity run ./Image/myimage.sif -m mymodule.start

However it's only work if I am in the same folder as 'mymodule'.

Now, I need to run this same module from a remote directory. I therefore bind my 'mymodule' directory :

singularity run --bind ~/Projects/MyModule/:/mnt ./Image/myimage.sif -m mymodule.start

Unfortunately it is binded in the /mnt directory, which means my module cannot be found. The error is

/usr/bin/python3: No module named mymodule.start

How could I make mymodule findable ?


Solution

  • Depends how the paths are specified in module.start but this should work with apptainer:

    APPTAINERENV_PREPEND_PATH=$HOME/Projects/MyModule/ --bind ~/Projects/MyModule/:/mnt ./Image/myimage.sif -m mymodule.start