Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to pass command-line arguments to kernel #152

Open
wants to merge 1 commit into
base: 0.1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion etc/pip_install/toree/toreeapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import os.path
import json
import shlex
from os import listdir
from traitlets import Unicode, Dict, Set
from jupyter_client.kernelspecapp import InstallKernelSpec
Expand Down Expand Up @@ -48,6 +49,7 @@ class ToreeInstall(InstallKernelSpec):
jupyter toree install
jupyter toree install --spark_home=/spark/home/dir
jupyter toree install --spark_opts='--master=local[4]'
jupyter toree install --kernel_opts='-- -Xmax-classfile-name 170'
jupyter toree install --kernel_name=toree_special
jupyter toree install --toree_opts='--nosparkcontext'
jupyter toree install --interpreters=PySpark,SQL
Expand All @@ -69,6 +71,9 @@ class ToreeInstall(InstallKernelSpec):
spark_opts = Unicode('', config=True,
help='''Specify command line arguments to proxy for spark config.'''
)
kernel_opts = Unicode('', config=True,
help='''Specify command line arguments to pass to the interpreter'''
)
python_exec = Unicode('python', config=True,
help='''Specify the python executable. Defaults to "python"'''
)
Expand All @@ -77,6 +82,7 @@ class ToreeInstall(InstallKernelSpec):
'spark_home': 'ToreeInstall.spark_home',
'toree_opts': 'ToreeInstall.toree_opts',
'spark_opts': 'ToreeInstall.spark_opts',
'kernel_opts': 'ToreeInstall.kernel_opts',
'interpreters' : 'ToreeInstall.interpreters',
'python_exec' : 'ToreeInstall.python_exec'
}
Expand All @@ -97,7 +103,8 @@ def create_kernel_json(self, location, interpreter):
interpreter_lang = INTERPRETER_LANGUAGES[interpreter]
kernel_spec.display_name = '{} - {}'.format(self.kernel_name, interpreter)
kernel_spec.language = interpreter_lang
kernel_spec.argv = [os.path.join(location, 'bin', 'run.sh'), '--profile', '{connection_file}']
kernel_spec.argv = [os.path.join(location, 'bin', 'run.sh'), '--profile', '{connection_file}'] + \
shlex.split(self.kernel_opts)
kernel_spec.env = {
DEFAULT_INTERPRETER : interpreter,
# The SPARK_OPTS values are stored in TOREE_SPARK_OPTS to allow the two values to be merged when kernels
Expand Down