How to use the @jupyterlab/services.SessionManager 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 jupyterlab / jupyterlab / packages / services / examples / node / index.js View on Github external
var services = require('@jupyterlab/services');

// Start a new session.
var options = {
  path: 'foo.ipynb',
  type: 'notebook',
  name: 'foo.ipynb',
  kernel: {
    name: 'python'
  }
};

/* eslint-disable no-console */
console.log('Starting session...');
var kernelManager = new services.KernelManager();
var sessionManager = new services.SessionManager({ kernelManager });
var session;
sessionManager
  .startNew(options)
  .then(function(s) {
    // Rename the session.
    session = s;
    return session.setPath('bar.ipynb');
  })
  .then(function() {
    console.log('Session renamed to', session.path);
    // Execute and handle replies on the kernel.
    var future = session.kernel.requestExecute({ code: 'a = 1' });
    future.onReply = function(reply) {
      console.log('Got execute reply', reply);
    };
    return future.done;
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
  );
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / session / manager.spec.ts View on Github external
it('should get the server settings', () => {
        manager.dispose();
        const serverSettings = ServerConnection.makeSettings();
        const token = serverSettings.token;
        manager = new SessionManager({ serverSettings });
        expect(manager.serverSettings.token).to.equal(token);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / session / manager.spec.ts View on Github external
it('should test whether the manager is ready', async () => {
        manager.dispose();
        manager = new SessionManager();
        expect(manager.isReady).to.equal(false);
        await manager.ready;
        expect(manager.isReady).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-services / src / session / manager.spec.ts View on Github external
it('should get the server settings', () => {
        manager.dispose();
        const serverSettings = ServerConnection.makeSettings();
        const token = serverSettings.token;
        manager = new SessionManager({ serverSettings });
        expect(manager.serverSettings.token).to.equal(token);
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / clientsession.spec.ts View on Github external
describe('ClientSession', () => {
    const manager = new SessionManager();
    let session: ClientSession;

    beforeAll(() => manager.ready);

    beforeEach(() => {
      Dialog.flush();
      session = new ClientSession({
        manager,
        kernelPreference: { name: manager.specs.default }
      });
    });

    afterEach(async () => {
      Dialog.flush();
      try {
        await session.shutdown();
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / session / manager.spec.ts View on Github external
beforeEach(() => {
    manager = new SessionManager();
    expect(manager.specs).to.be.null;
  });
github jupyterlab / jupyterlab / tests / test-services / src / session / manager.spec.ts View on Github external
beforeEach(() => {
    manager = new SessionManager();
    expect(manager.specs).to.be.null;
  });
github jupyterlab / jupyterlab-data-explorer / tests / test-apputils / src / clientsession.spec.ts View on Github external
describe('ClientSession', () => {
    const manager = new SessionManager();
    let session: ClientSession;

    beforeAll(() => manager.ready);

    beforeEach(() => {
      Dialog.flush();
      session = new ClientSession({
        manager,
        kernelPreference: { name: manager.specs.default }
      });
    });

    afterEach(async () => {
      Dialog.flush();
      try {
        await session.shutdown();
github DonJayamanne / pythonVSCode / src / client / datascience / jupyter / jupyterSessionManager.ts View on Github external
public async initialize(connInfo: IConnection): Promise {
        this.connInfo = connInfo;
        this.serverSettings = await this.getServerConnectSettings(connInfo);
        this.sessionManager = new SessionManager({ serverSettings: this.serverSettings });
        this.contentsManager = new ContentsManager({ serverSettings: this.serverSettings });
    }