ZEPPELIN-2990. Matplotlib sometimes fails in IPythonInterpreter

This commit is contained in:
Jeff Zhang 2017-10-13 15:41:01 +08:00
parent 9812e26bce
commit 1e57afe276
6 changed files with 17 additions and 5 deletions

View file

@ -96,7 +96,7 @@ public class IPythonClient {
LOGGER.debug("Interpreter Streaming Output: " + executeResponse.getOutput());
if (isPreviousOutputImage) {
// add '\n' when switch from image to text
interpreterOutput.write("\n".getBytes());
interpreterOutput.write("\n%text ".getBytes());
}
isPreviousOutputImage = false;
interpreterOutput.write(executeResponse.getOutput().getBytes());

View file

@ -286,6 +286,7 @@ public class IPythonInterpreter extends Interpreter implements ExecuteResultHand
} else {
envs.put("PYTHONPATH", additionalPythonPath);
}
LOGGER.info("PYTHONPATH:" + envs.get("PYTHONPATH"));
return envs;
}

View file

@ -284,12 +284,24 @@ public class IPythonInterpreterTest {
// the order of IMAGE and TEXT is not determined
// check there must be one IMAGE output
boolean hasImageOutput = false;
boolean hasLineText = false;
boolean hasFigureText = false;
for (InterpreterResultMessage msg : interpreterResultMessages) {
if (msg.getType() == InterpreterResult.Type.IMG) {
hasImageOutput = true;
}
if (msg.getType() == InterpreterResult.Type.TEXT
&& msg.getData().contains("matplotlib.lines.Line2D")) {
hasLineText = true;
}
if (msg.getType() == InterpreterResult.Type.TEXT
&& msg.getData().contains("matplotlib.figure.Figure")) {
hasFigureText = true;
}
}
assertTrue("No Image Output", hasImageOutput);
assertTrue("No Line Text", hasLineText);
assertTrue("No Figure Text", hasFigureText);
// bokeh
// bokeh initialization

View file

@ -146,7 +146,7 @@ public class IPySparkInterpreterTest {
List<InterpreterResultMessage> interpreterResultMessages = null;
try {
interpreterResultMessages = context2.out.getInterpreterResultMessages();
assertTrue(interpreterResultMessages.get(0).getData().contains("cancelled"));
assertTrue(interpreterResultMessages.get(0).getData().contains("KeyboardInterrupt"));
} catch (IOException e) {
e.printStackTrace();
}
@ -180,7 +180,7 @@ public class IPySparkInterpreterTest {
"ssc.start()\n" +
"time.sleep(6)\n" +
"ssc.stop(stopSparkContext=False, stopGraceFully=True)", context);
Thread.sleep(100);
Thread.sleep(1000);
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
interpreterResultMessages = context.out.getInterpreterResultMessages();
assertEquals(1, interpreterResultMessages.size());

View file

@ -357,7 +357,7 @@ public class NotebookServer extends WebSocketServlet
break;
}
} catch (Exception e) {
LOG.error("Can't handle message", e);
LOG.error("Can't handle message: " + msg, e);
}
}

View file

@ -246,7 +246,6 @@ public class RemoteInterpreterEventPoller extends Thread {
listener.onParaInfosReceived(noteId, paraId, settingId, paraInfos);
}
}
logger.debug("Event from remote process {}", event.getType());
} catch (Exception e) {
logger.error("Can't handle event " + event, e);
}