-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsettings.py
More file actions
189 lines (153 loc) · 5.83 KB
/
settings.py
File metadata and controls
189 lines (153 loc) · 5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Sequence, Set
from snakemake_interface_common.settings import SettingsEnumBase, TSettingsEnumBase
import snakemake_interface_common.plugin_registry.plugin
@dataclass
class CommonSettings:
"""Common Snakemake settings shared between executors that can be specified
by executor plugins.
The plugin has to specify an instance of this class as the value of the
common_settings attribute.
Attributes
----------
non_local_exec : bool
Whether to execute jobs locally or on a cluster.
implies_no_shared_fs : bool
Whether the executor implies to not have a shared file system.
dryrun_exec : bool
Whether jobs will be executed in dry-run mode.
job_deploy_sources : bool
Whether to deploy workflow sources before job execution. This is e.g.
needed when remote jobs are guaranteed to be not executed on a shared
filesystem. For example, this is True in the kubernetes executor plugin.
touch_exec : bool
Whether job outputs will be touched only.
use_threads : bool
Whether to use threads instead of processes.
pass_default_storage_provider_args : bool
Whether to pass default storage provider arguments to spawned jobs.
pass_default_resources_args : bool
Whether to pass default resources arguments to spawned jobs.
pass_envvar_declarations_to_cmd : bool
Whether envvars shall be declared in the job command. If false, envvars
have to be declared in a different way by the executor, e.g. by passing
them as secrets (see snakemake-executor-plugin-kubernetes).
auto_deploy_default_storage_provider : bool
Whether to automatically deploy the default storage provider in the spawned
job via pip. This is usually needed in case the executor does not have a
shared file system.
init_seconds_before_status_checks : int
Number of seconds to wait before starting to check the status of spawned jobs.
pass_group_args : bool
Whether to pass group arguments to spawned jobs.
spawned_jobs_assume_shared_fs: bool
Whether spawned jobs in the executor should always assume a shared FS regardless
of the user provided settings. This should be True if the executor spawns
another non-local executor that runs jobs on the same node.
For example, it is used in snakemake-executor-plugin-slurm-jobstep.
can_transfer_local_files: bool
Indicates whether the plugin can transfer local files to the remote executor when
run without a shared FS. If true, it's the plugin's responsibility and not
Snakemake's to manage file transfers.
"""
non_local_exec: bool
implies_no_shared_fs: bool
job_deploy_sources: bool
dryrun_exec: bool = False
touch_exec: bool = False
use_threads: bool = False
pass_default_storage_provider_args: bool = True
pass_default_resources_args: bool = True
pass_envvar_declarations_to_cmd: bool = True
auto_deploy_default_storage_provider: bool = True
init_seconds_before_status_checks: int = 0
pass_group_args: bool = False
spawned_jobs_assume_shared_fs: bool = False
can_transfer_local_files: bool = False
@property
def local_exec(self):
return not self.non_local_exec
@dataclass
class ExecutorSettingsBase(
snakemake_interface_common.plugin_registry.plugin.SettingsBase
):
"""Base class for executor settings.
Executor plugins can define a subclass of this class,
named 'ExecutorSettings'.
"""
pass
class RemoteExecutionSettingsExecutorInterface(ABC):
@property
@abstractmethod
def jobname(self) -> str: ...
@property
@abstractmethod
def jobscript(self) -> str: ...
@property
@abstractmethod
def immediate_submit(self) -> bool: ...
@property
@abstractmethod
def envvars(self) -> Sequence[str]: ...
@property
@abstractmethod
def max_status_checks_per_second(self) -> float: ...
@property
@abstractmethod
def seconds_between_status_checks(self) -> int: ...
class ExecMode(SettingsEnumBase):
"""
Enum for execution mode of Snakemake.
This handles the behavior of e.g. the logger.
"""
DEFAULT = 0
SUBPROCESS = 1
REMOTE = 2
class ExecutionSettingsExecutorInterface(ABC):
@property
@abstractmethod
def keep_incomplete(self) -> bool: ...
class SharedFSUsage(SettingsEnumBase):
PERSISTENCE = 0
INPUT_OUTPUT = 1
SOFTWARE_DEPLOYMENT = 2
SOURCES = 3
STORAGE_LOCAL_COPIES = 4
SOURCE_CACHE = 5
SOFTWARE_DEPLOYMENT_CACHE = 6
@classmethod
def choices(cls) -> List[str]:
return super().choices() + ["none"]
@classmethod
def _parse_choices_into(cls, choices: str, container) -> List[TSettingsEnumBase]:
if "none" in choices:
if len(choices) > 1:
raise ValueError(
"Cannot specify 'none' together with other shared filesystem usages."
)
return container([])
else:
return container(cls.parse_choice(choice) for choice in choices)
class StorageSettingsExecutorInterface(ABC):
@property
@abstractmethod
def shared_fs_usage(self) -> Set[SharedFSUsage]: ...
@property
def assume_common_workdir(self) -> bool:
return any(
usage in self.shared_fs_usage
for usage in (
SharedFSUsage.PERSISTENCE,
SharedFSUsage.INPUT_OUTPUT,
SharedFSUsage.SOFTWARE_DEPLOYMENT,
)
)
class DeploymentSettingsExecutorInterface(ABC):
@property
@abstractmethod
def deployment_method(self) -> Set[str]: ...
class GroupSettingsExecutorInterface(ABC):
@property
@abstractmethod
def local_groupid(self) -> str: ...