Commit c2727304 authored by Thierry Martinez's avatar Thierry Martinez
Browse files
parents af524052 0a3e3121
......@@ -61,6 +61,9 @@ biocham_tests: swipl-biocham $(MODULES) $(TEST_MODULES) Makefile
--goal="call_cleanup((run_tests, halt(0)), halt(1))" \
-c $(MODULES) $(TEST_MODULES)
jupyter: biocham
jupyter kernelspec install --user --name=biocham biocham_kernel
clean:
- make -C modules/graphviz clean
- make -C modules/sbml clean
......
if __name__ == '__main__':
from ipykernel.kernelapp import IPKernelApp
from .kernel import BiochamKernel
IPKernelApp.launch_instance(kernel_class=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(['biocham4', '--version']).decode('utf-8')
language_version = banner.split()[1]
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._start_biocham()
def _start_biocham(self):
self.biocham = replwrap.REPLWrapper( 'biocham4 --jupyter', 'biocham: ', 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': {},
}
# TODO: do_complete
......@@ -60,6 +60,17 @@ option('', '--generate-doc', Arg, Arg) :-
generate_doc,
quit.
option('', '--version', Arg, Arg) :-
quit.
option('', '--jupyter', Arg, Arg) :-
set_counter(plot_png, 0),
set_counter(graph_svg, 0),
set_plot_driver(gnu_plot_png),
set_image_viewer_driver(img_tag),
set_draw_graph_driver(graph_svg).
add_files(Files) :-
\+ (
member(File, Files),
......
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