Skip to content

Commit 2e02a8a

Browse files
satraeffigies
authored andcommitted
fix: improve version checking for nodes of workflows
1 parent 39012c5 commit 2e02a8a

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

nipype/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
import os
1515
from distutils.version import LooseVersion
1616

17-
from .info import (
18-
URL as __url__,
19-
STATUS as __status__,
20-
__version__,
21-
)
17+
from .info import URL as __url__, STATUS as __status__, __version__
2218
from .utils.config import NipypeConfig
2319
from .utils.logger import Logging
2420
from .refs import due
@@ -105,6 +101,8 @@ def check_latest_version(raise_exception=False):
105101
packname="nipype", version=__version__, latest=latest["version"]
106102
)
107103
)
104+
else:
105+
logger.info("No new version available.")
108106
if latest["bad_versions"] and any(
109107
[
110108
LooseVersion(__version__) == LooseVersion(ver)

nipype/pipeline/plugins/multiproc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Import packages
1111
import os
1212
import multiprocessing as mp
13-
from concurrent.futures import ProcessPoolExecutor
13+
from concurrent.futures import ProcessPoolExecutor, wait
1414
from traceback import format_exception
1515
import sys
1616
from logging import INFO
@@ -73,6 +73,12 @@ def run_node(node, updatehash, taskid):
7373
return result
7474

7575

76+
def process_initializer(cwd):
77+
"""Initializes the environment of the child process"""
78+
os.chdir(cwd)
79+
os.environ["NO_ET"] = "1"
80+
81+
7682
class MultiProcPlugin(DistributedPluginBase):
7783
"""
7884
Execute workflow with multiprocessing, not sending more jobs at once
@@ -137,13 +143,15 @@ def __init__(self, plugin_args=None):
137143
mp_context = mp.context.get_context(self.plugin_args.get("mp_context"))
138144
self.pool = ProcessPoolExecutor(
139145
max_workers=self.processors,
140-
initializer=os.chdir,
146+
initializer=process_initializer,
141147
initargs=(self._cwd,),
142148
mp_context=mp_context,
143149
)
144150
except (AttributeError, TypeError):
145151
# Python < 3.7 does not support initialization or contexts
146152
self.pool = ProcessPoolExecutor(max_workers=self.processors)
153+
result_future = self.pool.submit(process_initializer, self._cwd)
154+
wait(result_future, timeout=5)
147155

148156
self._stats = None
149157

nipype/pipeline/plugins/tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ def create_pyscript(node, updatehash=False, store_exception=True):
125125
can_import_matplotlib = False
126126
pass
127127
128+
import os
129+
os.environ['NO_ET'] = "1"
130+
128131
from nipype import config, logging
129132
from nipype.utils.filemanip import loadpkl, savepkl
130133
from socket import gethostname

0 commit comments

Comments
 (0)