Search in sources :

Example 1 with InvalidHookException

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);
    }
}
Also used : InvalidHookException(org.apache.zeppelin.interpreter.InvalidHookException) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) IOException(java.io.IOException) ExecuteException(org.apache.commons.exec.ExecuteException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InvalidHookException(org.apache.zeppelin.interpreter.InvalidHookException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ExecuteException (org.apache.commons.exec.ExecuteException)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)1 InvalidHookException (org.apache.zeppelin.interpreter.InvalidHookException)1