Socket
Socket
Sign inDemoInstall

@jupyterlab/services

Package Overview
Dependencies
Maintainers
3
Versions
387
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlab/services - npm Package Compare versions

Comparing version 0.31.0 to 0.32.0

8

lib/kernel/manager.d.ts

@@ -113,2 +113,10 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration';

/**
* Handle a kernel terminating.
*/
private _onTerminated(id);
/**
* Handle a kernel starting.
*/
private _onStarted(kernel);
/**
* Refresh the specs.

@@ -115,0 +123,0 @@ */

43

lib/kernel/manager.js

@@ -6,2 +6,3 @@ // Copyright (c) Jupyter Development Team.

var json_1 = require('phosphor/lib/algorithm/json');
var searching_1 = require('phosphor/lib/algorithm/searching');
var signaling_1 = require('phosphor/lib/core/signaling');

@@ -170,3 +171,7 @@ var utils = require('../utils');

KernelManager.prototype.startNew = function (options) {
return kernel_1.Kernel.startNew(this._getOptions(options));
var _this = this;
return kernel_1.Kernel.startNew(this._getOptions(options)).then(function (kernel) {
_this._onStarted(kernel);
return kernel;
});
};

@@ -187,3 +192,7 @@ /**

KernelManager.prototype.connectTo = function (id, options) {
return kernel_1.Kernel.connectTo(id, this._getOptions(options));
var _this = this;
return kernel_1.Kernel.connectTo(id, this._getOptions(options)).then(function (kernel) {
_this._onStarted(kernel);
return kernel;
});
};

@@ -200,5 +209,33 @@ /**

KernelManager.prototype.shutdown = function (id, options) {
return kernel_1.Kernel.shutdown(id, this._getOptions(options));
var _this = this;
return kernel_1.Kernel.shutdown(id, this._getOptions(options)).then(function () {
_this._onTerminated(id);
});
};
/**
* Handle a kernel terminating.
*/
KernelManager.prototype._onTerminated = function (id) {
var index = searching_1.findIndex(this._running, function (value) { return value.id === id; });
if (index !== -1) {
this._running.splice(index, 1);
this.runningChanged.emit(this._running.slice());
}
};
/**
* Handle a kernel starting.
*/
KernelManager.prototype._onStarted = function (kernel) {
var _this = this;
var id = kernel.id;
var index = searching_1.findIndex(this._running, function (value) { return value.id === id; });
if (index === -1) {
this._running.push(kernel.model);
this.runningChanged.emit(this._running.slice());
}
kernel.terminated.connect(function () {
_this._onTerminated(id);
});
};
/**
* Refresh the specs.

@@ -205,0 +242,0 @@ */

@@ -110,2 +110,14 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration';

/**
* Handle a session terminating.
*/
private _onTerminated(id);
/**
* Handle a session starting.
*/
private _onStarted(session);
/**
* Handle a change to a session.
*/
private _onChanged(model);
/**
* Refresh the specs.

@@ -112,0 +124,0 @@ */

@@ -6,2 +6,3 @@ // Copyright (c) Jupyter Development Team.

var json_1 = require('phosphor/lib/algorithm/json');
var searching_1 = require('phosphor/lib/algorithm/searching');
var signaling_1 = require('phosphor/lib/core/signaling');

@@ -170,3 +171,7 @@ var kernel_1 = require('../kernel');

SessionManager.prototype.startNew = function (options) {
return session_1.Session.startNew(this._getOptions(options));
var _this = this;
return session_1.Session.startNew(this._getOptions(options)).then(function (session) {
_this._onStarted(session);
return session;
});
};

@@ -189,3 +194,7 @@ /**

SessionManager.prototype.connectTo = function (id, options) {
return session_1.Session.connectTo(id, this._getOptions(options));
var _this = this;
return session_1.Session.connectTo(id, this._getOptions(options)).then(function (session) {
_this._onStarted(session);
return session;
});
};

@@ -196,3 +205,6 @@ /**

SessionManager.prototype.shutdown = function (id, options) {
return session_1.Session.shutdown(id, this._getOptions(options));
var _this = this;
return session_1.Session.shutdown(id, this._getOptions(options)).then(function () {
_this._onTerminated(id);
});
};

@@ -210,2 +222,43 @@ /**

/**
* Handle a session terminating.
*/
SessionManager.prototype._onTerminated = function (id) {
var index = searching_1.findIndex(this._running, function (value) { return value.id === id; });
if (index !== -1) {
this._running.splice(index, 1);
this.runningChanged.emit(this._running.slice());
}
};
/**
* Handle a session starting.
*/
SessionManager.prototype._onStarted = function (session) {
var _this = this;
var id = session.id;
var index = searching_1.findIndex(this._running, function (value) { return value.id === id; });
if (index === -1) {
this._running.push(session.model);
this.runningChanged.emit(this._running.slice());
}
session.terminated.connect(function () {
_this._onTerminated(id);
});
session.pathChanged.connect(function () {
_this._onChanged(session.model);
});
session.kernelChanged.connect(function () {
_this._onChanged(session.model);
});
};
/**
* Handle a change to a session.
*/
SessionManager.prototype._onChanged = function (model) {
var index = searching_1.findIndex(this._running, function (value) { return value.id === model.id; });
if (index !== -1) {
this._running[index] = model;
this.runningChanged.emit(this._running.slice());
}
};
/**
* Refresh the specs.

@@ -212,0 +265,0 @@ */

@@ -85,2 +85,10 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration';

/**
* Handle a session terminating.
*/
private _onTerminated(name);
/**
* Handle a session starting.
*/
private _onStarted(session);
/**
* Refresh the running sessions.

@@ -87,0 +95,0 @@ */

@@ -6,2 +6,3 @@ // Copyright (c) Jupyter Development Team.

var json_1 = require('phosphor/lib/algorithm/json');
var searching_1 = require('phosphor/lib/algorithm/searching');
var signaling_1 = require('phosphor/lib/core/signaling');

@@ -133,3 +134,7 @@ var utils = require('../utils');

TerminalManager.prototype.startNew = function (options) {
return terminal_1.TerminalSession.startNew(this._getOptions(options));
var _this = this;
return terminal_1.TerminalSession.startNew(this._getOptions(options)).then(function (session) {
_this._onStarted(session);
return session;
});
};

@@ -152,3 +157,7 @@ /*

TerminalManager.prototype.connectTo = function (name, options) {
return terminal_1.TerminalSession.connectTo(name, this._getOptions(options));
var _this = this;
return terminal_1.TerminalSession.connectTo(name, this._getOptions(options)).then(function (session) {
_this._onStarted(session);
return session;
});
};

@@ -159,3 +168,6 @@ /**

TerminalManager.prototype.shutdown = function (name) {
return terminal_1.TerminalSession.shutdown(name, this._getOptions());
var _this = this;
return terminal_1.TerminalSession.shutdown(name, this._getOptions()).then(function () {
_this._onTerminated(name);
});
};

@@ -175,2 +187,27 @@ /**

/**
* Handle a session terminating.
*/
TerminalManager.prototype._onTerminated = function (name) {
var index = searching_1.findIndex(this._running, function (value) { return value.name === name; });
if (index !== -1) {
this._running.splice(index, 1);
this.runningChanged.emit(this._running.slice());
}
};
/**
* Handle a session starting.
*/
TerminalManager.prototype._onStarted = function (session) {
var _this = this;
var name = session.name;
var index = searching_1.findIndex(this._running, function (value) { return value.name === name; });
if (index === -1) {
this._running.push(session.model);
this.runningChanged.emit(this._running.slice());
}
session.terminated.connect(function () {
_this._onTerminated(name);
});
};
/**
* Refresh the running sessions.

@@ -177,0 +214,0 @@ */

2

package.json
{
"name": "@jupyterlab/services",
"version": "0.31.0",
"version": "0.32.0",
"description": "Client APIs for the Jupyter services REST APIs",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -178,3 +178,3 @@ JupyterLab Services

// Execute and handle replies.
let future = kernel.execute({ code: 'a = 1' } );
let future = kernel.requestExecute({ code: 'a = 1' } );
future.onDone = () => {

@@ -192,3 +192,3 @@ console.log('Future is fulfilled');

};
kernel.inspect(request).then(reply => {
kernel.requestInspect(request).then(reply => {
console.log(reply.content.data);

@@ -200,3 +200,3 @@ });

kernel.interrupt().then(() => {
kernel.complete({ code: 'impor', cursor_pos: 4 } ).then((reply) => {
kernel.requestComplete({ code: 'impor', cursor_pos: 4 } ).then((reply) => {
console.log(reply.content.matches);

@@ -226,2 +226,3 @@ });

// The base url of the Jupyter server.

@@ -231,3 +232,2 @@ const BASE_URL = 'http://localhost:8000';

// Get a list of available sessions and connect to one.

@@ -240,3 +240,3 @@ Session.listRunning({ baseUrl: BASE_URL }).then(sessionModels => {

};
session.connectTo(sessionModels[0].id, options).then((session) => {
Session.connectTo(sessionModels[0].id, options).then((session) => {
console.log(session.kernel.name);

@@ -255,3 +255,3 @@ });

// Execute and handle replies on the kernel.
let future = session.kernel.execute({ code: 'a = 1' });
let future = session.kernel.requestExecute({ code: 'a = 1' });
future.onDone = () => {

@@ -267,3 +267,3 @@ console.log('Future is fulfilled');

// Register a callback for when the session dies.
session.sessionDied.connect(() => {
session.terminated.connect(() => {
console.log('session died');

@@ -278,2 +278,3 @@ });

});
```

@@ -284,6 +285,2 @@

```typescript
import {
Kernel
} from '@jupyterlab/services';
// The base url of the Jupyter server.

@@ -309,4 +306,4 @@ const BASE_URL = 'http://localhost:8000';

// Create a comm from the client side.
getKernelSpecs({ baseUrl: BASE_URL }).then(kernelSpecs => {
return kernel.startNew({
Kernel.getSpecs({ baseUrl: BASE_URL }).then(kernelSpecs => {
return Kernel.startNew({
baseUrl: BASE_URL,

@@ -334,3 +331,3 @@ name: kernelSpecs.default,

].join('\n');
kernel.execute({ code: code });
kernel.requestExecute({ code: code });
});

@@ -429,5 +426,5 @@ ```

// Create a named terminal session and send some data.
TerminalSession.open({ name: 'foo' }).then(session => {
TerminalSession.startNew().then(session => {
session.send({ type: 'stdin', content: ['foo'] });
});
```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc