Search in sources :

Example 61 with InterpreterGroup

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

the class RInterpreterTest method setUp.

@Before
public void setUp() throws InterpreterException {
    Properties properties = new Properties();
    properties.setProperty("zeppelin.R.knitr", "true");
    properties.setProperty("spark.r.backendConnectionTimeout", "10");
    InterpreterContext context = getInterpreterContext();
    InterpreterContext.set(context);
    rInterpreter = new RInterpreter(properties);
    InterpreterGroup interpreterGroup = new InterpreterGroup();
    interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(rInterpreter), "session_1");
    rInterpreter.setInterpreterGroup(interpreterGroup);
    rInterpreter.open();
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Before(org.junit.Before)

Example 62 with InterpreterGroup

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

the class KotlinSparkInterpreterTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    intpGroup = new InterpreterGroup();
    context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").setParagraphTitle("title").setAngularObjectRegistry(new AngularObjectRegistry(intpGroup.getId(), null)).setResourcePool(new LocalResourcePool("id")).setInterpreterOut(new InterpreterOutput()).setIntpEventClient(mock(RemoteInterpreterEventClient.class)).build();
    context.out = new InterpreterOutput(new InterpreterOutputListener() {

        @Override
        public void onUpdateAll(InterpreterOutput out) {
        }

        @Override
        public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
            try {
                output = out.toInterpreterResultMessage().getData();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onUpdate(int index, InterpreterResultMessageOutput out) {
        }
    });
    InterpreterContext.set(context);
    intpGroup.put("note", new LinkedList<Interpreter>());
    Properties properties = getSparkTestProperties(tmpDir);
    repl = new SparkInterpreter(properties);
    repl.setInterpreterGroup(intpGroup);
    intpGroup.get("note").add(repl);
    repl.open();
    repl.interpret("sc", context);
    interpreter = new KotlinSparkInterpreter(properties);
    interpreter.setInterpreterGroup(intpGroup);
    intpGroup.get("note").add(interpreter);
    try {
        interpreter.open();
        sparkSupported = true;
    } catch (UnsupportedClassVersionError e) {
        sparkSupported = false;
    }
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterOutputListener(org.apache.zeppelin.interpreter.InterpreterOutputListener) IOException(java.io.IOException) RemoteInterpreterEventClient(org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient) Properties(java.util.Properties) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterResultMessageOutput(org.apache.zeppelin.interpreter.InterpreterResultMessageOutput) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) BeforeClass(org.junit.BeforeClass)

Example 63 with InterpreterGroup

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

the class PySparkInterpreterTest method testFailtoLaunchPythonProcess.

@Override
@Test
public void testFailtoLaunchPythonProcess() throws InterpreterException {
    tearDown();
    intpGroup = new InterpreterGroup();
    Properties properties = new Properties();
    properties.setProperty(SparkStringConstants.APP_NAME_PROP_NAME, "Zeppelin Test");
    properties.setProperty("spark.pyspark.python", "invalid_python");
    properties.setProperty("zeppelin.python.useIPython", "false");
    properties.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
    properties.setProperty("zeppelin.spark.maxResult", "3");
    interpreter = new LazyOpenInterpreter(new PySparkInterpreter(properties));
    interpreter.setInterpreterGroup(intpGroup);
    Interpreter sparkInterpreter = new LazyOpenInterpreter(new SparkInterpreter(properties));
    sparkInterpreter.setInterpreterGroup(intpGroup);
    LazyOpenInterpreter iPySparkInterpreter = new LazyOpenInterpreter(new IPySparkInterpreter(properties));
    iPySparkInterpreter.setInterpreterGroup(intpGroup);
    intpGroup.put("note", new LinkedList<Interpreter>());
    intpGroup.get("note").add(interpreter);
    intpGroup.get("note").add(sparkInterpreter);
    intpGroup.get("note").add(iPySparkInterpreter);
    InterpreterContext.set(getInterpreterContext());
    try {
        interpreter.interpret("1+1", getInterpreterContext());
        fail("Should fail to open PySparkInterpreter");
    } catch (InterpreterException e) {
        String stacktrace = ExceptionUtils.getStackTrace(e);
        assertTrue(stacktrace, stacktrace.contains("No such file or directory"));
    }
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) Properties(java.util.Properties) Test(org.junit.Test) PythonInterpreterTest(org.apache.zeppelin.python.PythonInterpreterTest)

Example 64 with InterpreterGroup

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

the class SparkSqlInterpreterTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    Properties p = new Properties();
    p.setProperty(SparkStringConstants.MASTER_PROP_NAME, "local[4]");
    p.setProperty(SparkStringConstants.APP_NAME_PROP_NAME, "test");
    p.setProperty("zeppelin.spark.maxResult", "10");
    p.setProperty("zeppelin.spark.concurrentSQL", "true");
    p.setProperty("zeppelin.spark.sql.stacktrace", "true");
    p.setProperty("zeppelin.spark.useHiveContext", "true");
    p.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
    intpGroup = new InterpreterGroup();
    sparkInterpreter = new SparkInterpreter(p);
    sparkInterpreter.setInterpreterGroup(intpGroup);
    sqlInterpreter = new SparkSqlInterpreter(p);
    sqlInterpreter.setInterpreterGroup(intpGroup);
    intpGroup.put("session_1", new LinkedList<Interpreter>());
    intpGroup.get("session_1").add(sparkInterpreter);
    intpGroup.get("session_1").add(sqlInterpreter);
    context = getInterpreterContext();
    InterpreterContext.set(context);
    sparkInterpreter.open();
    sqlInterpreter.open();
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

Example 65 with InterpreterGroup

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

the class SparkShinyInterpreterTest method setUp.

@Before
public void setUp() throws InterpreterException {
    Properties properties = new Properties();
    properties.setProperty(SparkStringConstants.MASTER_PROP_NAME, "local[*]");
    properties.setProperty(SparkStringConstants.APP_NAME_PROP_NAME, "test");
    InterpreterContext context = getInterpreterContext();
    InterpreterContext.set(context);
    interpreter = new SparkShinyInterpreter(properties);
    InterpreterGroup interpreterGroup = new InterpreterGroup();
    interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(interpreter), "session_1");
    interpreter.setInterpreterGroup(interpreterGroup);
    sparkInterpreter = new SparkInterpreter(properties);
    interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(sparkInterpreter), "session_1");
    sparkInterpreter.setInterpreterGroup(interpreterGroup);
    interpreter.open();
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Before(org.junit.Before)

Aggregations

InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)74 Properties (java.util.Properties)30 Interpreter (org.apache.zeppelin.interpreter.Interpreter)27 Test (org.junit.Test)26 LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)23 Before (org.junit.Before)19 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)18 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)17 RemoteAngularObjectRegistry (org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)14 IOException (java.io.IOException)12 TException (org.apache.thrift.TException)12 AngularObject (org.apache.zeppelin.display.AngularObject)12 List (java.util.List)10 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)10 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)10 Note (org.apache.zeppelin.notebook.Note)9 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)8 Paragraph (org.apache.zeppelin.notebook.Paragraph)8 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)7