[ZEPPELIN-4771]. Bokeh output in IPythonInterpreter is not in correct format

This commit is contained in:
Jeff Zhang 2020-04-23 11:32:14 +08:00
parent 28a0a6dea9
commit da6578e0ee
4 changed files with 14 additions and 11 deletions

View file

@ -57,7 +57,7 @@ public class IPythonInterpreter extends JupyterKernelInterpreter {
private String py4jGatewaySecret;
public IPythonInterpreter(Properties properties) {
super(properties);
super("python", properties);
}
@Override

View file

@ -54,7 +54,7 @@ public class IRInterpreter extends JupyterKernelInterpreter {
private SparkRBackend sparkRBackend;
public IRInterpreter(Properties properties) {
super(properties);
super("ir", properties);
}
/**

View file

@ -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().

View file

@ -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" +