mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
some cleanup
This commit is contained in:
parent
e5b6850667
commit
18d5dbecb1
4 changed files with 19 additions and 17 deletions
|
|
@ -34,6 +34,7 @@ import py4j.GatewayServer;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
|
@ -127,7 +128,7 @@ public class IPythonInterpreter extends JupyterKernelInterpreter {
|
|||
private void initPythonInterpreter(String gatewayHost, int gatewayPort) throws IOException {
|
||||
InputStream input =
|
||||
getClass().getClassLoader().getResourceAsStream("python/zeppelin_ipython.py");
|
||||
List<String> lines = IOUtils.readLines(input);
|
||||
List<String> lines = IOUtils.readLines(input, StandardCharsets.UTF_8);
|
||||
ExecuteResponse response = jupyterKernelClient.block_execute(ExecuteRequest.newBuilder()
|
||||
.setCode(StringUtils.join(lines, System.lineSeparator())
|
||||
.replace("${JVM_GATEWAY_PORT}", gatewayPort + "")
|
||||
|
|
@ -138,7 +139,7 @@ public class IPythonInterpreter extends JupyterKernelInterpreter {
|
|||
|
||||
input =
|
||||
getClass().getClassLoader().getResourceAsStream("python/zeppelin_context.py");
|
||||
lines = IOUtils.readLines(input);
|
||||
lines = IOUtils.readLines(input, StandardCharsets.UTF_8);
|
||||
response = jupyterKernelClient.block_execute(ExecuteRequest.newBuilder()
|
||||
.setCode(StringUtils.join(lines, System.lineSeparator())).build());
|
||||
if (response.getStatus() != ExecuteStatus.SUCCESS) {
|
||||
|
|
@ -154,13 +155,13 @@ public class IPythonInterpreter extends JupyterKernelInterpreter {
|
|||
|
||||
if (additionalPythonInitFile != null) {
|
||||
input = getClass().getClassLoader().getResourceAsStream(additionalPythonInitFile);
|
||||
lines = IOUtils.readLines(input);
|
||||
lines = IOUtils.readLines(input, StandardCharsets.UTF_8);
|
||||
response = jupyterKernelClient.block_execute(ExecuteRequest.newBuilder()
|
||||
.setCode(StringUtils.join(lines, System.lineSeparator())
|
||||
.replace("${JVM_GATEWAY_PORT}", gatewayPort + "")
|
||||
.replace("${JVM_GATEWAY_ADDRESS}", gatewayHost)).build());
|
||||
if (response.getStatus() != ExecuteStatus.SUCCESS) {
|
||||
LOGGER.error("Fail to run additional Python init file\n" + response.getOutput());
|
||||
LOGGER.error("Fail to run additional Python init file\n{}", response.getOutput());
|
||||
throw new IOException("Fail to run additional Python init file: "
|
||||
+ additionalPythonInitFile + "\n" + response.getOutput());
|
||||
}
|
||||
|
|
@ -196,7 +197,7 @@ public class IPythonInterpreter extends JupyterKernelInterpreter {
|
|||
if (usePy4JAuth) {
|
||||
envs.put("PY4J_GATEWAY_SECRET", this.py4jGatewaySecret);
|
||||
}
|
||||
LOGGER.info("PYTHONPATH:" + envs.get("PYTHONPATH"));
|
||||
LOGGER.info("PYTHONPATH: {}", envs.get("PYTHONPATH"));
|
||||
return envs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
|
|||
assertEquals(context.out.toInterpreterResultMessage().get(0).getData(),
|
||||
InterpreterResult.Code.SUCCESS, result.code());
|
||||
interpreterResultMessages = context.out.toInterpreterResultMessage();
|
||||
|
||||
|
||||
assertEquals(context.out.toString(), 5, interpreterResultMessages.size());
|
||||
// the first message is the warning text message.
|
||||
assertEquals(InterpreterResult.Type.HTML, interpreterResultMessages.get(1).getType());
|
||||
|
|
@ -377,7 +377,7 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
|
|||
// We ensure that running and auto completion are not hanging.
|
||||
InterpreterResult res = interpretFuture.get(20000, TimeUnit.MILLISECONDS);
|
||||
List<InterpreterCompletion> autoRes = completionFuture.get(3000, TimeUnit.MILLISECONDS);
|
||||
assertTrue(res.code().name().equals("SUCCESS"));
|
||||
assertEquals("SUCCESS", res.code().name());
|
||||
assertTrue(autoRes.size() > 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
|
@ -78,12 +79,12 @@ public class ShinyInterpreterTest {
|
|||
InterpreterContext context = getInterpreterContext();
|
||||
context.getLocalProperties().put("type", "ui");
|
||||
InterpreterResult result =
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/ui.R")), context);
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/ui.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
context = getInterpreterContext();
|
||||
context.getLocalProperties().put("type", "server");
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R")), context);
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
final InterpreterContext context2 = getInterpreterContext();
|
||||
|
|
@ -121,13 +122,13 @@ public class ShinyInterpreterTest {
|
|||
context.getLocalProperties().put("type", "ui");
|
||||
context.getLocalProperties().put("app", "app2");
|
||||
result =
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/ui.R")), context);
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/ui.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
context = getInterpreterContext();
|
||||
context.getLocalProperties().put("type", "server");
|
||||
context.getLocalProperties().put("app", "app2");
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R")), context);
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
final InterpreterContext context3 = getInterpreterContext();
|
||||
|
|
@ -183,12 +184,12 @@ public class ShinyInterpreterTest {
|
|||
InterpreterContext context = getInterpreterContext();
|
||||
context.getLocalProperties().put("type", "ui");
|
||||
InterpreterResult result =
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/invalid_ui.R")), context);
|
||||
interpreter.interpret(IOUtils.toString(getClass().getResource("/invalid_ui.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
context = getInterpreterContext();
|
||||
context.getLocalProperties().put("type", "server");
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R")), context);
|
||||
result = interpreter.interpret(IOUtils.toString(getClass().getResource("/server.R"), StandardCharsets.UTF_8), context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
||||
final InterpreterContext context2 = getInterpreterContext();
|
||||
|
|
|
|||
|
|
@ -74,13 +74,13 @@ public class TerminalInterpreterTest extends BaseInterpreterTest {
|
|||
try {
|
||||
// mock connect terminal
|
||||
boolean running = terminal.terminalThreadIsRunning();
|
||||
assertEquals(running, true);
|
||||
assertTrue(running);
|
||||
|
||||
URI uri = URI.create("ws://localhost:" + terminal.getTerminalPort() + "/terminal/");
|
||||
webSocketContainer = ContainerProvider.getWebSocketContainer();
|
||||
|
||||
// Attempt Connect
|
||||
session = (Session) webSocketContainer.connectToServer(TerminalSocketTest.class, uri);
|
||||
session = webSocketContainer.connectToServer(TerminalSocketTest.class, uri);
|
||||
|
||||
// Send Start terminal service message
|
||||
String terminalReadyCmd = String.format("{\"type\":\"TERMINAL_READY\"," +
|
||||
|
|
@ -154,13 +154,13 @@ public class TerminalInterpreterTest extends BaseInterpreterTest {
|
|||
try {
|
||||
// mock connect terminal
|
||||
boolean running = terminal.terminalThreadIsRunning();
|
||||
assertEquals(running, true);
|
||||
assertTrue(running);
|
||||
|
||||
URI uri = URI.create("ws://localhost:" + terminal.getTerminalPort() + "/terminal/");
|
||||
webSocketContainer = ContainerProvider.getWebSocketContainer();
|
||||
|
||||
// Attempt Connect
|
||||
session = (Session) webSocketContainer.connectToServer(TerminalSocketTest.class, uri);
|
||||
session = webSocketContainer.connectToServer(TerminalSocketTest.class, uri);
|
||||
|
||||
// Send Start terminal service message
|
||||
String terminalReadyCmd = String.format("{\"type\":\"TERMINAL_READY\"," +
|
||||
|
|
|
|||
Loading…
Reference in a new issue