npm.io
0.0.17 • Published 4 years ago

aiffel-jupyter-kernel

Licence
ISC
Version
0.0.17
Deps
8
Size
68 kB
Vulns
0
Weekly
0

aiffel-jupyter-kernel

Get Started

Installation

$ yarn add aiffel-jupyter-kernel
Connect to jupyter
const connector = new KernelConnector()
connector.connect({
    baseUrl: 'http://127.0.0.1:8888', // Jupyter url
    token: 'token' // Jupyter token
})
Execute code
const response = connector.requestExecute({
    code: value || '',
    allow_stdin: true,
    silent: false,
    stop_on_error: true,
    store_history: true,
})
Render execution response
<CodeExecuteResponse response={response} />
KernelConnector hook
type Props = {
    connector: KernelConnector
}

/*
This component will be rendered when the KernelConnector's runningStatus or connectionState changes.
*/
export default function Something({ connector }: Props) {
    const { runningStatus, connectionState } = useKernelConnector(connector)
    ...
}
Debug window
  1. add DEBUG_JUPYTER_KERNEL to localStorage
  2. render <DebugWindow kernelConnector={connector}/>

When develop this package

scripts

$ yarn watch
$ cd ./example
$ yarn start

Reference