Commit 554dc32d authored by Łukasz Nowak's avatar Łukasz Nowak

jupyter: Simplify ERP5kernel maintenance

Instead of templating python code, make it static and parameterize it
with parameters.

kernel.json can pass default ERP5 url, which is (dirty) read by
ERP5kernel. Additionally ERP5kernel.py is just linked into kernel
directory, which simplifies debugging.

Note: This commit is still dirty, but it prepares ERP5kernel.py to be
      packaged, thus there is no reason to make more changes and
      cleanup.

/reviewed-on !206
parent 4dec1979
#!{{ python_executable }}
from ipykernel.kernelbase import Kernel
from ipykernel.kernelapp import IPKernelApp
from IPython.core.display import HTML
import requests
import json
import sys
# erp5_url from buildout
erp5_url = "{{ erp5_url }}"
if not erp5_url:
erp5_url = None
else:
erp5_url = "%s/erp5/Base_executeJupyter" % erp5_url
erp5_url = None
if len(sys.argv) > 1:
erp5_url = "%s/erp5/Base_executeJupyter" % (sys.argv[1],)
class MagicInfo:
"""
......
......@@ -16,7 +16,7 @@
[instance-jupyter-notebook]
filename = instance.cfg.in
md5sum = a2116d236542e139aa446a6b88db3d28
md5sum = f03d67d3e50a6b5d4572a167dc784bc1
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
......@@ -27,12 +27,12 @@ filename = jupyter_set_password.cgi.jinja
md5sum = b8d31441780b524a7e52d1710dd78385
[erp5-kernel]
filename = ERP5kernel.py.jinja
md5sum = 8bd16cc9f35b00172e8266f1cde5956f
filename = ERP5kernel.py
md5sum = 7d5309fe79afbcb455c0d8181b42e56c
[kernel-json]
filename = kernel.json.jinja
md5sum = ab6e78ea20855e07d388b5b86d1770fe
md5sum = 33547be93a67530165e079dc3ecfdac3
[custom-js]
filename = custom.js.jinja
......
......@@ -129,13 +129,9 @@ recipe = slapos.cookbook:publish.serialised
url = https://[${instance-parameter:host}]:${instance-parameter:port}
[erp5-kernel]
<= dynamic-jinja2-template-base
template = {{ erp5_kernel_location }}/{{ erp5_kernel_filename }}
rendered = ${directory:erp5_kernel_dir}/ERP5kernel.py
# Use ipython as executable python as we'll be needing requests library in kernel
context =
raw python_executable {{ bin_directory }}/ipython
key erp5_url slapconfiguration:configuration.erp5-url
recipe = slapos.cookbook:symbolic.link
link-binary = {{ erp5_kernel_location }}/{{ erp5_kernel_filename }}
target-directory = ${directory:erp5_kernel_dir}
[kernel-json]
<= dynamic-jinja2-template-base
......@@ -144,7 +140,8 @@ rendered = ${directory:erp5_kernel_dir}/kernel.json
# Use python2.7 executable bin file for kernel config
context =
raw python_executable {{ python_executable }}
key kernel_dir erp5-kernel:rendered
raw kernel_dir ${erp5-kernel:target-directory}/{{ erp5_kernel_filename }}
key erp5_url slapconfiguration:configuration.erp5-url
raw display_name ERP5
raw language_name python
......
......@@ -2,6 +2,7 @@
"argv": [
"{{python_executable}}",
"{{kernel_dir}}",
"{{erp5_url}}",
"-f",
"{connection_file}"
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment