How to use the @jupyterlab/services.Kernel.getSpecs 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 nteract / hydrogen / lib / ws-kernel-picker.js View on Github external
emptyMessage: "No sessions available"
    });

    const gatewayOptions = Object.assign(
      {
        xhrFactory: () => new xhr.XMLHttpRequest(),
        wsFactory: (url, protocol) => new ws(url, protocol)
      },
      gatewayInfo.options
    );

    let serverSettings = ServerConnection.makeSettings(gatewayOptions);
    let specModels;

    try {
      specModels = await Kernel.getSpecs(serverSettings);
    } catch (error) {
      // The error types you get back at this stage are fairly opaque. In
      // particular, having invalid credentials typically triggers ECONNREFUSED
      // rather than 403 Forbidden. This does some basic checks and then assumes
      // that all remaining error types could be caused by invalid credentials.
      if (!error.xhr || !error.xhr.responseText) {
        throw error;
      } else if (error.xhr.responseText.includes("ETIMEDOUT")) {
        atom.notifications.addError("Connection to gateway failed");
        this.listView.cancel();
        return;
      } else {
        const promptSucceeded = await this.promptForCredentials(gatewayOptions);
        if (!promptSucceeded) {
          return;
        }
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should omit an invalid kernelspec', async () => {
      const R_SPEC = JSON.parse(JSON.stringify(PYTHON_SPEC));
      R_SPEC.name = 1;
      const serverSettings = getRequestHandler(200, {
        default: 'python',
        kernelspecs: {
          R: R_SPEC,
          python: PYTHON_SPEC
        }
      });
      const specs = await Kernel.getSpecs(serverSettings);
      expect(specs.default).to.equal('python');
      expect(specs.kernelspecs['R']).to.be.undefined;
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should handle a missing default parameter', async () => {
      const serverSettings = getRequestHandler(200, {
        kernelspecs: { python: PYTHON_SPEC }
      });
      const specs = await Kernel.getSpecs(serverSettings);
      expect(specs.default).to.be.ok;
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should load the kernelspecs', async () => {
      const specs = await Kernel.getSpecs();
      expect(specs.default).to.be.ok;
    });
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 specs = await Kernel.getSpecs(serverSettings);
      expect(specs.default).to.be.ok;
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should handle an improper display_name', async () => {
      const R_SPEC = JSON.parse(JSON.stringify(PYTHON_SPEC));
      R_SPEC.spec.display_name = ['hello'];
      const serverSettings = getRequestHandler(200, {
        default: 'R',
        kernelspecs: { R: R_SPEC }
      });
      const promise = Kernel.getSpecs(serverSettings);
      await expectFailure(promise, 'No valid kernelspecs found');
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should load the kernelspecs', async () => {
      const specs = await Kernel.getSpecs();
      expect(specs.default).to.be.ok;
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should handle an improper language', async () => {
      const R_SPEC = JSON.parse(JSON.stringify(PYTHON_SPEC));
      R_SPEC.spec.language = 1;
      const serverSettings = getRequestHandler(200, {
        default: 'R',
        kernelspecs: { R: R_SPEC }
      });
      const promise = Kernel.getSpecs(serverSettings);
      await expectFailure(promise, 'No valid kernelspecs found');
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should handle a missing default parameter', async () => {
      const serverSettings = getRequestHandler(200, {
        kernelspecs: { python: PYTHON_SPEC }
      });
      const specs = await Kernel.getSpecs(serverSettings);
      expect(specs.default).to.be.ok;
    });
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))