Skip to content

Commit f91133a

Browse files
fix: practical improvements
1 parent 7f54a80 commit f91133a

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ExecutorSettings:
1818
myparam: int=field(default=None, metadata={"help": "Some help text"})
1919

2020

21+
# Required:
2122
# Specify common settings shared by various executors.
2223
common_settings = CommonSettings(
2324
# define whether your executor plugin executes locally
@@ -36,32 +37,33 @@ class Executor(RemoteExecutor)
3637
self,
3738
workflow: WorkflowExecutorInterface,
3839
dag: DAGExecutorInterface,
39-
stats: StatsExecutorInterface,
4040
logger: LoggerExecutorInterface,
41-
executor_settings: Optional[ExecutorSettings], # if no ExecutorSettings are defined above, this will receive None
41+
4242
):
43-
super().__init__(
44-
workflow,
45-
dag,
46-
stats,
47-
logger,
48-
executor_settings,
49-
# configure behavior of RemoteExecutor below
50-
max_status_checks_per_second=1, # how many status checks should be performed per second
51-
disable_default_remote_provider_args=False, # whether arguments for setting the remote provider shall not be passed to jobs
52-
disable_default_resources_args=False, # whether arguments for setting default resources shall not be passed to jobs
53-
disable_envvar_declarations=False, # whether environment variables shall not be passed to jobs
54-
)
55-
# access executor specific settings
56-
self.executor_settings
57-
# access workflow
58-
self.workflow
43+
super().__init__(
44+
workflow,
45+
dag,
46+
logger,
47+
executor_settings,
48+
# configure behavior of RemoteExecutor below
49+
pass_default_remote_provider_args=True, # whether arguments for setting the remote provider shall be passed to jobs
50+
pass_default_resources_args=True, # whether arguments for setting default resources shall be passed to jobs
51+
pass_envvar_declarations_to_cmd=True, # whether environment variables shall be passed to jobs
52+
)
53+
# access executor specific settings
54+
self.executor_settings
55+
# access workflow
56+
self.workflow
57+
58+
# IMPORTANT: in your plugin, only access methods and properties of Snakemake objects (like Workflow, Persistence, etc.)
59+
# that are defined in the interfaces found in THIS package. Other parts of those objects
60+
# are NOT guaranteed to remain the same across new releases.
5961

60-
# IMPORTANT: in your plugin, only access methods and properties of Snakemake objects (like Workflow, Persistence, etc.)
61-
# that are defined in the interfaces found in THIS package. Other parts of those objects
62-
# are NOT guaranteed to remain the same across new releases.
62+
# To ensure that the used interfaces are not changing, you should depend on this package as
63+
# >=a.b.c,<d with d=a+1 (i.e. pin the dependency on this package to be at least the version at time of development
64+
# and less than the next major version which would introduce breaking changes).
6365

64-
# To ensure that the used interfaces are not changing, you should depend on this package as
65-
# >=a.b.c,<d with d=a+1 (i.e. pin the dependency on this package to be at least the version at time of development
66-
# and less than the next major version which would introduce breaking changes).
66+
async def _wait_for_jobs(self):
67+
# implement here a loop that checks which jobs are already finished
68+
6769
```

snakemake_interface_executor_plugins/executors/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
logger: LoggerExecutorInterface,
4343
pass_default_remote_provider_args: bool = True,
4444
pass_default_resources_args: bool = True,
45-
pass_envvar_declarations_to_cmd: bool = False,
45+
pass_envvar_declarations_to_cmd: bool = True,
4646
):
4747
super().__init__(
4848
workflow,

snakemake_interface_executor_plugins/registry/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ def _collect_plugins(self):
5757
):
5858
continue
5959
module = importlib.import_module(moduleinfo.name)
60-
self._register_plugin(moduleinfo.name, module)
60+
self.register_plugin(moduleinfo.name, module)
61+
62+
def register_plugin(self, name: str, plugin: types.ModuleType):
63+
"""Validate and register a plugin.
64+
65+
Does nothing if the plugin is already registered.
66+
"""
67+
if name in self.plugins:
68+
return
6169

62-
def _register_plugin(self, name: str, plugin: types.ModuleType):
63-
"""Validate and register a plugin"""
6470
self._validate_plugin(name, plugin)
6571

6672
# Derive the shortened name for future access
@@ -69,7 +75,7 @@ def _register_plugin(self, name: str, plugin: types.ModuleType):
6975
self.plugins[plugin_name] = Plugin(
7076
plugin_name,
7177
plugin.Executor,
72-
common_settings=getattr(plugin, "common_settings", None),
78+
common_settings=plugin.common_settings,
7379
_executor_settings_cls=getattr(plugin, "ExecutorSettings", None),
7480
)
7581

snakemake_interface_executor_plugins/registry/plugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def register_cli_args(self, argparser):
5959

6060
def has_executor_settings(self):
6161
"""Determine if a plugin defines custom executor settings"""
62-
return self._executor_settings_cls is not None and not isinstance(
63-
self._executor_settings_cls, ExecutorSettingsBase
64-
)
62+
return self._executor_settings_cls is not None
6563

6664
def get_executor_settings(self, args) -> ExecutorSettingsBase:
6765
"""Return an instance of self.executor_settings with values from args.

tests/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ def test_registry_get_executor_settings(registry):
3232
args = parser.parse_args([])
3333
plugin = registry.plugins["flux"]
3434
settings = plugin.get_executor_settings(args)
35+
print(settings, plugin._executor_settings_cls)
3536
assert isinstance(settings, plugin._executor_settings_cls)

0 commit comments

Comments
 (0)