Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jupyter-js-services

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupyter-js-services - npm Package Compare versions

Comparing version 0.6.5 to 0.6.6

4

lib/ikernel.d.ts

@@ -41,7 +41,7 @@ import { IDisposable } from 'phosphor-disposable';

*/
id: string;
id?: string;
/**
* The name of the kernel.
*/
name: string;
name?: string;
}

@@ -48,0 +48,0 @@ /**

@@ -38,2 +38,6 @@ import { IDisposable } from 'phosphor-disposable';

/**
* The id of an existing kernel.
*/
kernelId?: string;
/**
* The root url of the notebook server.

@@ -140,10 +144,8 @@ */

*/
renameNotebook(path: string, ajaxSettings?: IAjaxSettings): Promise<void>;
renameNotebook(path: string): Promise<void>;
/**
* Change the kernel.
*
* @params name - The name of the new kernel.
* @params options - The name or id of the new kernel.
*
* @returns - A promise that resolves with the new kernel.
*
* #### Notes

@@ -153,3 +155,3 @@ * This shuts down the existing kernel and creates a new kernel,

*/
changeKernel(name: string): Promise<IKernel>;
changeKernel(options: IKernelId): Promise<IKernel>;
/**

@@ -162,3 +164,3 @@ * Kill the kernel and shutdown the session.

*/
shutdown(ajaxSettings?: IAjaxSettings): Promise<void>;
shutdown(): Promise<void>;
}

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

this._comms = null;
this._status = ikernel_1.KernelStatus.Dead;
this._targetRegistry = null;

@@ -761,2 +762,3 @@ phosphor_signaling_1.clearSignalData(this);

if (this.status === ikernel_1.KernelStatus.Dead) {
// If the socket is being closed, ignore any messages
return;

@@ -763,0 +765,0 @@ }

@@ -330,20 +330,8 @@ // Copyright (c) Jupyter Development Team.

}
var model = {
kernel: { name: this._kernel.name, id: this._kernel.id },
var data = JSON.stringify({
notebook: { path: path }
};
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.dataType = 'json';
ajaxSettings.data = JSON.stringify(model);
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw Error('Invalid Status: ' + success.xhr.status);
}
var data = success.data;
validate.validateSessionId(data);
_this._notebookPath = data.notebook.path;
}, Private.onSessionError);
});
return this._patch(data).then(function (id) {
_this._notebookPath = id.notebook.path;
});
};

@@ -353,6 +341,4 @@ /**

*
* @params name - The name of the new kernel.
* @params options - The name or id of the new kernel.
*
* @returns - A promise that resolves with the new kernel.
*
* #### Notes

@@ -362,3 +348,3 @@ * This shuts down the existing kernel and creates a new kernel,

*/
NotebookSession.prototype.changeKernel = function (name) {
NotebookSession.prototype.changeKernel = function (options) {
var _this = this;

@@ -368,4 +354,19 @@ if (this.isDisposed) {

}
// Attempt to shutdown the kernel, but change the kernel either way.
return this.kernel.shutdown().then(function () { return _this._changeKernel(name); }, function () { return _this._changeKernel(name); });
this._kernel.dispose();
this._kernel = null;
var data = JSON.stringify({ kernel: options });
return this._patch(data).then(function (id) {
var options = utils.copy(_this._options);
options.ajaxSettings = _this.ajaxSettings;
options.kernelName = id.kernel.name;
options.notebookPath = id.notebook.path;
_this._notebookPath = id.notebook.path;
return Private.createKernel(id, options);
}).then(function (kernel) {
_this._kernel = kernel;
kernel.statusChanged.connect(_this.onKernelStatus, _this);
kernel.unhandledMessage.connect(_this.onUnhandledMessage, _this);
_this.kernelChanged.emit(kernel);
return kernel;
});
};

@@ -417,20 +418,19 @@ /**

/**
* Change the kernel.
* Send a PATCH to the server, updating the notebook path or the kernel.
*/
NotebookSession.prototype._changeKernel = function (name) {
var _this = this;
var options = utils.copy(this._options);
options.ajaxSettings = this.ajaxSettings;
options.kernelName = name;
options.notebookPath = this.notebookPath;
this._kernel.dispose();
return Private.startSession(options).then(function (sessionId) {
return Private.createKernel(sessionId, options);
}).then(function (kernel) {
kernel.statusChanged.connect(_this.onKernelStatus, _this);
kernel.unhandledMessage.connect(_this.onUnhandledMessage, _this);
_this._kernel = kernel;
_this.kernelChanged.emit(kernel);
return kernel;
});
NotebookSession.prototype._patch = function (data) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.dataType = 'json';
ajaxSettings.data = data;
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw Error('Invalid Status: ' + success.xhr.status);
}
var data = success.data;
validate.validateSessionId(data);
return data;
}, Private.onSessionError);
};

@@ -472,3 +472,3 @@ return NotebookSession;

var model = {
kernel: { name: options.kernelName },
kernel: { name: options.kernelName, id: options.kernelId },
notebook: { path: options.notebookPath }

@@ -495,7 +495,5 @@ };

function createKernel(sessionId, options) {
var baseUrl = options.baseUrl || utils.getBaseUrl();
options.notebookPath = sessionId.notebook.path;
var kernelOptions = {
name: sessionId.kernel.name,
baseUrl: options.baseUrl,
baseUrl: options.baseUrl || utils.getBaseUrl(),
wsUrl: options.wsUrl,

@@ -528,4 +526,7 @@ username: options.username,

function onSessionError(error) {
console.error("API request failed (" + error.statusText + "): ");
throw Error(error.statusText);
var text = (error.statusText ||
error.error.message ||
error.xhr.responseText);
console.error("API request failed (" + error.xhr.status + "): " + text);
throw Error(text);
}

@@ -532,0 +533,0 @@ Private.onSessionError = onSessionError;

{
"name": "jupyter-js-services",
"version": "0.6.5",
"version": "0.6.6",
"description": "Client APIs for the Jupyter services REST APIs",

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

@@ -82,3 +82,3 @@ Jupyter JS Services

----------------------------
The library requires a running Jupyter Notebook server, v4.1+, launched as:
The library requires a running Jupyter Notebook server (development version), launched as:

@@ -366,2 +366,3 @@ ```bash

```typescript
import {
startNewKernel, getKernelSpecs, getConfigSection, ConfigWithDefaults

@@ -368,0 +369,0 @@ } from 'jupyter-js-services';

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