Commit da236fdd authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain
Browse files

add a jupyter kernel creation option

parent baf85283
......@@ -60,6 +60,9 @@ biocham_tests: swipl-biocham $(MODULES) $(TEST_MODULES) Makefile
--goal="call_cleanup((run_tests, halt(0)), halt(1))" \
jupyter: biocham
jupyter kernelspec install --user --name=biocham biocham_kernel
- make -C modules/graphviz clean
- make -C modules/sbml clean
if __name__ == '__main__':
from ipykernel.kernelapp import IPKernelApp
from .kernel import BiochamKernel
"argv": ["python3", "-m", "biocham_kernel", "-f", "{connection_file}"],
"display_name": "Biocham"
from subprocess import check_output
from ipykernel.kernelbase import Kernel
from pexpect import replwrap
class BiochamKernel(Kernel):
implementation = 'Biocham'
implementation_version = '0.1.0'
language = 'biocham'
language_info = {
'name': 'biocham',
'mimetype': 'text/plain',
'file_extension': '.bc',
banner = check_output(['biocham', '--version']).decode('utf-8')
language_version = banner.split()[1]
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
def _start_biocham(self):
self.biocham = replwrap.REPLWrapper( 'biocham', '\nbiocham: ', None)
def do_execute(self, code, silent, store_history=True,
user_expressions=None, allow_stdin=False):
output = self.biocham.run_command(code)
if not silent:
stream_content = {'name': 'stdout', 'text': output}
self.send_response(self.iopub_socket, 'stream', stream_content)
return {'status': 'ok',
# The base class increments the execution count
'execution_count': self.execution_count,
'payload': [],
'user_expressions': {},
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