Add zeppelin.python.maxResult property to python interpreter

This commit is contained in:
Mina Lee 2016-06-22 15:41:16 -07:00
parent 5013890ed5
commit 66b8f738f1
5 changed files with 23 additions and 9 deletions

View file

@ -16,12 +16,17 @@ group: manual
<th>Description</th>
</tr>
<tr>
<td>python</td>
<td>zeppelin.python</td>
<td>python</td>
<td>Path of the already installed Python binary (could be python2 or python3).
If python is not in your $PATH you can set the absolute directory (example : /usr/bin/python)
</td>
</tr>
<tr>
<td>zeppelin.python.maxResult</td>
<td>1000</td>
<td>Max number of dataframe rows to display.</td>
</tr>
</table>
## Enabling Python Interpreter

View file

@ -48,13 +48,14 @@ public class PythonInterpreter extends Interpreter {
public static final String BOOTSTRAP_PY = "/bootstrap.py";
public static final String BOOTSTRAP_INPUT_PY = "/bootstrap_input.py";
public static final String ZEPPELIN_PYTHON = "zeppelin.python";
public static final String DEFAULT_ZEPPELIN_PYTHON = "python";
public static final String MAX_RESULT = "zeppelin.python.maxResult";
private Integer port;
private GatewayServer gatewayServer;
private long pythonPid;
private Boolean py4J = false;
private InterpreterContext context;
private int maxResult;
PythonProcess process = null;
@ -67,6 +68,7 @@ public class PythonInterpreter extends Interpreter {
logger.info("Starting Python interpreter .....");
logger.info("Python path is set to:" + property.getProperty(ZEPPELIN_PYTHON));
maxResult = Integer.valueOf(getProperty(MAX_RESULT));
process = getPythonProcess();
try {
@ -234,4 +236,7 @@ public class PythonInterpreter extends Interpreter {
return port;
}
public int getMaxResult() {
return maxResult;
}
}

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# PYTHON 2 / 3 comptability :
# PYTHON 2 / 3 compatibility :
# bootstrap.py must be runnable with Python 2 or 3
# Remove interactive mode displayhook
@ -36,7 +36,7 @@ signal.signal(signal.SIGINT, intHandler)
def help():
print ('%html')
print ('<h2>Python Interpreter help</h2>')
print ('<h3>Python 2 & 3 comptability</h3>')
print ('<h3>Python 2 & 3 compatibility</h3>')
print ('<p>The interpreter is compatible with Python 2 & 3.<br/>')
print ('To change Python version, ')
print ('change in the interpreter configuration the python to the ')
@ -100,4 +100,3 @@ class PyZeppelinContext():
print (self.errorMsg)
z = PyZeppelinContext("")

View file

@ -9,6 +9,12 @@
"propertyName": "zeppelin.python",
"defaultValue": "python",
"description": "Python directory. It is set to python by default.(assume python is in your $PATH)"
},
"zeppelin.python.maxResult": {
"envName": null,
"propertyName": "zeppelin.python.maxResult",
"defaultValue": "1000",
"description": "Max number of dataframe rows to display."
}
}
}

View file

@ -17,6 +17,7 @@
package org.apache.zeppelin.python;
import static org.apache.zeppelin.python.PythonInterpreter.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -53,9 +54,6 @@ public class PythonInterpreterTest {
Logger logger = LoggerFactory.getLogger(PythonProcess.class);
public static final String ZEPPELIN_PYTHON = "zeppelin.python";
public static final String DEFAULT_ZEPPELIN_PYTHON = "python";
PythonInterpreter pythonInterpreter = null;
PythonProcess mockPythonProcess;
String cmdHistory;
@ -63,6 +61,7 @@ public class PythonInterpreterTest {
public static Properties getPythonTestProperties() {
Properties p = new Properties();
p.setProperty(ZEPPELIN_PYTHON, DEFAULT_ZEPPELIN_PYTHON);
p.setProperty(MAX_RESULT, "1000");
return p;
}