Skip to content

Commit f7b463d

Browse files
committed
Attempt to set backend in local matplotlib
1 parent 3c779c1 commit f7b463d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nipype/pipeline/plugins/base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ..utils import (nx, dfs_preorder)
2121
from ..engine import (MapNode, str2bool)
2222

23+
import nipype
2324
from nipype.utils.filemanip import savepkl, loadpkl
2425
from nipype.interfaces.utility import Function
2526

@@ -90,6 +91,13 @@ def report_nodes_not_run(notrun):
9091
'Check log for details'))
9192

9293

94+
def write_matplotlibrc(batch_dir):
95+
"""Set the matplotlib backend in a local rc file."""
96+
backend = nipype.config.get("execution", "matplotlib_backend")
97+
with open(os.path.join(batch_dir, "matplotlibrc"), "w") as fid:
98+
fid.write("backend : %s" % backend)
99+
100+
93101
def create_pyscript(node, updatehash=False, store_exception=True):
94102
# pickle node
95103
timestamp = strftime('%Y%m%d_%H%M%S')
@@ -103,6 +111,7 @@ def create_pyscript(node, updatehash=False, store_exception=True):
103111
batch_dir = os.path.join(node.base_dir, 'batch')
104112
if not os.path.exists(batch_dir):
105113
os.makedirs(batch_dir)
114+
write_matplotlibrc(batch_dir)
106115
pkl_file = os.path.join(batch_dir, 'node_%s.pklz' % suffix)
107116
savepkl(pkl_file, dict(node=node, updatehash=updatehash))
108117
# create python script to load and trap exception

0 commit comments

Comments
 (0)