Search in sources :

Example 16 with LazyOpenInterpreter

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

Example 17 with LazyOpenInterpreter

use of org.apache.zeppelin.interpreter.LazyOpenInterpreter 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());
    }
}
Also used : InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterHookRegistry(org.apache.zeppelin.interpreter.InterpreterHookRegistry) Properties(java.util.Properties) TTransportException(org.apache.thrift.transport.TTransportException) InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) ApplicationException(org.apache.zeppelin.helium.ApplicationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DependencyResolver(org.apache.zeppelin.dep.DependencyResolver) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) AngularObject(org.apache.zeppelin.display.AngularObject) HeliumAppAngularObjectRegistry(org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) DistributedResourcePool(org.apache.zeppelin.resource.DistributedResourcePool) ApplicationLoader(org.apache.zeppelin.helium.ApplicationLoader)

Example 18 with LazyOpenInterpreter

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

the class IPySparkInterpreterTest method startInterpreter.

@Override
protected void startInterpreter(Properties properties) throws InterpreterException {
    InterpreterContext context = getInterpreterContext();
    context.setIntpEventClient(mockIntpEventClient);
    InterpreterContext.set(context);
    LazyOpenInterpreter sparkInterpreter = new LazyOpenInterpreter(new SparkInterpreter(properties));
    intpGroup = new InterpreterGroup();
    intpGroup.put("session_1", new ArrayList<Interpreter>());
    intpGroup.get("session_1").add(sparkInterpreter);
    sparkInterpreter.setInterpreterGroup(intpGroup);
    LazyOpenInterpreter pySparkInterpreter = new LazyOpenInterpreter(new PySparkInterpreter(properties));
    intpGroup.get("session_1").add(pySparkInterpreter);
    pySparkInterpreter.setInterpreterGroup(intpGroup);
    interpreter = new LazyOpenInterpreter(new IPySparkInterpreter(properties));
    intpGroup.get("session_1").add(interpreter);
    interpreter.setInterpreterGroup(intpGroup);
    pySparkInterpreter.open();
    interpreter.open();
}
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)

Example 19 with LazyOpenInterpreter

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

the class SparkRInterpreterTest method testInvalidR.

@Test
public void testInvalidR() throws InterpreterException {
    tearDown();
    Properties properties = new Properties();
    properties.setProperty("zeppelin.R.cmd", "invalid_r");
    properties.setProperty(SparkStringConstants.MASTER_PROP_NAME, "local");
    properties.setProperty(SparkStringConstants.APP_NAME_PROP_NAME, "test");
    InterpreterGroup interpreterGroup = new InterpreterGroup();
    Interpreter sparkRInterpreter = new LazyOpenInterpreter(new SparkRInterpreter(properties));
    Interpreter sparkInterpreter = new LazyOpenInterpreter(new SparkInterpreter(properties));
    interpreterGroup.addInterpreterToSession(sparkRInterpreter, "session_1");
    interpreterGroup.addInterpreterToSession(sparkInterpreter, "session_1");
    sparkRInterpreter.setInterpreterGroup(interpreterGroup);
    sparkInterpreter.setInterpreterGroup(interpreterGroup);
    InterpreterContext context = getInterpreterContext();
    InterpreterContext.set(context);
    try {
        sparkRInterpreter.interpret("1+1", getInterpreterContext());
        fail("Should fail to open SparkRInterpreter");
    } 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) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Test(org.junit.Test)

Example 20 with LazyOpenInterpreter

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

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