use of org.apache.zeppelin.interpreter.InvalidHookException in project zeppelin by apache.
the class PythonInterpreter method open.
@Override
public void open() throws InterpreterException {
// try IPythonInterpreter first
iPythonInterpreter = getIPythonInterpreter();
boolean useIPython = Boolean.parseBoolean(getProperty("zeppelin.python.useIPython", "true"));
LOGGER.info("zeppelin.python.useIPython: {}", useIPython);
if (useIPython) {
String checkKernelPrerequisiteResult = iPythonInterpreter.checkKernelPrerequisite(getPythonExec());
if (StringUtils.isEmpty(checkKernelPrerequisiteResult)) {
try {
iPythonInterpreter.open();
LOGGER.info("IPython is available, Use IPythonInterpreter to replace PythonInterpreter");
return;
} catch (Exception e) {
iPythonInterpreter = null;
LOGGER.warn("Fail to open IPythonInterpreter", e);
}
} else {
LOGGER.info("IPython requirement is not met, checkKernelPrerequisiteResult: {}", checkKernelPrerequisiteResult);
}
}
// reset iPythonInterpreter to null as it is not available
iPythonInterpreter = null;
LOGGER.info("IPython is not available, use the native PythonInterpreter");
// Add matplotlib display hook
InterpreterGroup intpGroup = getInterpreterGroup();
if (intpGroup != null && intpGroup.getInterpreterHookRegistry() != null) {
try {
// just for unit test I believe (zjffdu)
registerHook(HookType.POST_EXEC_DEV.getName(), "__zeppelin__._displayhook()");
} catch (InvalidHookException e) {
throw new InterpreterException(e);
}
}
try {
this.usePy4jAuth = Boolean.parseBoolean(getProperty("zeppelin.py4j.useAuth", "true"));
createGatewayServerAndStartScript();
} catch (IOException e) {
LOGGER.error("Fail to open PythonInterpreter", e);
throw new InterpreterException("Fail to open PythonInterpreter", e);
}
}
Aggregations