use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class PythonInterpreterTest method beforeTest.
@Before
public void beforeTest() throws IOException {
cmdHistory = "";
// python interpreter
pythonInterpreter = new PythonInterpreter(getPythonTestProperties());
// create interpreter group
InterpreterGroup group = new InterpreterGroup();
group.put("note", new LinkedList<Interpreter>());
group.get("note").add(pythonInterpreter);
pythonInterpreter.setInterpreterGroup(group);
out = new InterpreterOutput(this);
context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(group.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), out);
pythonInterpreter.open();
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class NoteInterpreterLoaderTest method testNoteInterpreterCloseForAll.
@Test
public void testNoteInterpreterCloseForAll() throws IOException {
interpreterSettingManager.setInterpreters("user", "FitstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
interpreterSettingManager.setInterpreters("user", "yourFirstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
// interpreters are not created before accessing it
assertNull(interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getInterpreterGroup("user", "FitstNote").get("FitstNote"));
assertNull(interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getInterpreterGroup("user", "yourFirstNote").get("yourFirstNote"));
Interpreter firstNoteIntp = factory.getInterpreter("user", "FitstNote", "group1.mock1");
Interpreter yourFirstNoteIntp = factory.getInterpreter("user", "yourFirstNote", "group1.mock1");
firstNoteIntp.open();
yourFirstNoteIntp.open();
assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
interpreterSettingManager.closeNote("user", "FitstNote");
assertFalse(((LazyOpenInterpreter) firstNoteIntp).isOpen());
assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
//reopen
firstNoteIntp.open();
assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
// invalid check
interpreterSettingManager.closeNote("invalid", "Note");
assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
// invalid contains value check
interpreterSettingManager.closeNote("u", "Note");
assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class PigQueryInterpreterTest method setUp.
@Before
public void setUp() throws InterpreterException {
Properties properties = new Properties();
properties.put("zeppelin.pig.execType", "local");
properties.put("zeppelin.pig.maxResult", "20");
pigInterpreter = new LazyOpenInterpreter(new PigInterpreter(properties));
pigQueryInterpreter = new LazyOpenInterpreter(new PigQueryInterpreter(properties));
List<Interpreter> interpreters = new ArrayList();
interpreters.add(pigInterpreter);
interpreters.add(pigQueryInterpreter);
InterpreterGroup group = new InterpreterGroup();
group.put("note_id", interpreters);
pigInterpreter.setInterpreterGroup(group);
pigQueryInterpreter.setInterpreterGroup(group);
pigInterpreter.open();
pigQueryInterpreter.open();
context = InterpreterContext.builder().setParagraphId("paragraphId").build();
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class PythonInterpreterMatplotlibTest method setUp.
@Before
public void setUp() throws Exception {
Properties p = new Properties();
p.setProperty("zeppelin.python", "python");
p.setProperty("zeppelin.python.maxResult", "100");
p.setProperty("zeppelin.python.useIPython", "false");
p.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
intpGroup = new InterpreterGroup();
python = new PythonInterpreter(p);
python.setInterpreterGroup(intpGroup);
List<Interpreter> interpreters = new LinkedList<>();
interpreters.add(python);
intpGroup.put("note", interpreters);
out = new InterpreterOutput(this);
context = InterpreterContext.builder().setInterpreterOut(out).setAngularObjectRegistry(new AngularObjectRegistry(intpGroup.getId(), null)).build();
InterpreterContext.set(context);
python.open();
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class PythonInterpreterTest method testFailtoLaunchPythonProcess.
@Test
public void testFailtoLaunchPythonProcess() throws InterpreterException {
tearDown();
intpGroup = new InterpreterGroup();
Properties properties = new Properties();
properties.setProperty("zeppelin.python", "invalid_python");
properties.setProperty("zeppelin.python.useIPython", "false");
properties.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
interpreter = new LazyOpenInterpreter(new PythonInterpreter(properties));
intpGroup.put("note", new LinkedList<Interpreter>());
intpGroup.get("note").add(interpreter);
interpreter.setInterpreterGroup(intpGroup);
InterpreterContext.set(getInterpreterContext());
try {
interpreter.interpret("1+1", getInterpreterContext());
fail("Should fail to open PythonInterpreter");
} catch (InterpreterException e) {
String stacktrace = ExceptionUtils.getStackTrace(e);
assertTrue(stacktrace, stacktrace.contains("No such file or directory"));
}
}
Aggregations