mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Make Python fetch maxResults from JVM
This commit is contained in:
parent
9eac20d08a
commit
e800fd7032
3 changed files with 26 additions and 10 deletions
|
|
@ -112,18 +112,17 @@ class PyZeppelinContext(object):
|
|||
errorMsg = "You must install py4j Python module " \
|
||||
"(pip install py4j) to use Zeppelin dynamic forms features"
|
||||
|
||||
def __init__(self, zc):
|
||||
self.z = zc
|
||||
def __init__(self):
|
||||
self.max_result = 1000
|
||||
|
||||
def input(self, name, defaultValue=""):
|
||||
print (self.errorMsg)
|
||||
print(self.errorMsg)
|
||||
|
||||
def select(self, name, options, defaultValue=""):
|
||||
print (self.errorMsg)
|
||||
print(self.errorMsg)
|
||||
|
||||
def checkbox(self, name, options, defaultChecked=[]):
|
||||
print (self.errorMsg)
|
||||
print(self.errorMsg)
|
||||
|
||||
def show(self, p, **kwargs):
|
||||
if hasattr(p, '__name__') and p.__name__ == "matplotlib.pyplot":
|
||||
|
|
@ -172,4 +171,4 @@ class PyZeppelinContext(object):
|
|||
img.close()
|
||||
|
||||
|
||||
z = PyZeppelinContext("")
|
||||
z = PyZeppelinContext()
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ java_import(gateway.jvm, "org.apache.zeppelin.display.Input")
|
|||
class Py4jZeppelinContext(PyZeppelinContext):
|
||||
"""A context impl that uses Py4j to communicate to JVM
|
||||
"""
|
||||
def __init__(self, zc):
|
||||
super(Py4jZeppelinContext, self).__init__(zc)
|
||||
def __init__(self, z):
|
||||
self.z = z
|
||||
self.paramOption = gateway.jvm.org.apache.zeppelin.display.Input.ParamOption
|
||||
self.javaList = gateway.jvm.java.util.ArrayList
|
||||
self.max_result = 1000 #TODO(bzz): read `zeppelin.python.maxResult` from JVM
|
||||
self.max_result = self.z.getMaxResult()
|
||||
|
||||
def input(self, name, defaultValue=""):
|
||||
return self.z.getGui().input(name, defaultValue)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.junit.Test;
|
|||
public class PythonInterpreterWithPythonInstalledTest {
|
||||
|
||||
@Test
|
||||
public void badSqlSyntaxFails() {
|
||||
public void badPythonSyntaxFails() {
|
||||
//given
|
||||
PythonInterpreter realPython = new PythonInterpreter(
|
||||
PythonInterpreterTest.getPythonTestProperties());
|
||||
|
|
@ -58,4 +58,21 @@ public class PythonInterpreterWithPythonInstalledTest {
|
|||
assertTrue(ret.message().length() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void goodPythonSyntaxRuns() {
|
||||
//given
|
||||
PythonInterpreter realPython = new PythonInterpreter(
|
||||
PythonInterpreterTest.getPythonTestProperties());
|
||||
realPython.open();
|
||||
|
||||
//when
|
||||
InterpreterResult ret = realPython.interpret("help()", null);
|
||||
|
||||
//then
|
||||
assertNotNull("Interpreter returned 'null'", ret);
|
||||
//System.out.println("\nInterpreter response: \n" + ret.message());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertTrue(ret.message().length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue