Skip to content

Commit

Permalink
fix: Only --bind Snakemake when we're working with a Python script (#…
Browse files Browse the repository at this point in the history
…1206)

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
frankier and johanneskoester committed Oct 21, 2021
1 parent 84d1f64 commit 1d79f62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions snakemake/deployment/singularity.py
Expand Up @@ -113,6 +113,7 @@ def shellcmd(
envvars=None,
shell_executable=None,
container_workdir=None,
is_python_script=False,
):
"""Execute shell command inside singularity container given optional args
and environment variables to be passed."""
Expand All @@ -131,8 +132,9 @@ def shellcmd(
# because we cannot be sure where it is located in the container.
shell_executable = os.path.split(shell_executable)[-1]

# mount host snakemake module into container
args += " --bind {}:{}".format(SNAKEMAKE_SEARCHPATH, SNAKEMAKE_MOUNTPOINT)
if is_python_script:
# mount host snakemake module into container
args += " --bind {}:{}".format(SNAKEMAKE_SEARCHPATH, SNAKEMAKE_MOUNTPOINT)

if container_workdir:
args += " --pwd {}".format(container_workdir)
Expand Down
4 changes: 3 additions & 1 deletion snakemake/script.py
Expand Up @@ -579,7 +579,9 @@ def execute_script(self, fname, edit=False):
# bash is configured as executable on Windows
py_exec = py_exec.replace("\\", "/")
# use the same Python as the running process or the one from the environment
self._execute_cmd("{py_exec} {fname:q}", py_exec=py_exec, fname=fname)
self._execute_cmd(
"{py_exec} {fname:q}", py_exec=py_exec, fname=fname, is_python_script=True
)


class RScript(ScriptBase):
Expand Down
1 change: 1 addition & 0 deletions snakemake/shell.py
Expand Up @@ -184,6 +184,7 @@ def __new__(
envvars=None,
shell_executable=cls._process_args["executable"],
container_workdir=shadow_dir,
is_python_script=context.get("is_python_script", False),
)
logger.info("Activating singularity image {}".format(container_img))
if conda_env:
Expand Down

0 comments on commit 1d79f62

Please sign in to comment.