Skip to content

Commit 70f4f7f

Browse files
committed
Merge pull request #1401 from satra/fix/jobexecute_log
FIX: job execution on systems/approaches where locale is undefined
2 parents cb207f8 + 4cf5a25 commit 70f4f7f

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Next release
22
============
33

4+
* FIX: job execution on systems/approaches where locale is undefined (https://github.com/nipy/nipype/pull/1401)
45
* FIX: Clean up byte/unicode issues using subprocess (https://github.com/nipy/nipype/pull/1394)
56
* FIX: Prevent crash when tvtk is loaded - ETS_TOOLKIT=null (https://github.com/nipy/nipype/pull/973)
67
* ENH: New interfaces in dipy: RESTORE, EstimateResponseSH, CSD and StreamlineTractography

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies:
2929
- pip install -e git+https://github.com/enthought/etsproxy.git#egg=etsproxy
3030
- pip install -e git+https://github.com/enthought/ets.git#egg=ets
3131
- gem install fakes3
32-
- if [[ ! -d ~/examples/data ]]; then wget "http://tcpdiag.dl.sourceforge.net/project/nipy/nipype/nipype-0.2/nipype-tutorial.tar.bz2" && tar jxvf nipype-tutorial.tar.bz2 && mv nipype-tutorial/* ~/examples/; fi
32+
- if [[ ! -d ~/examples/data ]]; then wget "https://dl.dropbox.com/s/jzgq2nupxyz36bp/nipype-tutorial.tar.bz2" && tar jxvf nipype-tutorial.tar.bz2 && mv nipype-tutorial/* ~/examples/; fi
3333
- if [[ ! -d ~/examples/fsl_course_data ]]; then wget -c "http://fsl.fmrib.ox.ac.uk/fslcourse/fdt1.tar.gz" && wget -c "http://fsl.fmrib.ox.ac.uk/fslcourse/fdt2.tar.gz" && wget -c "http://fsl.fmrib.ox.ac.uk/fslcourse/tbss.tar.gz" && mkdir ~/examples/fsl_course_data && tar zxvf fdt1.tar.gz -C ~/examples/fsl_course_data && tar zxvf fdt2.tar.gz -C ~/examples/fsl_course_data && tar zxvf tbss.tar.gz -C ~/examples/fsl_course_data; fi
3434
- bash ~/nipype/tools/install_spm_mcr.sh
3535
- mkdir -p ~/.nipype && echo '[logging]' > ~/.nipype/nipype.cfg && echo 'workflow_level = DEBUG' >> ~/.nipype/nipype.cfg && echo 'interface_level = DEBUG' >> ~/.nipype/nipype.cfg && echo 'filemanip_level = DEBUG' >> ~/.nipype/nipype.cfg

doc/documentation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Documentation
99
:Release: |version|
1010
:Date: |today|
1111

12-
Previous versions: `0.10.0 <http://nipy.org/nipype/0.10.0>`_ `0.9.2 <http://nipy.org/nipype/0.9.2>`_
12+
Previous versions: `0.11.0 <http://nipy.org/nipype/0.11.0>`_ `0.10.0 <http://nipy.org/nipype/0.10.0>`_
1313

1414
.. container:: doc2
1515

doc/users/pipeline_tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Step 0
6363
~~~~~~
6464

6565
Download and extract the `Pipeline tutorial data (429MB).
66-
<http://sourceforge.net/projects/nipy/files/nipype/nipype-0.2/nipype-tutorial.tar.bz2/download>`_
66+
<https://dl.dropbox.com/s/jzgq2nupxyz36bp/nipype-tutorial.tar.bz2>`_
6767

6868
(checksum: 56ed4b7e0aac5627d1724e9c10cd26a7)
6969

nipype/interfaces/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,9 @@ def __init__(self, name, impl):
11501150
self._buf = ''
11511151
self._rows = []
11521152
self._lastidx = 0
1153+
self.default_encoding = locale.getdefaultlocale()[1]
1154+
if self.default_encoding is None:
1155+
self.default_encoding = 'UTF-8'
11531156

11541157
def fileno(self):
11551158
"Pass-through for file descriptor."
@@ -1164,7 +1167,7 @@ def read(self, drain=0):
11641167
def _read(self, drain):
11651168
"Read from the file descriptor"
11661169
fd = self.fileno()
1167-
buf = os.read(fd, 4096).decode()
1170+
buf = os.read(fd, 4096).decode(self.default_encoding)
11681171
if not buf and not self._buf:
11691172
return None
11701173
if '\n' not in buf:
@@ -1203,6 +1206,9 @@ def run_command(runtime, output=None, timeout=0.01, redirect_x=False):
12031206
raise RuntimeError('Xvfb was not found, X redirection aborted')
12041207
cmdline = 'xvfb-run -a ' + cmdline
12051208

1209+
default_encoding = locale.getdefaultlocale()[1]
1210+
if default_encoding is None:
1211+
default_encoding = 'UTF-8'
12061212
if output == 'file':
12071213
errfile = os.path.join(runtime.cwd, 'stderr.nipype')
12081214
outfile = os.path.join(runtime.cwd, 'stdout.nipype')
@@ -1257,17 +1263,17 @@ def _process(drain=0):
12571263
result['merged'] = [r[1] for r in temp]
12581264
if output == 'allatonce':
12591265
stdout, stderr = proc.communicate()
1260-
stdout = stdout.decode(locale.getdefaultlocale()[1])
1261-
stderr = stderr.decode(locale.getdefaultlocale()[1])
1266+
stdout = stdout.decode(default_encoding)
1267+
stderr = stderr.decode(default_encoding)
12621268
result['stdout'] = stdout.split('\n')
12631269
result['stderr'] = stderr.split('\n')
12641270
result['merged'] = ''
12651271
if output == 'file':
12661272
ret_code = proc.wait()
12671273
stderr.flush()
12681274
stdout.flush()
1269-
result['stdout'] = [line.decode(locale.getdefaultlocale()[1]).strip() for line in open(outfile, 'rb').readlines()]
1270-
result['stderr'] = [line.decode(locale.getdefaultlocale()[1]).strip() for line in open(errfile, 'rb').readlines()]
1275+
result['stdout'] = [line.decode(default_encoding).strip() for line in open(outfile, 'rb').readlines()]
1276+
result['stderr'] = [line.decode(default_encoding).strip() for line in open(errfile, 'rb').readlines()]
12711277
result['merged'] = ''
12721278
if output == 'none':
12731279
proc.communicate()

nipype/pipeline/plugins/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
363363
self.proc_done[jobid] = True
364364
self.proc_pending[jobid] = True
365365
# Send job to task manager and add to pending tasks
366-
logger.info('Executing: %s ID: %d' %
366+
logger.info('Submitting: %s ID: %d' %
367367
(self.procs[jobid]._id, jobid))
368368
if self._status_callback:
369369
self._status_callback(self.procs[jobid], 'start')
@@ -405,7 +405,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
405405
self.proc_pending[jobid] = False
406406
else:
407407
self.pending_tasks.insert(0, (tid, jobid))
408-
logger.info('Finished executing: %s ID: %d' %
408+
logger.info('Finished submitting: %s ID: %d' %
409409
(self.procs[jobid]._id, jobid))
410410
else:
411411
break

nipype/pipeline/plugins/pbs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .base import (SGELikeBatchManagerBase, logger, iflogger, logging)
99

10-
from nipype.interfaces.base import CommandLine
10+
from ...interfaces.base import CommandLine, text_type
1111

1212

1313
class PBSPlugin(SGELikeBatchManagerBase):
@@ -97,7 +97,7 @@ def _submit_batchtask(self, scriptfile, node):
9797
iflogger.setLevel(oldlevel)
9898
raise RuntimeError('\n'.join((('Could not submit pbs task'
9999
' for node %s') % node._id,
100-
str(e))))
100+
text_type(e))))
101101
else:
102102
break
103103
iflogger.setLevel(oldlevel)

0 commit comments

Comments
 (0)