Search in sources :

Example 21 with LazyOpenInterpreter

use of org.apache.zeppelin.interpreter.LazyOpenInterpreter 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 22 with LazyOpenInterpreter

use of org.apache.zeppelin.interpreter.LazyOpenInterpreter 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)

Example 23 with LazyOpenInterpreter

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

the class IPyFlinkInterpreterTest method startInterpreter.

@Override
protected void startInterpreter(Properties properties) throws InterpreterException {
    InterpreterContext context = getInterpreterContext();
    context.setIntpEventClient(mockIntpEventClient);
    InterpreterContext.set(context);
    this.flinkInnerInterpreter = new FlinkInterpreter(properties);
    this.flinkScalaInterpreter = new LazyOpenInterpreter(flinkInnerInterpreter);
    intpGroup = new InterpreterGroup();
    intpGroup.put("session_1", new ArrayList<Interpreter>());
    intpGroup.get("session_1").add(flinkScalaInterpreter);
    flinkScalaInterpreter.setInterpreterGroup(intpGroup);
    LazyOpenInterpreter pyFlinkInterpreter = new LazyOpenInterpreter(new PyFlinkInterpreter(properties));
    intpGroup.get("session_1").add(pyFlinkInterpreter);
    pyFlinkInterpreter.setInterpreterGroup(intpGroup);
    interpreter = new LazyOpenInterpreter(new IPyFlinkInterpreter(properties));
    intpGroup.get("session_1").add(interpreter);
    interpreter.setInterpreterGroup(intpGroup);
    interpreter.open();
    angularObjectRegistry = new AngularObjectRegistry("flink", null);
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Example 24 with LazyOpenInterpreter

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

the class IPythonKernelTest method setUp.

@Before
public void setUp() throws InterpreterException {
    Properties properties = new Properties();
    interpreter = new LazyOpenInterpreter(new JupyterInterpreter(properties));
    intpGroup = new InterpreterGroup();
    resourcePool = new LocalResourcePool("local");
    intpGroup.setResourcePool(resourcePool);
    intpGroup.put("session_1", new ArrayList<>());
    intpGroup.get("session_1").add(interpreter);
    interpreter.setInterpreterGroup(intpGroup);
    interpreter.open();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) Before(org.junit.Before)

Example 25 with LazyOpenInterpreter

use of org.apache.zeppelin.interpreter.LazyOpenInterpreter in project SSM by Intel-bigdata.

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());
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Test(org.junit.Test)

Aggregations

LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)25 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)21 Interpreter (org.apache.zeppelin.interpreter.Interpreter)17 Properties (java.util.Properties)16 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)14 Before (org.junit.Before)8 Test (org.junit.Test)8 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)3 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)3 IOException (java.io.IOException)2 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)2 WrappedInterpreter (org.apache.zeppelin.interpreter.WrappedInterpreter)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2 ArrayList (java.util.ArrayList)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 DependencyResolver (org.apache.zeppelin.dep.DependencyResolver)1 AngularObject (org.apache.zeppelin.display.AngularObject)1 ApplicationException (org.apache.zeppelin.helium.ApplicationException)1