Commit b078e528 authored by Ayush Tiwari's avatar Ayush Tiwari

Initial *buildout for ipython notebook with ERP5 kernel.

parent 320c474d
......@@ -58,6 +58,8 @@ service = $${:etc}/service
promise = $${:etc}/promise/
# Path of the log directory used by our service (see [hello-world])
log = $${:var}/log
# Path of IPython directory in which ERP5 kernel will be running
ipython-directory = $${:home}/.ipython/kernels
# Create a simple web server that says "hello <configuration.name>" to the web.
......@@ -103,4 +105,4 @@ port = $${hello-world:port}
[publish-connection-parameter]
recipe = slapos.cookbook:publish
name = Hello $${instance-parameter:configuration.name}!
url = $${hello-world:url}
url = $${hello-world:url}
\ No newline at end of file
......@@ -23,6 +23,8 @@ parts =
## Monitor for ipython
monitor-current-log-access
monitor-deploy-set-password-cgi
erp5-kernel
kernel-json
extends = ${monitor-template:output}
......@@ -75,6 +77,7 @@ command-line =
--notebook-dir=$${instance-parameter:notebook_dir}
--logfile=$${instance-parameter:logfile}
--config=$${ipython_notebook_config:rendered}
--log-level="DEBUG"
wrapper-path = $${directory:service}/ipython_notebook
parameters-extra = true
......@@ -85,6 +88,7 @@ rendered = $${directory:etc}/ipython_notebook_config.py
mode = 0744
context =
raw config_cfg $${buildout:directory}/knowledge0.cfg
raw ipython_dir $${directory:ipython_dir}
[monitor-current-log-access]
< = monitor-directory-access
......@@ -113,8 +117,29 @@ service = $${:etc}/service
promise = $${:etc}/promise/
log = $${:var}/log
notebook_dir = $${:var}/notebooks
ipython_dir = $${:home}/.ipython
ipython_kernel_dir = $${:ipython_dir}/kernels
erp5_kernel_dir = $${:ipython_kernel_dir}/ERP5
[publish-connection-parameter]
recipe = slapos.cookbook:publish
url = https://[$${instance-parameter:host}]:$${instance-parameter:port}
monitor_url = $${monitor-parameters:url}
[erp5-kernel]
recipe = slapos.recipe.template:jinja2
template = ${erp5-kernel:location}/${erp5-kernel:filename}
rendered = $${directory:erp5_kernel_dir}/ERP5kernel.py
mode = 0744
context =
raw python_executable ${buildout:bin-directory}/ipython
[kernel-json]
recipe = slapos.recipe.template:jinja2
template = ${kernel-json:location}/${kernel-json:filename}
rendered = $${directory:erp5_kernel_dir}/kernel.json
mode = 0744
context =
raw python_executable ${buildout:bin-directory}/ipython
raw kernel_dir $${directory:erp5_kernel_dir}/ERP5kernel.py
raw display_name ERP5
\ No newline at end of file
......@@ -32,7 +32,7 @@ initialization +=
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
download-only = true
md5sum = a5bc4ee8539109d1de7ab33b4c2c97ea
md5sum = b056616e962b2fe1fa523ddd658b0f1b
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = ipython_notebook_config.jinja
mode = 0644
......@@ -51,8 +51,23 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/instance.cfg
[erp5-kernel]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
download-only = true
md5sum = 460206edb2fc6b21e065b6cbd1475f1a
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = ERP5kernel.py.jinja
mode = 0644
[kernel-json]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
download-only = true
md5sum = 0f77ab5399990ebb25f95f969cb4b7cb
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = kernel.json.jinja
mode = 0644
[versions]
PyRSS2Gen = 1.1
......
#!{{python_executable}}
from IPython.kernel.zmq.kernelbase import Kernel
from IPython.display import display_javascript
from IPython.core.display import HTML
class ERP5Kernel(Kernel):
implementation = 'ERP5'
implementation_version = '1.0'
language = 'ERP5'
language_version = '0.1'
language_info = {'mimetype': 'text/plain', 'name':'python'}
banner = "ERP5 integration with ipython notebook"
def do_execute(self, code, silent, store_history=True, user_expressions=None,
allow_stdin=False):
if not silent:
import requests
res = requests.get('https://zope:insecure@softinst60318.host.vifib.net/erp5/data_set_module/wendelin_1/Base_executePython', verify=False, params={'python_expression': code})
code_result = res.text
data = {
'data': {'text/html': code_result},
'metadata': {}
}
self.send_response(self.iopub_socket, 'display_data', data)
return {'status': 'ok',
# The base class increments the execution count
'execution_count': self.execution_count,
'payload': [],
'user_expressions': {},
}
if __name__ == '__main__':
from IPython.kernel.zmq.kernelapp import IPKernelApp
IPKernelApp.launch_instance(kernel_class=ERP5Kernel)
else:
from IPython.kernel.zmq.kernelapp import IPKernelApp
......@@ -11,3 +11,9 @@ parser.read(knowledge_0)
if parser.has_option("ipython_notebook", "password"):
c.NotebookApp.password = parser.get("ipython_notebook", "password")
# The name of the IPython directory. This directory is used for logging
# configuration (through profiles), history storage, etc. The default is usually
# $HOME/.ipython. This options can also be specified through the environment
# variable IPYTHONDIR.
c.IPKernelApp.ipython_dir = unicode('{{ ipython_dir }}')
c.NotebookApp.ipython_dir = unicode('{{ ipython_dir }}')
\ No newline at end of file
{
"argv": [
"{{python_executable}}",
"{{kernel_dir}}",
"-f",
"{connection_file}"
],
"display_name": "{{display_name}}",
"language": "python",
"language_info": {"name": "python"}
}
\ No newline at end of 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