Commit 8bd929ae authored by Theresa Pollinger's avatar Theresa Pollinger
Browse files

made the thing (hopefully) locally installable

parent 8a89e555
**MetaKernel Echo** is a Jupyter kernel using MetaKernel magics, shell, help, and parallel processing tools. This code provides an example MetaKernel kernel. **interview_kernel** is a Jupyter kernel using MetaKernel magics.
## Install ## Install
First, you need to install the metakernel_echo library and dependencies: from this directory, run
```shell
pip install interview_kernel --upgrade
```
Then, you need to install the metakernel echo kernel spec:
```shell ```shell
python interview_kernel install pip install interview_kernel
python setup.py install
cd interview_kernel
python install.py
``` ```
## Running ## Running
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,12 +17,10 @@ def install_my_kernel_spec(user=True, prefix=None): ...@@ -17,12 +17,10 @@ def install_my_kernel_spec(user=True, prefix=None):
os.chmod(td, 0o755) # Starts off as 700, not user readable os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f: with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True) json.dump(kernel_json, f, sort_keys=True)
# TODO: Copy any resources
try: try:
# copyfile('./kernel.js', os.path.join(td, 'kernel.js'))
interview = Interview() interview = Interview()
with open(os.path.join(td, 'kernel.js'), 'w') as f: with open(os.path.join(td, 'kernel.js'), 'w') as f:
# javascript code that sets an initial markdown cell # javascript code that sets an initial markdown cell in every new notebook
js = """define(['base/js/namespace'], function(Jupyter) js = """define(['base/js/namespace'], function(Jupyter)
{{ {{
function onload() function onload()
......
...@@ -13,14 +13,19 @@ from pylatexenc.latex2text import LatexNodes2Text ...@@ -13,14 +13,19 @@ from pylatexenc.latex2text import LatexNodes2Text
import getpass import getpass
from bokeh.io import output_notebook from bokeh.io import output_notebook
from pde_state_machine import * #from . import pde_state_machine
from string_handling import build_url, get_recursively import pde_state_machine
#from . import string_handling
import string_handling
from distutils.util import strtobool from distutils.util import strtobool
"""This is a Jupyter kernel derived from MetaKernel. To use it, install it with the install.py script and run """This is a Jupyter kernel derived from MetaKernel. To use it, install it with the install.py script and run
"jupyter notebook --debug --NotebookApp.token='' " from terminal. """ "jupyter notebook --debug --NotebookApp.token='' " from terminal. """
class Interview(MetaKernel): class Interview(MetaKernel):
implementation = 'Interview' implementation = 'Interview'
implementation_version = '0.1' implementation_version = '0.1'
language = 'text' language = 'text'
...@@ -55,7 +60,7 @@ Otherwise, you can always answer with \LaTeX-type input. ...@@ -55,7 +60,7 @@ Otherwise, you can always answer with \LaTeX-type input.
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.state_machine = PDE_States(self.poutput, self.update_prompt, self.please_prompt, self.display_html) self.state_machine = pde_state_machine.PDE_States(self.poutput, self.update_prompt, self.please_prompt, self.display_html)
# call superclass constructor # call superclass constructor
super(Interview, self).__init__(**kwargs) super(Interview, self).__init__(**kwargs)
...@@ -255,7 +260,7 @@ Otherwise, you can always answer with \LaTeX-type input. ...@@ -255,7 +260,7 @@ Otherwise, you can always answer with \LaTeX-type input.
url_args_dict = dict(type="pgraph", url_args_dict = dict(type="pgraph",
graphdata=self.state_machine.mmtinterface.namespace) graphdata=self.state_machine.mmtinterface.namespace)
# if applicable, highlight the ephemeral parts https://github.com/UniFormal/TGView/issues/25 # if applicable, highlight the ephemeral parts https://github.com/UniFormal/TGView/issues/25
thynames = get_recursively(self.state_machine.simdata, "theoryname") thynames = string_handling.get_recursively(self.state_machine.simdata, "theoryname")
# if thynames: # if thynames:
# url_args_dict["highlight"] = ",".join(thynames) # url_args_dict["highlight"] = ",".join(thynames)
# for now, highlight the "persistent ephemeral" theories, cf https://github.com/UniFormal/MMT/issues/326 # for now, highlight the "persistent ephemeral" theories, cf https://github.com/UniFormal/MMT/issues/326
...@@ -271,8 +276,8 @@ Otherwise, you can always answer with \LaTeX-type input. ...@@ -271,8 +276,8 @@ Otherwise, you can always answer with \LaTeX-type input.
# have the side bars go away # have the side bars go away
url_args_dict["viewOnlyMode"] = "true" url_args_dict["viewOnlyMode"] = "true"
tgview_url = build_url(server_url, "graphs/tgview.html", args_dict=url_args_dict) tgview_url = string_handling.build_url(server_url, "graphs/tgview.html", args_dict=url_args_dict)
#print(tgview_url) # print(tgview_url)
code = """ code = """
<iframe <iframe
......
...@@ -249,7 +249,7 @@ class PDE_States: ...@@ -249,7 +249,7 @@ class PDE_States:
##### for state domain ##### for state domain
def domain_begin(self): def domain_begin(self):
self.poutput("What is the domain in your model? Ω : type ❘ = [?;?], e.g. `\\Omega = [0.0;1.0]`") self.poutput("What is the domain in your model? Ω : type ❘ = [?;?], e.g. `\\\\Omega = [0.0;1.0]`")
# self.poutput("By the way, you can always try and use LaTeX-type input.") # self.poutput("By the way, you can always try and use LaTeX-type input.")
self.simdata[self.state]["axes"] = OrderedDict() self.simdata[self.state]["axes"] = OrderedDict()
self.domain_mmt_preamble() self.domain_mmt_preamble()
...@@ -950,6 +950,8 @@ class PDE_States: ...@@ -950,6 +950,8 @@ class PDE_States:
def recap(self, userstring=None): # TODO def recap(self, userstring=None): # TODO
self.print_simdata() self.print_simdata()
self.print_empty_line()
self.poutput("You can inspect the persistently loaded MMT theories under " + self.mmtinterface.mmt_base_url)
def print_simdata(self): def print_simdata(self):
self.poutput("These are the things we know so far about your problem:") self.poutput("These are the things we know so far about your problem:")
......
...@@ -9,7 +9,7 @@ from setuptools import setup ...@@ -9,7 +9,7 @@ from setuptools import setup
setup( setup(
name='interview_kernel', name='interview_kernel',
version='0.1.0', version='0.1.0',
packages=['interview_kernel', 'interview_kernel/exastencils'], packages=['interview_kernel'],
url='https://gl.kwarc.info/theresa_pollinger/MoSIS', url='https://gl.kwarc.info/theresa_pollinger/MoSIS',
license='MIT', license='MIT',
author='Theresa Pollinger', author='Theresa Pollinger',
...@@ -20,13 +20,12 @@ setup( ...@@ -20,13 +20,12 @@ setup(
# replicating contents of MANIFEST, # replicating contents of MANIFEST,
# cf.https://stackoverflow.com/questions/7522250/how-to-include-package-data-with-setuptools-distribute/14159430#14159430 # cf.https://stackoverflow.com/questions/7522250/how-to-include-package-data-with-setuptools-distribute/14159430#14159430
package_data={ package_data={
'interview_kernel/exastencils': ['interview_kernel/exastencils/compiler.jar', 'interview_kernel': ['interview_kernel/exastencils/compiler.jar',
'interview_kernel/exastencils/generate_compile_and_run_list.sh', 'interview_kernel/exastencils/generate_compile_and_run_list.sh',
'interview_kernel/exastencils/lib/*.*'], 'interview_kernel/exastencils/lib/*.*'],
}, },
zip_safe=False, zip_safe=False,
# use_scm_version=True, # use_scm_version=True,
setup_requires=['setuptools_scm'], # or possibly https://pypi.python.org/pypi/setuptools-git setup_requires=['setuptools_scm'], # or possibly https://pypi.python.org/pypi/setuptools-git
install_requires=['transitions', 'bokeh', 'requests', 'pylatexenc', 'metakernel', 'lxml', 'IPython', install_requires=['transitions', 'bokeh', 'requests', 'pylatexenc', 'metakernel', 'lxml', 'IPython', 'jupyter_client', 'ipywidgets']
'jupyter_client', 'ipywidgets']
) )
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