JupyterContext
Extends:
An execution context using Jupyter kernels
This class of execution context acts as a bridge between Stencila and
Jupyter kernels. It exposes methods of the Stencila Context API e.g. executeEval
which delegate execution to a Jupyter kernel. This is done via the
Jupyter Messageing Protocol (JMP)
over ZeroMQ sockets.
The discover static method should be called initially to find all Jupyter kernels
currently installed on the machine and update JupyterContext.spec.kernels:
JupyterContext.discover()
New Jupyter execution contexts can be constructed using the language option which will
search for a kernel with a matching lowercased language property:
new JupyterContext({language:'r'})
Alternively, you can specify a kernel directly:
new JupyterContext({kernel:'ir'})
See https://github.com/jupyter/jupyter/wiki/Jupyter-kernels for a list of available Jupyter kernels.
Many thanks to the nteract community for kernelspecs and
spawnteract, and to Nicolas Riesco for (jmp)[https://github.com/n-riesco/jmp],
all of which made this implementation far easier!
Static Method Summary
| Static Public Methods | ||
| public static |
Discover Jupyter kernels on the current machine |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: Object) Construct a Jupyter execution context |
|
Member Summary
| Public Members | ||
| public |
debug: * |
|
| public |
kernel: * |
|
| public |
timeout: * |
|
| Private Members | ||
| private |
_config: * |
|
| private |
|
|
| private |
_ioSocket: * |
|
| private |
_kernelInfo: * |
|
| private |
_process: * |
|
| private |
_requests: {} |
|
| private |
_sessionId: * |
|
| private |
_shellSocket: * |
|
| private |
_spec: * |
|
Method Summary
| Public Methods | ||
| public |
async execute(cell: *): * Execute a cell |
|
| public |
Finalize the context |
|
| public |
Initialize the context |
|
| Private Methods | ||
| private |
Send a request message to the kernal |
|
| private |
_response(response: Message) Receive a response message from the kernel |
|
| private |
Convert a "MIME bundle" within a JMP message (e.g. |
|
Inherited Summary
| From class Context | ||
| public get |
host: * |
|
| public get |
id: * |
|
| public get |
location: {"context": *, "host": *, "machine": *} |
|
| public get |
name: * |
|
| private |
_host: * |
|
| private |
|
|
| private |
_name: * |
|
| private |
_variables: {} |
|
| public |
async compile(cell: *): {"source": *, "expr": *, "global": *, "options": *, "inputs": *, "outputs": *, "messages": *} |
|
| public |
async evaluate(node: *): * |
|
| public |
async execute(cell: *): * |
|
| public |
async libraries(): {} |
|
| public |
async pack(value: *): * |
|
| public |
async packPackage(value: *): {"type": *, "data": *} |
|
| public |
async packPointer(objectPattern: {"type": *, "name": *, "preview": *}): {"type": *, "path": *, "preview": *} |
|
| public |
async provide(what: *): * |
|
| public |
async resolve(what: *): * |
|
| public |
Unpack a data node into a native data value |
|
| public |
async unpackPackage(pkg: *): * |
|
| public |
async unpackPointer(pointer: *): * |
|
Static Public Methods
Public Constructors
public constructor(options: Object) source
Construct a Jupyter execution context
Override:
Context#constructorParams:
| Name | Type | Attribute | Description |
| options | Object | Options for specifying which kernel to use |
Public Members
public debug: * source
public kernel: * source
public timeout: * source
Private Members
private _config: * source
private _connectionFile: * source
private _ioSocket: * source
private _kernelInfo: * source
private _process: * source
private _requests: {} source
private _sessionId: * source
private _shellSocket: * source
private _spec: * source
Public Methods
public async execute(cell: *): * source
Execute a cell
For cells with expr: true utilises user_expressions property of an execute_request to
evaluate expression side-effect free.
Override:
Context#executeParams:
| Name | Type | Attribute | Description |
| cell | * |
Return:
| * |
Private Methods
private _request(requestType: String, content: Object, responseTypes: String): Promise source
Send a request message to the kernal
private _response(response: Message) source
Receive a response message from the kernel
Params:
| Name | Type | Attribute | Description |
| response | Message | Response message |
