use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class PythonCondaInterpreterTest method setUp.
@Before
public void setUp() throws InterpreterException {
conda = spy(new PythonCondaInterpreter(new Properties()));
when(conda.getClassName()).thenReturn(PythonCondaInterpreter.class.getName());
python = mock(PythonInterpreter.class);
when(python.getClassName()).thenReturn(PythonInterpreter.class.getName());
InterpreterGroup group = new InterpreterGroup();
group.put("note", Arrays.asList(python, conda));
python.setInterpreterGroup(group);
conda.setInterpreterGroup(group);
}
use of org.apache.zeppelin.interpreter.InterpreterGroup 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.InterpreterGroup 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"));
}
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class LivyInterpreterIT method testSparkInterpreter.
@Test
public void testSparkInterpreter() throws InterpreterException {
if (!checkPreCondition()) {
return;
}
InterpreterGroup interpreterGroup = new InterpreterGroup("group_1");
interpreterGroup.put("session_1", new ArrayList<Interpreter>());
LivySparkInterpreter sparkInterpreter = new LivySparkInterpreter(properties);
sparkInterpreter.setInterpreterGroup(interpreterGroup);
interpreterGroup.get("session_1").add(sparkInterpreter);
AuthenticationInfo authInfo = new AuthenticationInfo("user1");
MyInterpreterOutputListener outputListener = new MyInterpreterOutputListener();
InterpreterOutput output = new InterpreterOutput(outputListener);
InterpreterContext context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").setAuthenticationInfo(authInfo).setInterpreterOut(output).build();
sparkInterpreter.open();
LivySparkSQLInterpreter sqlInterpreter = new LivySparkSQLInterpreter(properties);
interpreterGroup.get("session_1").add(sqlInterpreter);
sqlInterpreter.setInterpreterGroup(interpreterGroup);
sqlInterpreter.open();
try {
// detect spark version
InterpreterResult result = sparkInterpreter.interpret("sc.version", context);
assertEquals(result.toString(), InterpreterResult.Code.SUCCESS, result.code());
assertEquals(1, result.message().size());
boolean isSpark2 = isSpark2(sparkInterpreter, context);
testRDD(sparkInterpreter, isSpark2);
testDataFrame(sparkInterpreter, sqlInterpreter, isSpark2);
} finally {
sparkInterpreter.close();
sqlInterpreter.close();
}
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class RemoteInterpreterServer method createInterpreter.
@Override
public void createInterpreter(String interpreterGroupId, String sessionId, String className, Map<String, String> properties, String userName) throws InterpreterRPCException, TException {
try {
if (interpreterGroup == null) {
interpreterGroup = new InterpreterGroup(interpreterGroupId);
angularObjectRegistry = new AngularObjectRegistry(interpreterGroup.getId(), intpEventClient);
hookRegistry = new InterpreterHookRegistry();
resourcePool = new DistributedResourcePool(interpreterGroup.getId(), intpEventClient);
interpreterGroup.setInterpreterHookRegistry(hookRegistry);
interpreterGroup.setAngularObjectRegistry(angularObjectRegistry);
interpreterGroup.setResourcePool(resourcePool);
intpEventClient.setIntpGroupId(interpreterGroupId);
String localRepoPath = properties.get("zeppelin.interpreter.localRepo");
if (properties.containsKey("zeppelin.interpreter.output.limit")) {
InterpreterOutput.LIMIT = Integer.parseInt(properties.get("zeppelin.interpreter.output.limit"));
}
depLoader = new DependencyResolver(localRepoPath);
appLoader = new ApplicationLoader(resourcePool, depLoader);
resultCacheInSeconds = Integer.parseInt(properties.getOrDefault("zeppelin.interpreter.result.cache", "0"));
}
Class<Interpreter> replClass = (Class<Interpreter>) Object.class.forName(className);
Properties p = new Properties();
p.putAll(properties);
setSystemProperty(p);
Constructor<Interpreter> constructor = replClass.getConstructor(new Class[] { Properties.class });
Interpreter interpreter = constructor.newInstance(p);
interpreter.setClassloaderUrls(new URL[] {});
interpreter.setInterpreterGroup(interpreterGroup);
interpreter.setUserName(userName);
interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(interpreter), sessionId);
this.isForceShutdown = Boolean.parseBoolean(properties.getOrDefault("zeppelin.interpreter.forceShutdown", "true"));
LOGGER.info("Instantiate interpreter {}, isForceShutdown: {}", className, isForceShutdown);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
throw new InterpreterRPCException("Fail to create interpreter, cause: " + e.toString());
}
}
Aggregations