Search in sources :

Example 1 with InterpreterNotFoundException

use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.

the class HeliumApplicationFactoryTest method testInterpreterUnbindOfNullReplParagraph.

@Test
@Ignore
public void testInterpreterUnbindOfNullReplParagraph() throws IOException {
    // create note
    String note1Id = notebook.createNote("note1", anonymous);
    Note note1 = notebook.processNote(note1Id, note1Tmp -> {
        return note1Tmp;
    });
    // add paragraph with invalid magic
    Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
    p1.setText("%fake ");
    // make sure that p1's repl is null
    try {
        p1.getBindedInterpreter();
        fail("Should throw InterpreterNotFoundException");
    } catch (InterpreterNotFoundException e) {
    }
    // remove note
    notebook.removeNote(note1.getId(), anonymous);
}
Also used : InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) Note(org.apache.zeppelin.notebook.Note) Paragraph(org.apache.zeppelin.notebook.Paragraph) Ignore(org.junit.Ignore) AbstractInterpreterTest(org.apache.zeppelin.interpreter.AbstractInterpreterTest) Test(org.junit.Test)

Example 2 with InterpreterNotFoundException

use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.

the class Note method runAllSync.

/**
 * Run all the paragraphs in sync(blocking) way.
 *
 * @param authInfo
 * @param isolated
 */
private void runAllSync(AuthenticationInfo authInfo, boolean isolated, Map<String, Object> params) throws Exception {
    try {
        for (Paragraph p : getParagraphs()) {
            if (!p.isEnabled()) {
                continue;
            }
            p.setAuthenticationInfo(authInfo);
            Map<String, Object> originalParams = p.settings.getParams();
            try {
                if (params != null && !params.isEmpty()) {
                    p.settings.setParams(params);
                }
                Interpreter interpreter = p.getBindedInterpreter();
                if (interpreter != null) {
                    // set interpreter property to execution.mode to be note
                    // so that it could use the correct scheduler. see ZEPPELIN-4832
                    interpreter.setProperty(".execution.mode", "note");
                    interpreter.setProperty(".noteId", id);
                }
                // Must run each paragraph in blocking way.
                if (!run(p.getId(), true)) {
                    LOGGER.warn("Skip running the remain notes because paragraph {} fails", p.getId());
                    return;
                }
            } catch (InterpreterNotFoundException e) {
            // ignore, because the following run method will fail if interpreter not found.
            } finally {
                // reset params to the original value
                p.settings.setParams(originalParams);
            }
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (isolated) {
            LOGGER.info("Releasing interpreters used by this note: {}", id);
            for (InterpreterSetting setting : getUsedInterpreterSettings()) {
                setting.closeInterpreters(getExecutionContext());
                for (Paragraph p : paragraphs) {
                    p.setInterpreter(null);
                }
            }
        }
    }
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) RemoteAngularObject(org.apache.zeppelin.interpreter.remote.RemoteAngularObject) AngularObject(org.apache.zeppelin.display.AngularObject) IOException(java.io.IOException) InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) CorruptedNoteException(org.apache.zeppelin.notebook.exception.CorruptedNoteException)

Example 3 with InterpreterNotFoundException

use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.

the class Notebook method getBindedInterpreterSettings.

public List<InterpreterSetting> getBindedInterpreterSettings(String noteId) throws IOException {
    List<InterpreterSetting> interpreterSettings = new ArrayList<>();
    processNote(noteId, note -> {
        if (note != null) {
            Set<InterpreterSetting> settings = new HashSet<>();
            for (Paragraph p : note.getParagraphs()) {
                try {
                    Interpreter intp = p.getBindedInterpreter();
                    settings.add(((ManagedInterpreterGroup) intp.getInterpreterGroup()).getInterpreterSetting());
                } catch (InterpreterNotFoundException e) {
                // ignore this
                }
            }
            // add the default interpreter group
            InterpreterSetting defaultIntpSetting = interpreterSettingManager.getByName(note.getDefaultInterpreterGroup());
            if (defaultIntpSetting != null) {
                settings.add(defaultIntpSetting);
            }
            interpreterSettings.addAll(settings);
        }
        return null;
    });
    return interpreterSettings;
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HashSet(java.util.HashSet)

Example 4 with InterpreterNotFoundException

use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.

the class Paragraph method execute.

/**
 * Return true only when paragraph run successfully with state of FINISHED.
 * @param blocking
 * @return
 */
public boolean execute(String interpreterGroupId, boolean blocking) {
    try {
        this.interpreterGroupId = interpreterGroupId;
        this.interpreter = getBindedInterpreter();
        InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup) interpreter.getInterpreterGroup()).getInterpreterSetting();
        Map<String, Object> config = interpreterSetting.getConfig(interpreter.getClassName());
        mergeConfig(config);
        // clear output
        setResult(null);
        cleanOutputBuffer();
        cleanRuntimeInfos();
        setStatus(Status.PENDING);
        if (shouldSkipRunParagraph()) {
            LOGGER.info("Skip to run blank paragraph. {}", getId());
            setStatus(Job.Status.FINISHED);
            return true;
        }
        if (isEnabled()) {
            setAuthenticationInfo(getAuthenticationInfo());
            interpreter.getScheduler().submit(this);
        } else {
            LOGGER.info("Skip disabled paragraph. {}", getId());
            setStatus(Job.Status.FINISHED);
            return true;
        }
        if (blocking) {
            while (!getStatus().isCompleted()) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            return getStatus() == Status.FINISHED;
        } else {
            return true;
        }
    } catch (InterpreterNotFoundException e) {
        InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, String.format("Interpreter %s not found", this.intpText));
        setReturn(intpResult, e);
        setStatus(Job.Status.ERROR);
        return false;
    } catch (Throwable e) {
        InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, "Unexpected exception: " + ExceptionUtils.getStackTrace(e));
        setReturn(intpResult, e);
        setStatus(Job.Status.ERROR);
        return false;
    }
}
Also used : InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) AngularObject(org.apache.zeppelin.display.AngularObject) ManagedInterpreterGroup(org.apache.zeppelin.interpreter.ManagedInterpreterGroup)

Example 5 with InterpreterNotFoundException

use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.

the class Paragraph method isValidInterpreter.

public boolean isValidInterpreter(String replName) {
    try {
        ExecutionContext executionContext = note.getExecutionContext();
        executionContext.setUser(user);
        executionContext.setInterpreterGroupId(interpreterGroupId);
        return note.getInterpreterFactory().getInterpreter(replName, executionContext) != null;
    } catch (InterpreterNotFoundException e) {
        return false;
    }
}
Also used : ExecutionContext(org.apache.zeppelin.interpreter.ExecutionContext) InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException)

Aggregations

InterpreterNotFoundException (org.apache.zeppelin.interpreter.InterpreterNotFoundException)10 Interpreter (org.apache.zeppelin.interpreter.Interpreter)5 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)5 AngularObject (org.apache.zeppelin.display.AngularObject)4 ManagedInterpreterGroup (org.apache.zeppelin.interpreter.ManagedInterpreterGroup)3 ArrayList (java.util.ArrayList)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)2 Paragraph (org.apache.zeppelin.notebook.Paragraph)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 AbstractInterpreterTest (org.apache.zeppelin.interpreter.AbstractInterpreterTest)1 ExecutionContext (org.apache.zeppelin.interpreter.ExecutionContext)1 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 RemoteAngularObject (org.apache.zeppelin.interpreter.remote.RemoteAngularObject)1 RemoteInterpreter (org.apache.zeppelin.interpreter.remote.RemoteInterpreter)1 Note (org.apache.zeppelin.notebook.Note)1