How to use the @jupyterlab/apputils.ClientSession function in @jupyterlab/apputils

To help you get started, we’ve selected a few @jupyterlab/apputils 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 jupyterlab / jupyterlab-data-explorer / tests / test-apputils / src / clientsession.spec.ts View on Github external
it('should connect to an existing kernel', async () => {
        // Shut down and dispose the session so it can be re-instantiated.
        await session.shutdown();
        session.dispose();

        const other = await manager.startNew({ path: UUID.uuid4() });
        const kernelPreference = { id: other.kernel.id };

        session = new ClientSession({ manager, kernelPreference });
        await session.initialize();
        expect(session.kernel.id).to.equal(other.kernel.id);
        // We don't call other.shutdown() here because that
        // is handled by the afterEach() handler above.
        other.dispose();
      });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / examples / cell / src / index.ts View on Github external
function main(): void {
  const manager = new SessionManager();
  const session = new ClientSession({ manager, name: 'Example' });
  const mimeService = new CodeMirrorMimeTypeService();

  // Initialize the command registry with the bindings.
  const commands = new CommandRegistry();
  const useCapture = true;

  // Setup the keydown listener for the document.
  document.addEventListener(
    'keydown',
    event => {
      commands.processKeydownEvent(event);
    },
    useCapture
  );

  // Create the cell widget with a default rendermime instance.
github jupyterlab / jupyterlab / examples / cell / src / index.ts View on Github external
function main(): void {
  const manager = new SessionManager();
  const session = new ClientSession({ manager, name: 'Example' });
  const mimeService = new CodeMirrorMimeTypeService();

  // Initialize the command registry with the bindings.
  const commands = new CommandRegistry();
  const useCapture = true;

  // Setup the keydown listener for the document.
  document.addEventListener(
    'keydown',
    event => {
      commands.processKeydownEvent(event);
    },
    useCapture
  );

  // Create the cell widget with a default rendermime instance.
github jupyterlab / jupyterlab-data-explorer / tests / test-apputils / src / clientsession.spec.ts View on Github external
beforeEach(() => {
      Dialog.flush();
      session = new ClientSession({
        manager,
        kernelPreference: { name: manager.specs.default }
      });
    });
github yuvipanda / simplest-notebook / tests / utils.ts View on Github external
export async function createClientSession(
  options: Partial = {}
): Promise {
  const manager = options.manager || Private.manager.sessions;

  await manager.ready;
  return new ClientSession({
    manager,
    path: options.path || UUID.uuid4(),
    name: options.name,
    type: options.type,
    kernelPreference: options.kernelPreference || {
      shouldStart: true,
      canStart: true,
      name: manager.specs.default
    }
  });
}
github jupyterlab / jupyterlab / testutils / src / index.ts View on Github external
export async function createClientSession(
  options: Partial = {}
): Promise {
  const manager = options.manager || Private.getManager().sessions;

  await manager.ready;
  return new ClientSession({
    manager,
    path: options.path || UUID.uuid4(),
    name: options.name,
    type: options.type,
    kernelPreference: options.kernelPreference || {
      shouldStart: true,
      canStart: true,
      name: manager.specs.default
    }
  });
}
github jupyterlab / jupyterlab / tests / test-apputils / src / clientsession.spec.ts View on Github external
beforeEach(() => {
      Dialog.flush();
      session = new ClientSession({
        manager,
        kernelPreference: { name: manager.specs.default }
      });
    });
github yuvipanda / simplest-notebook / packages / console / src / panel.ts View on Github external
constructor(options: ConsolePanel.IOptions) {
    super();
    this.addClass(PANEL_CLASS);
    let {
      rendermime, mimeTypeService, path, basePath, name, manager, modelFactory
    } = options;
    let contentFactory = this.contentFactory = (
      options.contentFactory || ConsolePanel.defaultContentFactory
    );
    let count = Private.count++;
    if (!path) {
      path = `${basePath || ''}/console-${count}-${uuid()}`;
    }

    let session = this._session = new ClientSession({
      manager: manager.sessions,
      path,
      name: name || `Console ${count}`,
      type: 'console',
      kernelPreference: options.kernelPreference
    });

    let resolver = new RenderMime.UrlResolver({
      session,
      contents: manager.contents
    });
    rendermime = rendermime.clone({ resolver });

    this.console = contentFactory.createConsole({
      rendermime, session, mimeTypeService, contentFactory, modelFactory
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / console / src / panel.ts View on Github external
rendermime,
      mimeTypeService,
      path,
      basePath,
      name,
      manager,
      modelFactory
    } = options;
    let contentFactory = (this.contentFactory =
      options.contentFactory || ConsolePanel.defaultContentFactory);
    let count = Private.count++;
    if (!path) {
      path = `${basePath || ''}/console-${count}-${UUID.uuid4()}`;
    }

    let session = (this._session = new ClientSession({
      manager: manager.sessions,
      path,
      name: name || `Console ${count}`,
      type: 'console',
      kernelPreference: options.kernelPreference,
      setBusy: options.setBusy
    }));

    let resolver = new RenderMimeRegistry.UrlResolver({
      session,
      contents: manager.contents
    });
    rendermime = rendermime.clone({ resolver });

    this.console = contentFactory.createConsole({
      rendermime,
github jupyterlab / jupyterlab / packages / docregistry / src / context.ts View on Github external
let dbFactory = options.modelDBFactory;
    if (dbFactory) {
      const localPath = manager.contents.localPath(this._path);
      this._modelDB = dbFactory.createNew(localPath);
      this._model = this._factory.createNew(lang, this._modelDB);
    } else {
      this._model = this._factory.createNew(lang);
    }

    this._readyPromise = manager.ready.then(() => {
      return this._populatedPromise.promise;
    });

    let ext = PathExt.extname(this._path);
    this.session = new ClientSession({
      manager: manager.sessions,
      path: this._path,
      type: ext === '.ipynb' ? 'notebook' : 'file',
      name: PathExt.basename(localPath),
      kernelPreference: options.kernelPreference || { shouldStart: false },
      setBusy: options.setBusy
    });
    this.session.propertyChanged.connect(this._onSessionChanged, this);
    manager.contents.fileChanged.connect(this._onFileChanged, this);

    this.urlResolver = new RenderMimeRegistry.UrlResolver({
      session: this.session,
      contents: manager.contents
    });
  }