Skip to content

[ENH] Refactor VTK and tvtk -based interfaces #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 80 commits into from
Feb 22, 2016
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
420fa76
Added ets.toolkit configuration to initialization
oesteban Oct 21, 2014
559e698
remove ets.toolkit config in mesh (#972)
oesteban Oct 21, 2014
1f9372f
Merge branch 'master' into enh/ETSConfigTookit
oesteban Feb 23, 2015
545f8c5
Merge branch 'master' into enh/ETSConfigTookit
oesteban Mar 3, 2015
1231a5e
add new import under traits as failback for enthougth
oesteban Mar 3, 2015
dda44ba
Merge branch 'master' into enh/ETSConfigTookit
oesteban Apr 9, 2015
a72fd34
remove error, add config to docs
oesteban Apr 9, 2015
d53ab22
setting ETS_TOOLKIT
oesteban Sep 16, 2015
485c44d
insert here new TVTKBaseInterface
oesteban Sep 18, 2015
bfb0002
Merge branch 'fix/TVTKPolyDataWriter' into enh/ETSConfigTookit
oesteban Sep 18, 2015
21b86ac
ETS_TOOLKIT settings in algorithms.mesh
oesteban Sep 18, 2015
e144fd2
Merge branch 'fix/TVTKPolyDataWriter' into enh/ETSConfigTookit
oesteban Sep 18, 2015
90f27bd
search all tvtk imports and fix ETS_TOOLKIT
oesteban Sep 18, 2015
f8f2bed
Merge branch 'master' into enh/ETSConfigTookit
oesteban Nov 18, 2015
f79aaad
Merge branch 'master' into enh/ETSConfigTookit
oesteban Dec 14, 2015
6416e5b
add autotest file for TVTKBaseInterface
oesteban Dec 14, 2015
befd2db
Merge branch 'master' into enh/ETSConfigTookit
oesteban Dec 15, 2015
a0f4a7e
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 25, 2016
c6bb4e3
removed NotImplementedError in method with implementation
oesteban Jan 25, 2016
fa93796
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 27, 2016
b757cf8
improved code quality, added comments
oesteban Jan 27, 2016
a3bad0a
added dependencies to testing frameworks
oesteban Jan 27, 2016
df17a3d
added neurodebian in all travis builds
oesteban Jan 27, 2016
b9287f4
added dependency (Pillow) and fixed numpy installation
oesteban Jan 27, 2016
30b0323
fixed numpy installation -> moved from circle to travis
oesteban Jan 27, 2016
9ce6bce
replaced Pillow by PIL
oesteban Jan 27, 2016
4ee2119
added PIL from url
oesteban Jan 27, 2016
2416371
added PIL from url also for circle
oesteban Jan 27, 2016
fa6e263
fixed PIL installation
oesteban Jan 27, 2016
02ea69b
added missing etsproxy
oesteban Jan 27, 2016
70036b4
added python-vtk
oesteban Jan 27, 2016
a52e3d9
fixed vtk installation in travis
oesteban Jan 27, 2016
9a6728e
fixed mayavi in travis and python-vtk in circle
oesteban Jan 27, 2016
db3ac3e
added xvfbwrapper requirement, fixing vtk in ci
oesteban Jan 27, 2016
92d98bc
fixed syntax error in travis file
oesteban Jan 27, 2016
ffd1d40
fixed errors, added conditional doctest
oesteban Jan 27, 2016
cbea5b0
fixing travis for python 3.0, minor in circle
oesteban Jan 27, 2016
db08c4f
updated doctests for the case vtk is not installed (typically python …
oesteban Jan 27, 2016
7c7b719
fixed doctests
oesteban Jan 28, 2016
8938187
removed doctests, added exception testing when vtk is unavailable
oesteban Jan 28, 2016
b68c66a
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 28, 2016
a9c039e
fixed mesh tests
oesteban Jan 28, 2016
6b08b02
added base for two regression tests
oesteban Jan 28, 2016
602dea4
Merge branch 'fix/CircleCI/FslFeeds' into enh/ETSConfigTookit
oesteban Jan 28, 2016
5760a0e
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 28, 2016
c738be6
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 28, 2016
a94158b
added xvfbwrapper to requirements, improved vtk handling
oesteban Jan 28, 2016
8baba45
improved VTK version parsing
oesteban Jan 28, 2016
5396852
Merge branch 'master' into enh/ETSConfigTookit
oesteban Jan 28, 2016
9339e5f
encapsulated VTK Info in class
oesteban Jan 29, 2016
b7ba47f
use tvtk appropriate tools whenever possible
oesteban Jan 29, 2016
9cafde5
refactored vtk/tvtk use and ETSConfigToolkit
oesteban Jan 29, 2016
774906a
Merge branch 'master' into enh/ETSConfigTookit
oesteban Feb 1, 2016
90ad893
fixed outdated code based on xvfbwrapper
oesteban Feb 1, 2016
0dbe8bb
Merge branch 'master' into enh/ETSConfigTookit
oesteban Feb 1, 2016
1ce6850
fixing lint problems
oesteban Feb 2, 2016
01bd281
fixing output_spec is not callable
oesteban Feb 3, 2016
edf906e
revert codacy fixes
oesteban Feb 4, 2016
7e12be8
Merge branch 'master' into enh/ETSConfigTookit
oesteban Feb 4, 2016
69cf3aa
Merge branch 'master' into enh/ETSConfigTookit
oesteban Feb 5, 2016
94eeea2
update travis
Feb 10, 2016
a6ec41e
remove empty line before docstring
Feb 10, 2016
a17422e
add multiverse for ubuntu
Feb 10, 2016
c9968ae
travis set to pin libvtk6-dev from trusty
Feb 10, 2016
807708b
fix error in travis
Feb 10, 2016
39b84f7
fix error in travis
Feb 10, 2016
f809b41
trying to fix travis
Feb 10, 2016
76e64cc
add trusty-updates-
Feb 10, 2016
bf8192d
still fixing VTK6 installation in travis
Feb 10, 2016
5843591
fixed command as sudo
Feb 10, 2016
b9e051d
use ubuntu trusty
Feb 10, 2016
62a23e2
modify the neurodebian script for travis
Feb 10, 2016
664a839
remove ubuntu pinning
Feb 10, 2016
4a778c8
remove python-vtk from travis
Feb 11, 2016
3cd40e1
Merge branch 'master' into enh/ETSConfigTookit
Feb 11, 2016
0087bd9
added disable flag in codacy errors
Feb 11, 2016
a2e52ee
revert back travis
Feb 12, 2016
618fb23
Merge branch 'master' into enh/ETSConfigTookit
Feb 12, 2016
2448821
add disable flag for codacy
Feb 12, 2016
3c75d63
Merge branch 'master' into enh/ETSConfigTookit
Feb 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions nipype/algorithms/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ def _run_interface(self, runtime):
except ImportError:
raise ImportError('Interface P2PDistance requires tvtk')

try:
from enthought.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'null'
except ImportError:
iflogger.warn(('ETS toolkit could not be imported'))
pass

r1 = tvtk.PolyDataReader(file_name=self.inputs.surface1)
r2 = tvtk.PolyDataReader(file_name=self.inputs.surface2)
vtk1 = r1.output
Expand Down
29 changes: 28 additions & 1 deletion nipype/pipeline/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,40 @@ def create_pyscript(node, updatehash=False, store_exception=True):
pkl_file = os.path.join(batch_dir, 'node_%s.pklz' % suffix)
savepkl(pkl_file, dict(node=node, updatehash=updatehash))
mpl_backend = node.config["execution"]["matplotlib_backend"]
ets_toolkit = node.config["execution"]["ets_toolkit"]
# create python script to load and trap exception
cmdstr = """import os
import sys

can_import_matplotlib = True #Silently allow matplotlib to be ignored
can_import_ets = False #Silently allow ets to be ignored
try:
import matplotlib
matplotlib.use('%s')
except ImportError:
can_import_matplotlib = False
pass
except
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's with this lone "except"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ugly :( (deleting...).

Thanks for spotting it :)


try:
from enthought.etsconfig.api import ETSConfig
can_import_ets = True
except ImportError:
pass

if not can_import_ets:
try:
from traits.etsconfig.etsconfig import ETSConfig
can_import_ets = True
except ImportError:
pass

if can_import_ets:
try:
ETSConfig.toolkit = '%s'
except ValueError:
pass


from nipype import config, logging
from nipype.utils.filemanip import loadpkl, savepkl
Expand All @@ -134,9 +157,12 @@ def create_pyscript(node, updatehash=False, store_exception=True):
from collections import OrderedDict
config_dict=%s
config.update_config(config_dict)

## Only configure matplotlib if it was successfully imported, matplotlib is an optional component to nipype
if can_import_matplotlib:
config.update_matplotlib()
if can_import_ets:
config.update_ets()
logging.update_logging(config)
traceback=None
cwd = os.getcwd()
Expand Down Expand Up @@ -168,7 +194,8 @@ def create_pyscript(node, updatehash=False, store_exception=True):
report_crash(info['node'], traceback, gethostname())
raise Exception(e)
"""
cmdstr = cmdstr % (mpl_backend, pkl_file, batch_dir, node.config, suffix)
cmdstr = cmdstr % (mpl_backend, ets_toolkit, pkl_file,
batch_dir, node.config, suffix)
pyscript = os.path.join(batch_dir, 'pyscript_%s.py' % suffix)
fp = open(pyscript, 'wt')
fp.writelines(cmdstr)
Expand Down
23 changes: 23 additions & 0 deletions nipype/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
keep_inputs = false
local_hash_check = true
matplotlib_backend = Agg
ets_toolkit = null
plugin = Linear
remove_node_directories = false
remove_unnecessary_outputs = true
Expand All @@ -54,6 +55,7 @@
interval = 1209600
""" % (homedir, os.getcwd())


class NipypeConfig(object):
"""Base nipype config class
"""
Expand Down Expand Up @@ -151,6 +153,27 @@ def update_matplotlib(self):
import matplotlib
matplotlib.use(self.get('execution', 'matplotlib_backend'))

def update_ets(self):
can_import_ets = False
try:
from enthought.etsconfig.api import ETSConfig
can_import_ets = True
except ImportError:
pass

if not can_import_ets:
try:
from traits.etsconfig.etsconfig import ETSConfig
can_import_ets = True
except ImportError:
pass

if can_import_ets:
try:
ETSConfig.toolkit = '%s'
except ValueError:
pass

def enable_provenance(self):
self._config.set('execution', 'write_provenance', 'true')
self._config.set('execution', 'hash_method', 'content')
Expand Down