Repository: zeppelin Updated Branches: refs/heads/master f238ca0e3 -> 89e2e0246
[ZEPPELIN-2827] Spark's pyspark fails if unsupported version of matplotlib is present ### What is this PR for? %spark.pyspark paragraphs keep running for more than > 5 minutes and then at the end, throw TTransportException. ``` org.apache.thrift.transport.TTransportException at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132) at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86) at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429) at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318) at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219) at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69) ``` This happens because Zeppelin refers to `matplotlib.rcParams['savefig.format']` https://github.com/apache/zeppelin/blob/master/interpreter/lib/python/mpl_config.py#L83 which is only present in matplotlib 1.2.0 (https://github.com/matplotlib/matplotlib/blob/v1.2.0/matplotlibrc.template#L355) and onwards. ### What type of PR is it? [Bug Fix] ### What is the Jira issue? * [ZEPPELIN-2827](https://issues.apache.org/jira/browse/ZEPPELIN-2827) ### How should this be tested? Try running spark.pyspark on a machine with matplotlib==1.1.1 installed, pyspark should work as expected. ### Questions: * Does the licenses files need update? N/A * Is there breaking changes for older versions? N/A * Does this needs documentation? N/A Author: Prabhjyot Singh <prabhjyotsi...@gmail.com> Closes #2516 from prabhjyotsingh/ZEPPELIN-2827 and squashes the following commits: 0321fcd3e [Prabhjyot Singh] check if `savefig.format` exists in mpl_config.py da26f5613 [Prabhjyot Singh] add a version check along with check if matplotlib is installed Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/89e2e024 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/89e2e024 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/89e2e024 Branch: refs/heads/master Commit: 89e2e0246c79b84d9cce73ac88727c29e37439f3 Parents: f238ca0 Author: Prabhjyot Singh <prabhjyotsi...@gmail.com> Authored: Thu Aug 3 22:48:40 2017 -0700 Committer: Prabhjyot Singh <prabhjyotsi...@gmail.com> Committed: Tue Aug 8 11:38:18 2017 -0700 ---------------------------------------------------------------------- interpreter/lib/python/mpl_config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/89e2e024/interpreter/lib/python/mpl_config.py ---------------------------------------------------------------------- diff --git a/interpreter/lib/python/mpl_config.py b/interpreter/lib/python/mpl_config.py index e48678f..5c60893 100644 --- a/interpreter/lib/python/mpl_config.py +++ b/interpreter/lib/python/mpl_config.py @@ -71,7 +71,11 @@ def _on_config_change(): supported_formats = _config['supported_formats'] if fmt not in supported_formats: raise ValueError("Unsupported format %s" %fmt) - matplotlib.rcParams['savefig.format'] = fmt + + if matplotlib.__version__ < '1.2.0': + matplotlib.rcParams.update({'savefig.format': fmt}) + else: + matplotlib.rcParams['savefig.format'] = fmt # Interactive mode interactive = _config['interactive'] @@ -80,6 +84,8 @@ def _on_config_change(): def _init_config(): dpi = matplotlib.rcParams['figure.dpi'] + if matplotlib.__version__ < '1.2.0': + matplotlib.rcParams.update({'savefig.format': 'png'}) fmt = matplotlib.rcParams['savefig.format'] width, height = matplotlib.rcParams['figure.figsize'] fontsize = matplotlib.rcParams['font.size']