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

#5859 Use python string templates instead of ad hoc for classpath in kernelspecs #5981

Merged
merged 7 commits into from
Sep 19, 2017

Conversation

rbidas
Copy link
Contributor

@rbidas rbidas commented Sep 15, 2017

No description provided.

@@ -1,5 +1,5 @@
{
"argv": [ "java", "-jar", "__PATH__", "{connection_file}" ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this file should be deleted since the base kernel never runs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -1,5 +1,5 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -57,7 +57,7 @@ subprojects {
ext.executeStaticContent = true
doLast {
if (executeStaticContent) {
def kernelJson = file('kernel.json').text.replace('__MAIN_CLASS__', mainClassName)
def kernelJson = file('kernel.json').text.replace('$MAIN_CLASS', '"' + mainClassName + '"')
Copy link
Contributor

@scottdraves scottdraves Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a variable for main class at all?
since we have a kernel.json file for each kernel and we know the class for each kernel, this substitution is not needed right? just put the class name into the kernel.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -323,14 +324,10 @@ def install_kernel(source_kernelspec='', kernelspec_name=None):
classpath = (os.path.abspath(os.path.join(target_dir, 'base', 'lib', '*')) + (';' if sys.platform == 'win32' else ':') + os.path.abspath(os.path.join(target_dir, name, 'lib', '*'))).replace('\\', '/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use json.dumps and OS independent logic the same as install.py does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

template = pkg_resources.resource_string(
'beakerx', os.path.join('static', 'kernel', kernel, 'kernel.json'))
contents = template.decode().replace('__PATH__', classpath)
contents = Template(template.decode()).substitute(PATH="\"" + classpath + "\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right, json.dumps returns a value with quotes already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -32,10 +33,14 @@ def _all_kernels():
'beakerx', os.path.join('static', 'kernel'))
return [kernel for kernel in kernels if kernel != 'base']

def convert_path(path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be needed, that is the main point of this PR.
the reason for converting backslash to forward slash is because the old code was not adding quotes as needed.
but now that we are using json.dumps, it should insert the quotes for us, so we should not need to have special case handling for windows.

@@ -1,6 +1,6 @@
{
"argv": [
"java", "-cp", "__PATH__", "__MAIN_CLASS__", "{connection_file}"
"java", "-cp", ${PATH}, "com.twosigma.beakerx.groovy.kernel.Groovy", "{connection_file}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks these look good now

@scottdraves scottdraves merged commit 82d2d04 into master Sep 19, 2017
@rbidas rbidas deleted the rbidas/5859 branch December 18, 2017 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants