Skip to content

Commit 03519b6

Browse files
committed
RF: Rename and uniformize option handling (backward-compatible)
1 parent 5cafb70 commit 03519b6

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

nipype/pipeline/plugins/dagman.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import sys
66
import uuid
7+
from warnings import warn
78

89
from .base import (GraphPluginBase, logger)
910

@@ -14,16 +15,17 @@ class CondorDAGManPlugin(GraphPluginBase):
1415
"""Execute using Condor DAGMan
1516
1617
The plugin_args input to run can be used to control the DAGMan execution.
18+
The value of any argument can be a literal string or a filename, where in
19+
the latter case the content of the file will be used as the argument value.
20+
1721
Currently supported options are:
1822
19-
- template : submit spec template for individual jobs in a DAG. All
20-
generated submit spec components (e.g. executable name and
21-
arguments) are appended to this template. This can be a str or
22-
a filename. In the latter case the file content is used as a
23-
template.
24-
- submit_specs : additional submit specs that are appended to the generated
25-
submit specs to allow for overriding or extending the defaults.
26-
This can be a str or a filename.
23+
- submit_template : submit spec template for individual jobs in a DAG (see
24+
CondorDAGManPlugin.default_submit_template for the default.
25+
- initial_specs : additional submit specs that are prepended to any job's
26+
submit file
27+
- override_specs : additional submit specs that are appended to any job's
28+
submit file
2729
- dagman_args : arguments to be prepended to the job execution script in the
2830
dagman call
2931
"""
@@ -53,23 +55,26 @@ def _get_str_or_file(self, arg):
5355
# actually have to run. would be good to be able to decide whether they
5456
# actually have to be scheduled (i.e. output already exist).
5557
def __init__(self, **kwargs):
56-
self._template = self.default_submit_template
57-
self._initial_specs = ""
58-
self._override_specs = ""
59-
self._dagman_args = ""
60-
if 'plugin_args' in kwargs and not kwargs['plugin_args'] is None:
58+
for var, id_, val in \
59+
(('_template', 'submit_template', self.default_submit_template),
60+
('_initial_specs', 'template', ''),
61+
('_initial_specs', 'initial_specs', ''),
62+
('_override_specs', 'submit_specs', ''),
63+
('_override_specs', 'override_specs', ''),
64+
('_dagman_args', 'dagman_args', '')):
65+
if 'plugin_args' in kwargs \
66+
and not kwargs['plugin_args'] is None \
67+
and id_ in kwargs['plugin_args']:
68+
val = self._get_str_or_file(kwargs['plugin_args'][id_])
69+
setattr(self, var, val)
70+
# TODO remove after some time
71+
if 'plugin_args' in kwargs \
72+
and not kwargs['plugin_args'] is None:
6173
plugin_args = kwargs['plugin_args']
6274
if 'template' in plugin_args:
63-
self._template = \
64-
self._get_str_or_file(plugin_args['template'])
65-
if 'initial_specs' in plugin_args:
66-
self._initial_specs = \
67-
self._get_str_or_file(plugin_args['initial_specs'])
68-
if 'override_specs' in plugin_args:
69-
self._override_specs = \
70-
self._get_str_or_file(plugin_args['override_specs'])
71-
if 'dagman_args' in plugin_args:
72-
self._dagman_args = plugin_args['dagman_args']
75+
warn("the 'template' argument is deprecated, use 'initial_specs' instead")
76+
if 'submit_specs' in plugin_args:
77+
warn("the 'submit_specs' argument is deprecated, use 'override_specs' instead")
7378
super(CondorDAGManPlugin, self).__init__(**kwargs)
7479

7580
def _submit_graph(self, pyfiles, dependencies, nodes):

0 commit comments

Comments
 (0)