Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only --bind Snakemake module into container when we're working with a Python script #1206

Merged
merged 2 commits into from Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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