Commit abbfa2a6 authored by Theresa Pollinger's avatar Theresa Pollinger
Browse files

made metakernel installable

parent fff3efd0
**MetaKernel Echo** is a Jupyter kernel using MetaKernel magics, shell, help, and parallel processing tools. This code provides an example MetaKernel kernel.
## Install
First, you need to install the metakernel_echo library and dependencies:
```shell
pip install metakernel_echo --upgrade
```
Then, you need to install the metakernel echo kernel spec:
```shell
python metakernel_echo install
```
## Running
You can then run the metakernel_echo kernel as a console, notebook, etc.:
```shell
jupyter console --kernel=metakernel_echo
```
## Dependencies
1. IPython 3
1. MetaKernel (installed with pip)
import argparse
import json
import os
import sys
from jupyter_client.kernelspec import KernelSpecManager
from IPython.utils.tempdir import TemporaryDirectory
kernel_json = {
"argv": [sys.executable, "-m", "interview_kernel", "-f", "{connection_file}"],
"display_name": "Interview",
"language": "text",
}
def install_my_kernel_spec(user=True, prefix=None):
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
# TODO: Copy any resources
print('Installing Jupyter kernel spec')
KernelSpecManager().install_kernel_spec(td, 'Interview', user=user, replace=True, prefix=prefix)
def _is_root():
try:
return os.geteuid() == 0
except AttributeError:
return False # assume not an admin on non-Unix platforms
def main(argv=None):
ap = argparse.ArgumentParser()
ap.add_argument('--user', action='store_true',
help="Install to the per-user kernels registry. Default if not root.")
ap.add_argument('--sys-prefix', action='store_true',
help="Install to sys.prefix (e.g. a virtualenv or conda env)")
ap.add_argument('--prefix',
help="Install to the given prefix. "
"Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/")
args = ap.parse_args(argv)
if args.sys_prefix:
args.prefix = sys.prefix
if not args.prefix and not _is_root():
args.user = True
install_my_kernel_spec(user=args.user, prefix=args.prefix)
if __name__ == '__main__':
main()
extension info.kwarc.mmt.interviews.InterviewServer
server on 55555
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