Search in sources :

Example 1 with InterpreterOutput

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

the class PythonInterpreterPandasSqlTest method setUp.

@Before
public void setUp() throws Exception {
    Properties p = new Properties();
    p.setProperty("zeppelin.python", "python");
    p.setProperty("zeppelin.python.maxResult", "100");
    intpGroup = new InterpreterGroup();
    python = new PythonInterpreter(p);
    python.setInterpreterGroup(intpGroup);
    python.open();
    sql = new PythonInterpreterPandasSql(p);
    sql.setInterpreterGroup(intpGroup);
    intpGroup.put("note", Arrays.asList(python, sql));
    out = new InterpreterOutput(this);
    context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), out);
    // to make sure python is running.
    InterpreterResult ret = python.interpret("\n", context);
    assertEquals(ret.message().toString(), InterpreterResult.Code.SUCCESS, ret.code());
    sql.open();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) HashMap(java.util.HashMap) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) LinkedList(java.util.LinkedList) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) GUI(org.apache.zeppelin.display.GUI) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Before(org.junit.Before)

Example 2 with InterpreterOutput

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

the class ZeppelinR method open.

/**
   * Start R repl
   * @throws IOException
   */
public void open() throws IOException {
    createRScript();
    zeppelinR.put(hashCode(), this);
    CommandLine cmd = CommandLine.parse(rCmdPath);
    cmd.addArgument("--no-save");
    cmd.addArgument("--no-restore");
    cmd.addArgument("-f");
    cmd.addArgument(scriptPath);
    cmd.addArgument("--args");
    cmd.addArgument(Integer.toString(hashCode()));
    cmd.addArgument(Integer.toString(port));
    cmd.addArgument(libPath);
    cmd.addArgument(Integer.toString(sparkVersion.toNumber()));
    // dump out the R command to facilitate manually running it, e.g. for fault diagnosis purposes
    logger.debug(cmd.toString());
    executor = new DefaultExecutor();
    outputStream = new InterpreterOutputStream(logger);
    input = new PipedOutputStream();
    PipedInputStream in = new PipedInputStream(input);
    PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream, outputStream, in);
    executor.setWatchdog(new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT));
    executor.setStreamHandler(streamHandler);
    Map env = EnvironmentUtils.getProcEnvironment();
    initialOutput = new InterpreterOutput(null);
    outputStream.setInterpreterOutput(initialOutput);
    executor.execute(cmd, env, this);
    rScriptRunning = true;
    // flush output
    eval("cat('')");
}
Also used : InterpreterOutputStream(org.apache.zeppelin.interpreter.util.InterpreterOutputStream) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with InterpreterOutput

use of org.apache.zeppelin.interpreter.InterpreterOutput 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");
    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 = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), out);
    python.open();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) Interpreter(org.apache.zeppelin.interpreter.Interpreter) HashMap(java.util.HashMap) Properties(java.util.Properties) LinkedList(java.util.LinkedList) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) GUI(org.apache.zeppelin.display.GUI) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Before(org.junit.Before)

Example 4 with InterpreterOutput

use of org.apache.zeppelin.interpreter.InterpreterOutput 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();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) Interpreter(org.apache.zeppelin.interpreter.Interpreter) HashMap(java.util.HashMap) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) GUI(org.apache.zeppelin.display.GUI) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Aggregations

HashMap (java.util.HashMap)4 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)4 LinkedList (java.util.LinkedList)3 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)3 GUI (org.apache.zeppelin.display.GUI)3 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)3 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)3 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)3 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)3 Before (org.junit.Before)3 Properties (java.util.Properties)2 Interpreter (org.apache.zeppelin.interpreter.Interpreter)2 Map (java.util.Map)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 InterpreterOutputStream (org.apache.zeppelin.interpreter.util.InterpreterOutputStream)1