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);
}
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);
}
}
}
}
}
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;
}
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;
}
}
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;
}
}
Aggregations