This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new aae3114  [ZEPPELIN-4771]. Bokeh output in IPythonInterpreter is not in 
correct format
aae3114 is described below

commit aae3114bd7f1b50ad274300723248b9ce984034d
Author: Jeff Zhang <zjf...@apache.org>
AuthorDate: Thu Apr 23 11:32:14 2020 +0800

    [ZEPPELIN-4771]. Bokeh output in IPythonInterpreter is not in correct format
    
    ### What is this PR for?
    
    Without this PR, the bokeh output will is not in correct format (see below 
screenshot). This root cause is the output type is not correct. We should only 
use html when it is ir kernel for jupyter interpreter.
    
    ### What type of PR is it?
    [Bug Fix ]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-4771
    
    ### How should this be tested?
    * CI pass
    
    ### Screenshots (if appropriate)
    Before
    
![image](https://user-images.githubusercontent.com/164491/80295130-b76c4800-87a2-11ea-8cb2-f7d213d6b714.png)
    
    After
    
![image](https://user-images.githubusercontent.com/164491/80295171-2cd81880-87a3-11ea-9a80-bffffc4accc0.png)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Jeff Zhang <zjf...@apache.org>
    
    Closes #3750 from zjffdu/ZEPPELIN-4771 and squashes the following commits:
    
    da6578e0e [Jeff Zhang] [ZEPPELIN-4771]. Bokeh output in IPythonInterpreter 
is not in correct format
    
    (cherry picked from commit 0a27eee0b9565c735ef94cfc1196f0b1a8928816)
    Signed-off-by: Jeff Zhang <zjf...@apache.org>
---
 .../apache/zeppelin/python/IPythonInterpreter.java    |  2 +-
 .../java/org/apache/zeppelin/r/IRInterpreter.java     |  2 +-
 .../apache/zeppelin/jupyter/JupyterKernelClient.java  | 19 +++++++++++--------
 .../zeppelin/jupyter/JupyterKernelInterpreter.java    |  2 +-
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java 
b/python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java
index c5527fe..8cd7fba 100644
--- a/python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java
+++ b/python/src/main/java/org/apache/zeppelin/python/IPythonInterpreter.java
@@ -57,7 +57,7 @@ public class IPythonInterpreter extends 
JupyterKernelInterpreter {
   private String py4jGatewaySecret;
 
   public IPythonInterpreter(Properties properties) {
-    super(properties);
+    super("python", properties);
   }
 
   @Override
diff --git a/rlang/src/main/java/org/apache/zeppelin/r/IRInterpreter.java 
b/rlang/src/main/java/org/apache/zeppelin/r/IRInterpreter.java
index 24305d6..f232d7e 100644
--- a/rlang/src/main/java/org/apache/zeppelin/r/IRInterpreter.java
+++ b/rlang/src/main/java/org/apache/zeppelin/r/IRInterpreter.java
@@ -54,7 +54,7 @@ public class IRInterpreter extends JupyterKernelInterpreter {
   private SparkRBackend sparkRBackend;
 
   public IRInterpreter(Properties properties) {
-    super(properties);
+    super("ir", properties);
   }
 
   /**
diff --git 
a/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelClient.java
 
b/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelClient.java
index 3d18df1..1065c41 100644
--- 
a/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelClient.java
+++ 
b/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelClient.java
@@ -41,7 +41,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.security.SecureRandom;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
@@ -66,24 +65,27 @@ public class JupyterKernelClient {
 
   private Properties properties;
   private InterpreterContext context;
-  private SecureRandom random = new SecureRandom();
+  private String kernel;
 
   /**
    * Construct client for accessing RouteGuide server at {@code host:port}.
    */
-  public JupyterKernelClient(String host,
-                             int port) {
-    this(ManagedChannelBuilder.forAddress(host, port).usePlaintext(true), new 
Properties());
+  public JupyterKernelClient(String host, int port, String kernel) {
+    this(ManagedChannelBuilder.forAddress(host, port).usePlaintext(true), new 
Properties(),
+            kernel);
   }
 
   /**
    * Construct client for accessing RouteGuide server using the existing 
channel.
    */
-  public JupyterKernelClient(ManagedChannelBuilder<?> channelBuilder, 
Properties properties) {
+  public JupyterKernelClient(ManagedChannelBuilder<?> channelBuilder,
+                             Properties properties,
+                             String kernel) {
     channel = channelBuilder.build();
     blockingStub = JupyterKernelGrpc.newBlockingStub(channel);
     asyncStub = JupyterKernelGrpc.newStub(channel);
     this.properties = properties;
+    this.kernel = kernel;
   }
 
   public void shutdown() throws InterruptedException {
@@ -170,7 +172,8 @@ public class JupyterKernelClient {
                 }
                 // explicitly use html output for ir kernel in some cases. 
otherwise some
                 // R packages doesn't work. e.g. googlevis
-                if (executeResponse.getOutput().contains("<script 
type=\"text/javascript\">")) {
+                if (kernel.equals("ir") && executeResponse.getOutput()
+                        .contains("<script type=\"text/javascript\">")) {
                   interpreterOutput.write("\n%html ".getBytes());
                 }
                 
interpreterOutput.write(executeResponse.getOutput().getBytes());
@@ -306,7 +309,7 @@ public class JupyterKernelClient {
   }
 
   public static void main(String[] args) {
-    JupyterKernelClient client = new JupyterKernelClient("localhost", 50053);
+    JupyterKernelClient client = new JupyterKernelClient("localhost", 50053, 
"python");
     client.status(StatusRequest.newBuilder().build());
 
     ExecuteResponse response = 
client.block_execute(ExecuteRequest.newBuilder().
diff --git 
a/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
 
b/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
index dff1900..98cf4bd 100644
--- 
a/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
+++ 
b/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
@@ -125,7 +125,7 @@ public class JupyterKernelInterpreter extends 
AbstractInterpreter {
 
       jupyterKernelClient = new 
JupyterKernelClient(ManagedChannelBuilder.forAddress("127.0.0.1",
               
kernelPort).usePlaintext(true).maxInboundMessageSize(message_size),
-              getProperties());
+              getProperties(), kernel);
       launchJupyterKernel(kernelPort);
     } catch (Exception e) {
       throw new InterpreterException("Fail to open 
JupyterKernelInterpreter:\n" +

Reply via email to