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 nexedi/slapos!206
parent 4dec1979
#!{{ python_executable }}
from ipykernel.kernelbase import Kernel from ipykernel.kernelbase import Kernel
from ipykernel.kernelapp import IPKernelApp from ipykernel.kernelapp import IPKernelApp
from IPython.core.display import HTML from IPython.core.display import HTML
import requests import requests
import json import json
import sys
# erp5_url from buildout erp5_url = None
erp5_url = "{{ erp5_url }}" if len(sys.argv) > 1:
if not erp5_url: erp5_url = "%s/erp5/Base_executeJupyter" % (sys.argv[1],)
erp5_url = None
else:
erp5_url = "%s/erp5/Base_executeJupyter" % erp5_url
class MagicInfo: class MagicInfo:
""" """
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[instance-jupyter-notebook] [instance-jupyter-notebook]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = a2116d236542e139aa446a6b88db3d28 md5sum = f03d67d3e50a6b5d4572a167dc784bc1
[jupyter-notebook-config] [jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja filename = jupyter_notebook_config.py.jinja
...@@ -27,12 +27,12 @@ filename = jupyter_set_password.cgi.jinja ...@@ -27,12 +27,12 @@ filename = jupyter_set_password.cgi.jinja
md5sum = b8d31441780b524a7e52d1710dd78385 md5sum = b8d31441780b524a7e52d1710dd78385
[erp5-kernel] [erp5-kernel]
filename = ERP5kernel.py.jinja filename = ERP5kernel.py
md5sum = 8bd16cc9f35b00172e8266f1cde5956f md5sum = 7d5309fe79afbcb455c0d8181b42e56c
[kernel-json] [kernel-json]
filename = kernel.json.jinja filename = kernel.json.jinja
md5sum = ab6e78ea20855e07d388b5b86d1770fe md5sum = 33547be93a67530165e079dc3ecfdac3
[custom-js] [custom-js]
filename = custom.js.jinja filename = custom.js.jinja
......
...@@ -129,13 +129,9 @@ recipe = slapos.cookbook:publish.serialised ...@@ -129,13 +129,9 @@ recipe = slapos.cookbook:publish.serialised
url = https://[${instance-parameter:host}]:${instance-parameter:port} url = https://[${instance-parameter:host}]:${instance-parameter:port}
[erp5-kernel] [erp5-kernel]
<= dynamic-jinja2-template-base recipe = slapos.cookbook:symbolic.link
template = {{ erp5_kernel_location }}/{{ erp5_kernel_filename }} link-binary = {{ erp5_kernel_location }}/{{ erp5_kernel_filename }}
rendered = ${directory:erp5_kernel_dir}/ERP5kernel.py target-directory = ${directory:erp5_kernel_dir}
# 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
[kernel-json] [kernel-json]
<= dynamic-jinja2-template-base <= dynamic-jinja2-template-base
...@@ -144,7 +140,8 @@ rendered = ${directory:erp5_kernel_dir}/kernel.json ...@@ -144,7 +140,8 @@ rendered = ${directory:erp5_kernel_dir}/kernel.json
# Use python2.7 executable bin file for kernel config # Use python2.7 executable bin file for kernel config
context = context =
raw python_executable {{ python_executable }} 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 display_name ERP5
raw language_name python raw language_name python
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"argv": [ "argv": [
"{{python_executable}}", "{{python_executable}}",
"{{kernel_dir}}", "{{kernel_dir}}",
"{{erp5_url}}",
"-f", "-f",
"{connection_file}" "{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