Skip to content

Commit 867a027

Browse files
feat!: pass common settings to SpawedJobArgsFactory; shell command arg quoting fixes (#58)
1 parent 9cc7e01 commit 867a027

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

snakemake_interface_executor_plugins/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from abc import ABC, abstractmethod
22
from typing import Mapping
33

4+
from snakemake_interface_executor_plugins.settings import CommonSettings
5+
46

57
class SpawnedJobArgsFactoryExecutorInterface(ABC):
68
@abstractmethod
79
def general_args(
810
self,
9-
pass_default_storage_provider_args: bool = True,
10-
pass_default_resources_args: bool = False,
11-
pass_group_args: bool = False,
11+
executor_common_settings: CommonSettings,
1212
) -> str:
1313
...
1414

1515
@abstractmethod
16-
def precommand(self) -> str:
16+
def precommand(self, executor_common_settings: CommonSettings) -> str:
1717
...
1818

1919
@abstractmethod

snakemake_interface_executor_plugins/executors/real.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ def get_envvar_declarations(self):
131131
defs = " ".join(
132132
f"{var}={repr(value)}" for var, value in self.envvars().items()
133133
)
134-
return f"export {defs} &&"
134+
if defs:
135+
return f"export {defs} &&"
136+
else:
137+
return ""
135138
else:
136139
return ""
137140

@@ -149,12 +152,10 @@ def format_job_exec(self, job: JobExecutorInterface) -> str:
149152
if suffix:
150153
suffix = f"&& {suffix}"
151154
general_args = self.workflow.spawned_job_args_factory.general_args(
152-
pass_default_storage_provider_args=self.common_settings.pass_default_storage_provider_args,
153-
pass_default_resources_args=self.common_settings.pass_default_resources_args,
154-
pass_group_args=self.common_settings.pass_group_args,
155+
executor_common_settings=self.common_settings
155156
)
156157
precommand = self.workflow.spawned_job_args_factory.precommand(
157-
auto_deploy_default_storage_provider=self.common_settings.auto_deploy_default_storage_provider
158+
executor_common_settings=self.common_settings
158159
)
159160
if precommand:
160161
precommand += " &&"

snakemake_interface_executor_plugins/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class CommonSettings:
4848
Number of seconds to wait before starting to check the status of spawned jobs.
4949
pass_group_args : bool
5050
Whether to pass group arguments to spawned jobs.
51+
spawned_jobs_assume_shared_fs: bool
52+
Whether spawned jobs in the executor should always assume a shared FS regardless
53+
of the user provided settings. This should be True if the executor spawns
54+
another non-local executor that runs jobs on the same node.
55+
For example, it is used in snakemake-executor-plugin-slurm-jobstep.
5156
"""
5257

5358
non_local_exec: bool
@@ -62,6 +67,7 @@ class CommonSettings:
6267
auto_deploy_default_storage_provider: bool = True
6368
init_seconds_before_status_checks: int = 0
6469
pass_group_args: bool = False
70+
spawned_jobs_assume_shared_fs: bool = False
6571

6672
@property
6773
def local_exec(self):

snakemake_interface_executor_plugins/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
from collections import UserDict
88
from pathlib import Path
9+
import shlex
910
import threading
1011
from typing import Any, List
1112
from urllib.parse import urlparse
@@ -45,7 +46,9 @@ def format_cli_value(value: Any) -> str:
4546
if isinstance(value, SettingsEnumBase):
4647
return value.item_to_choice()
4748
elif isinstance(value, Path):
48-
return str(value)
49+
return shlex.quote(str(value))
50+
elif isinstance(value, str):
51+
return shlex.quote(value)
4952
else:
5053
return repr(value)
5154

0 commit comments

Comments
 (0)