How to use the @jupyterlab/services.Kernel.startNew function in @jupyterlab/services

To help you get started, we’ve selected a few @jupyterlab/services examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pymedphys / pymedphys / packages / pymedphys / src / pymedphys / gui / src / jupyter.tsx View on Github external
let contextManager = new ContextManager(context);

const rendermime = new RenderMimeRegistry({ initialFactories });
rendermime.addFactory({
  safe: true,  // false
  mimeTypes: [BOKEHJS_LOAD_MIME_TYPE],
  createRenderer: (options) => new BokehJSLoad(options)
}, 0);

rendermime.addFactory({
  safe: true,  // false
  mimeTypes: [BOKEHJS_EXEC_MIME_TYPE],
  createRenderer: (options) => new BokehJSExec(options, contextManager)
}, -1);

const kernelPromise = Kernel.startNew()



export class CodeButtons extends Component {

  outputDiv: React.RefObject

  constructor(props: any) {
    super(props);
    this.outputDiv = React.createRef();
    this.runCode = this.runCode.bind(this);
    this.matplotlib = this.matplotlib.bind(this);
    this.bokeh = this.bokeh.bind(this);
  }

  // componentDidMount() {
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should accept ajax options', async () => {
      const serverSettings = makeSettings();
      const kernel = await Kernel.startNew({ serverSettings });
      expect(kernel.status).to.equal('unknown');
      await kernel.shutdown();
    });
github jupyterlab / jupyterlab / test / src / outputarea / widget.spec.ts View on Github external
it('should create a stdin widget', () => {
          return Kernel.startNew().then(kernel => {
            let factory = new OutputAreaWidget.ContentFactory();
            let options = {
              prompt: 'hello',
              password: false,
              kernel
            };
            expect(factory.createStdin(options)).to.be.a(Widget);
            return kernel.shutdown().then(() => { kernel.dispose(); });
          });
        });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / manager.spec.ts View on Github external
it('should emit a runningChanged signal', async () => {
        let called = false;
        manager.runningChanged.connect(() => {
          called = true;
        });
        const k = await Kernel.startNew();
        manager.connectTo(k.model);
        expect(called).to.equal(true);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / comm.spec.ts View on Github external
beforeAll(async () => {
    kernel = await Kernel.startNew({ name: 'ipython' });
  });
github pbugnion / ipywidgets_server / js / WidgetApplication.js View on Github external
async renderWidgets() {
        let connectionInfo = ServerConnection.makeSettings({
            baseUrl : this._baseUrl,
            wsUrl : this._wsUrl
        });

        const kernelSpecs = await Kernel.getSpecs(connectionInfo)

        console.log(`Starting kernel ${kernelSpecs.default}`)

        const kernel = await Kernel.startNew({
            name: kernelSpecs.default,
            serverSettings: connectionInfo
        });

        this._kernel = kernel;

        const el = document.getElementById('ipywidget-server-result')
        const manager = new WidgetManager(kernel, el, this._loader);

        const errorEl = document.getElementById('ipywidget-server-errors')
        const errorView = new ErrorView(errorEl);
        manager.onError.connect((sender, msg) => errorView.showError(msg.content))

        const options = {
            msgType: 'custom_message',
            channel: 'shell'
github explosion / spaCy / website / src / components / juniper.js View on Github external
requestKernel(settings) {
        if (this.props.useStorage) {
            const timestamp = new Date().getTime() + this.props.storageExpire * 60 * 1000
            const json = JSON.stringify({ settings, timestamp })
            window.localStorage.setItem(this.props.storageKey, json)
        }
        const serverSettings = ServerConnection.makeSettings(settings)
        return Kernel.startNew({ type: this.props.kernelType, serverSettings }).then(kernel => {
            this.log(() => console.info('ready'))
            return kernel
        })
    }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / services / examples / typescript-browser-with-output / src / index.ts View on Github external
async function main() {
  const code = [
    'from IPython.display import HTML',
    'HTML("<h1>Hello, world!</h1>")'
  ].join('\n');
  const model = new OutputAreaModel();
  const rendermime = new RenderMimeRegistry({ initialFactories });
  const outputArea = new OutputArea({ model, rendermime });

  const kernel = await Kernel.startNew();
  outputArea.future = kernel.requestExecute({ code });
  document.getElementById('outputarea').appendChild(outputArea.node);
  await outputArea.future.done;
  console.log('Test complete!');
}
github jupyter-widgets / ipywidgets / examples / web-tmpnb / src / index.ts View on Github external
Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
                return Kernel.startNew({name: kernelSpecs.default, serverSettings: connectionInfo});
            }).then(kernel => {
github ines / juniper / src / index.js View on Github external
requestKernel(settings) {
        if (this.useStorage && typeof window !== 'undefined') {
            const timestamp = new Date().getTime() + this.storageExpire * 60 * 1000;
            const json = JSON.stringify({ settings, timestamp });
            window.localStorage.setItem(this.storageKey, json);
        }
        const serverSettings = ServerConnection.makeSettings(settings);
        return Kernel.startNew({ type: this.kernelType, name: this.kernelType, serverSettings })
            .then(kernel => {
                this._event('ready');
                return kernel;
            });
    }