Skip to content

Commit 2a0eb6d

Browse files
committed
Merge branch 'effigies-fix/Plugin-absolute-import' into fix/Plugin-absolute-import
2 parents 2e545a3 + 63185c8 commit 2a0eb6d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

nipype/pipeline/engine/workflows.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
from .base import EngineBase
5959
from .nodes import Node, MapNode
60-
from .. import plugins
6160

6261
package_check('networkx', '1.3')
6362
logger = logging.getLogger('workflow')
@@ -558,8 +557,16 @@ def run(self, plugin=None, plugin_args=None, updatehash=False):
558557
if not isinstance(plugin, (str, bytes)):
559558
runner = plugin
560559
else:
561-
SelectedPlugin = getattr(plugins, '%sPlugin' % plugin)
562-
runner = SelectedPlugin(plugin_args=plugin_args)
560+
name = '.'.join(__name__.split('.')[:-2] + ['plugins'])
561+
try:
562+
__import__(name)
563+
except ImportError:
564+
msg = 'Could not import plugin module: %s' % name
565+
logger.error(msg)
566+
raise ImportError(msg)
567+
else:
568+
plugin_mod = getattr(sys.modules[name], '%sPlugin' % plugin)
569+
runner = plugin_mod(plugin_args=plugin_args)
563570
flatgraph = self._create_flat_graph()
564571
self.config = merge_dict(deepcopy(config._sections), self.config)
565572
if 'crashdump_dir' in self.config:

0 commit comments

Comments
 (0)