@difizen/libro-kernel 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/kernel/libro-kernel-manager.d.ts +7 -1
- package/es/kernel/libro-kernel-manager.d.ts.map +1 -1
- package/es/kernel/libro-kernel-manager.js +120 -50
- package/es/kernel/libro-kernel-protocol.d.ts +2 -0
- package/es/kernel/libro-kernel-protocol.d.ts.map +1 -1
- package/es/libro-kernel-connection-manager.d.ts +1 -0
- package/es/libro-kernel-connection-manager.d.ts.map +1 -1
- package/es/libro-kernel-connection-manager.js +15 -11
- package/es/session/libro-session-manager.d.ts +1 -0
- package/es/session/libro-session-manager.d.ts.map +1 -1
- package/es/session/libro-session-manager.js +50 -25
- package/package.json +3 -3
- package/src/kernel/libro-kernel-manager.ts +51 -1
- package/src/kernel/libro-kernel-protocol.ts +2 -0
- package/src/libro-kernel-connection-manager.ts +9 -6
- package/src/session/libro-session-manager.ts +30 -2
|
@@ -2,7 +2,7 @@ import { Poll } from '@difizen/libro-common';
|
|
|
2
2
|
import type { Event as ManaEvent } from '@difizen/mana-app';
|
|
3
3
|
import { Emitter } from '@difizen/mana-app';
|
|
4
4
|
import { ServerManager } from '../server/index.js';
|
|
5
|
-
import type { KernelId, IKernelConnection, KernelStatus, KernelConnectionOptions, IKernelModel } from './libro-kernel-protocol.js';
|
|
5
|
+
import type { KernelId, IKernelConnection, KernelStatus, KernelConnectionOptions, IKernelModel, KernelMeta } from './libro-kernel-protocol.js';
|
|
6
6
|
import { LibroKernelFactory, LibroKernelConnectionFactory } from './libro-kernel-protocol.js';
|
|
7
7
|
import type { LibroKernel } from './libro-kernel.js';
|
|
8
8
|
import { KernelRestAPI } from './restapi.js';
|
|
@@ -11,6 +11,7 @@ export declare class LibroKernelManager {
|
|
|
11
11
|
kernelConnectionFactory: LibroKernelConnectionFactory;
|
|
12
12
|
kernelRestAPI: KernelRestAPI;
|
|
13
13
|
kernelMap: Map<string, LibroKernel>;
|
|
14
|
+
private _models;
|
|
14
15
|
protected _pollModels: Poll;
|
|
15
16
|
protected _isReady: boolean;
|
|
16
17
|
protected _ready: Promise<void>;
|
|
@@ -19,6 +20,7 @@ export declare class LibroKernelManager {
|
|
|
19
20
|
get onConnectToKernel(): ManaEvent<any>;
|
|
20
21
|
get kernelIds(): string[];
|
|
21
22
|
getLibroKernel(kernelId: KernelId): LibroKernel | undefined;
|
|
23
|
+
get runningKernels(): Map<string, KernelMeta>;
|
|
22
24
|
constructor(serverManager: ServerManager);
|
|
23
25
|
/**
|
|
24
26
|
* Test whether the manager is ready.
|
|
@@ -44,6 +46,10 @@ export declare class LibroKernelManager {
|
|
|
44
46
|
* @returns A promise that resolves when the operation is complete.
|
|
45
47
|
*/
|
|
46
48
|
shutdown(id: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Shut down all kernels.
|
|
51
|
+
*/
|
|
52
|
+
shutdownAll(): Promise<void>;
|
|
47
53
|
connectToKernel(options: KernelConnectionOptions): Promise<IKernelConnection>;
|
|
48
54
|
isKernelAlive(id: string): Promise<boolean>;
|
|
49
55
|
startKernel(kernelConnection: IKernelConnection): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-kernel-manager.d.ts","sourceRoot":"","sources":["../../src/kernel/libro-kernel-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAgB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EACV,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,YAAY,
|
|
1
|
+
{"version":3,"file":"libro-kernel-manager.d.ts","sourceRoot":"","sources":["../../src/kernel/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AEzB;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC,CAE9C;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,SAAS,CAAC,KAAK,CAAC,CAExC;IAED;;;;;;OAMG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5B,eAAe,CAAC,OAAO,EAAE,uBAAuB;IAQhD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3C,WAAW,CAAC,gBAAgB,EAAE,iBAAiB;IAKrD,SAAS,CAAC,WAAW,CAAC,gBAAgB,EAAE,iBAAiB;IAYzD,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY;IAW/C;;;;;;;;OAQG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrC,SAAS,CAAC,wBAAwB,iBAAwB;IAC1D,SAAS,CAAC,qBAAqB,0BAAiC;IAEhE;;OAEG;cACa,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CA2ChD"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
3
9
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -18,7 +24,7 @@ import { Emitter } from '@difizen/mana-app';
|
|
|
18
24
|
import { NetworkError, ServerManager } from "../server/index.js";
|
|
19
25
|
import { LibroKernelFactory, LibroKernelConnectionFactory } from "./libro-kernel-protocol.js";
|
|
20
26
|
import { KernelRestAPI } from "./restapi.js";
|
|
21
|
-
export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelFactory), _dec3 = inject(LibroKernelConnectionFactory), _dec4 = inject(KernelRestAPI), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
27
|
+
export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelFactory), _dec3 = inject(LibroKernelConnectionFactory), _dec4 = inject(KernelRestAPI), _dec5 = prop(), _dec6 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
22
28
|
function LibroKernelManager(serverManager) {
|
|
23
29
|
var _this = this;
|
|
24
30
|
_classCallCheck(this, LibroKernelManager);
|
|
@@ -26,6 +32,7 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
26
32
|
_initializerDefineProperty(this, "kernelConnectionFactory", _descriptor2, this);
|
|
27
33
|
_initializerDefineProperty(this, "kernelRestAPI", _descriptor3, this);
|
|
28
34
|
_initializerDefineProperty(this, "kernelMap", _descriptor4, this);
|
|
35
|
+
_initializerDefineProperty(this, "_models", _descriptor5, this);
|
|
29
36
|
this._isReady = false;
|
|
30
37
|
this.connectToKernelEmitter = new Emitter();
|
|
31
38
|
this.connectionFailureEmmiter = new Emitter();
|
|
@@ -87,6 +94,11 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
87
94
|
value: function getLibroKernel(kernelId) {
|
|
88
95
|
return this.kernelMap.get(kernelId);
|
|
89
96
|
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "runningKernels",
|
|
99
|
+
get: function get() {
|
|
100
|
+
return this._models;
|
|
101
|
+
}
|
|
90
102
|
}, {
|
|
91
103
|
key: "isReady",
|
|
92
104
|
get: function get() {
|
|
@@ -149,24 +161,57 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
149
161
|
return _shutdown.apply(this, arguments);
|
|
150
162
|
}
|
|
151
163
|
return shutdown;
|
|
164
|
+
}()
|
|
165
|
+
/**
|
|
166
|
+
* Shut down all kernels.
|
|
167
|
+
*/
|
|
168
|
+
)
|
|
169
|
+
}, {
|
|
170
|
+
key: "shutdownAll",
|
|
171
|
+
value: (function () {
|
|
172
|
+
var _shutdownAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
173
|
+
var _this2 = this;
|
|
174
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
175
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
176
|
+
case 0:
|
|
177
|
+
_context3.next = 2;
|
|
178
|
+
return this.refreshRunning();
|
|
179
|
+
case 2:
|
|
180
|
+
_context3.next = 4;
|
|
181
|
+
return Promise.all(_toConsumableArray(this._models.keys()).map(function (id) {
|
|
182
|
+
return _this2.kernelRestAPI.shutdownKernel(id);
|
|
183
|
+
}));
|
|
184
|
+
case 4:
|
|
185
|
+
_context3.next = 6;
|
|
186
|
+
return this.refreshRunning();
|
|
187
|
+
case 6:
|
|
188
|
+
case "end":
|
|
189
|
+
return _context3.stop();
|
|
190
|
+
}
|
|
191
|
+
}, _callee3, this);
|
|
192
|
+
}));
|
|
193
|
+
function shutdownAll() {
|
|
194
|
+
return _shutdownAll.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
return shutdownAll;
|
|
152
197
|
}())
|
|
153
198
|
}, {
|
|
154
199
|
key: "connectToKernel",
|
|
155
200
|
value: function () {
|
|
156
|
-
var _connectToKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
201
|
+
var _connectToKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
|
|
157
202
|
var kernelConnection;
|
|
158
|
-
return _regeneratorRuntime().wrap(function
|
|
159
|
-
while (1) switch (
|
|
203
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
204
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
160
205
|
case 0:
|
|
161
206
|
kernelConnection = this.kernelConnectionFactory(options);
|
|
162
207
|
this.startKernel(kernelConnection);
|
|
163
208
|
this.connectToKernelEmitter.fire(kernelConnection);
|
|
164
|
-
return
|
|
209
|
+
return _context4.abrupt("return", kernelConnection);
|
|
165
210
|
case 4:
|
|
166
211
|
case "end":
|
|
167
|
-
return
|
|
212
|
+
return _context4.stop();
|
|
168
213
|
}
|
|
169
|
-
},
|
|
214
|
+
}, _callee4, this);
|
|
170
215
|
}));
|
|
171
216
|
function connectToKernel(_x2) {
|
|
172
217
|
return _connectToKernel.apply(this, arguments);
|
|
@@ -176,26 +221,26 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
176
221
|
}, {
|
|
177
222
|
key: "isKernelAlive",
|
|
178
223
|
value: function () {
|
|
179
|
-
var _isKernelAlive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
224
|
+
var _isKernelAlive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
180
225
|
var data;
|
|
181
|
-
return _regeneratorRuntime().wrap(function
|
|
182
|
-
while (1) switch (
|
|
226
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
227
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
183
228
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
229
|
+
_context5.prev = 0;
|
|
230
|
+
_context5.next = 3;
|
|
186
231
|
return this.kernelRestAPI.getKernelModel(id);
|
|
187
232
|
case 3:
|
|
188
|
-
data =
|
|
189
|
-
return
|
|
233
|
+
data = _context5.sent;
|
|
234
|
+
return _context5.abrupt("return", !!data);
|
|
190
235
|
case 7:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return
|
|
236
|
+
_context5.prev = 7;
|
|
237
|
+
_context5.t0 = _context5["catch"](0);
|
|
238
|
+
return _context5.abrupt("return", false);
|
|
194
239
|
case 10:
|
|
195
240
|
case "end":
|
|
196
|
-
return
|
|
241
|
+
return _context5.stop();
|
|
197
242
|
}
|
|
198
|
-
},
|
|
243
|
+
}, _callee5, this, [[0, 7]]);
|
|
199
244
|
}));
|
|
200
245
|
function isKernelAlive(_x3) {
|
|
201
246
|
return _isKernelAlive.apply(this, arguments);
|
|
@@ -205,20 +250,20 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
205
250
|
}, {
|
|
206
251
|
key: "startKernel",
|
|
207
252
|
value: function () {
|
|
208
|
-
var _startKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
209
|
-
var
|
|
210
|
-
return _regeneratorRuntime().wrap(function
|
|
211
|
-
while (1) switch (
|
|
253
|
+
var _startKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(kernelConnection) {
|
|
254
|
+
var _this3 = this;
|
|
255
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
256
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
212
257
|
case 0:
|
|
213
258
|
kernelConnection.statusChanged(this._onStatusChanged.bind(this));
|
|
214
259
|
kernelConnection.onDisposed(function () {
|
|
215
|
-
return
|
|
260
|
+
return _this3._onDisposed.bind(_this3)(kernelConnection);
|
|
216
261
|
});
|
|
217
262
|
case 2:
|
|
218
263
|
case "end":
|
|
219
|
-
return
|
|
264
|
+
return _context6.stop();
|
|
220
265
|
}
|
|
221
|
-
},
|
|
266
|
+
}, _callee6, this);
|
|
222
267
|
}));
|
|
223
268
|
function startKernel(_x4) {
|
|
224
269
|
return _startKernel.apply(this, arguments);
|
|
@@ -263,20 +308,20 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
263
308
|
}, {
|
|
264
309
|
key: "refreshRunning",
|
|
265
310
|
value: (function () {
|
|
266
|
-
var _refreshRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
267
|
-
return _regeneratorRuntime().wrap(function
|
|
268
|
-
while (1) switch (
|
|
311
|
+
var _refreshRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
312
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
313
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
269
314
|
case 0:
|
|
270
|
-
|
|
315
|
+
_context7.next = 2;
|
|
271
316
|
return getOrigin(this._pollModels).refresh();
|
|
272
317
|
case 2:
|
|
273
|
-
|
|
318
|
+
_context7.next = 4;
|
|
274
319
|
return getOrigin(this._pollModels).tick;
|
|
275
320
|
case 4:
|
|
276
321
|
case "end":
|
|
277
|
-
return
|
|
322
|
+
return _context7.stop();
|
|
278
323
|
}
|
|
279
|
-
},
|
|
324
|
+
}, _callee7, this);
|
|
280
325
|
}));
|
|
281
326
|
function refreshRunning() {
|
|
282
327
|
return _refreshRunning.apply(this, arguments);
|
|
@@ -290,32 +335,50 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
290
335
|
* Execute a request to the server to poll running kernels and update state.
|
|
291
336
|
*/
|
|
292
337
|
function () {
|
|
293
|
-
var _requestRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
|
|
338
|
+
var _requestRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
339
|
+
var _this4 = this;
|
|
340
|
+
var models, _err$response, _err$response2;
|
|
341
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
342
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
297
343
|
case 0:
|
|
298
|
-
|
|
299
|
-
|
|
344
|
+
_context8.prev = 0;
|
|
345
|
+
_context8.next = 3;
|
|
300
346
|
return this.kernelRestAPI.listRunning();
|
|
301
347
|
case 3:
|
|
302
|
-
|
|
348
|
+
models = _context8.sent;
|
|
349
|
+
_context8.next = 10;
|
|
303
350
|
break;
|
|
304
|
-
case
|
|
305
|
-
|
|
306
|
-
|
|
351
|
+
case 6:
|
|
352
|
+
_context8.prev = 6;
|
|
353
|
+
_context8.t0 = _context8["catch"](0);
|
|
307
354
|
// Handle network errors, as well as cases where we are on a
|
|
308
355
|
// JupyterHub and the server is not running. JupyterHub returns a
|
|
309
356
|
// 503 (<2.0) or 424 (>2.0) in that case.
|
|
310
|
-
if (
|
|
311
|
-
this.connectionFailureEmmiter.fire(
|
|
357
|
+
if (_context8.t0 instanceof NetworkError || ((_err$response = _context8.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 503 || ((_err$response2 = _context8.t0.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 424) {
|
|
358
|
+
this.connectionFailureEmmiter.fire(_context8.t0);
|
|
359
|
+
}
|
|
360
|
+
throw _context8.t0;
|
|
361
|
+
case 10:
|
|
362
|
+
if (!(this._models.size === models.length && models.every(function (model) {
|
|
363
|
+
var existing = _this4._models.get(model.id);
|
|
364
|
+
if (!existing) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
return existing.connections === model.connections && existing.execution_state === model.execution_state && existing.last_activity === model.last_activity && existing.name === model.name && existing.reason === model.reason && existing.traceback === model.traceback;
|
|
368
|
+
}))) {
|
|
369
|
+
_context8.next = 12;
|
|
370
|
+
break;
|
|
312
371
|
}
|
|
313
|
-
|
|
314
|
-
case
|
|
372
|
+
return _context8.abrupt("return");
|
|
373
|
+
case 12:
|
|
374
|
+
this._models = new Map(models.map(function (x) {
|
|
375
|
+
return [x.id, x];
|
|
376
|
+
}));
|
|
377
|
+
case 13:
|
|
315
378
|
case "end":
|
|
316
|
-
return
|
|
379
|
+
return _context8.stop();
|
|
317
380
|
}
|
|
318
|
-
},
|
|
381
|
+
}, _callee8, this, [[0, 6]]);
|
|
319
382
|
}));
|
|
320
383
|
function requestRunning() {
|
|
321
384
|
return _requestRunning.apply(this, arguments);
|
|
@@ -346,4 +409,11 @@ export var LibroKernelManager = (_dec = singleton(), _dec2 = inject(LibroKernelF
|
|
|
346
409
|
initializer: function initializer() {
|
|
347
410
|
return new Map();
|
|
348
411
|
}
|
|
412
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_models", [_dec6], {
|
|
413
|
+
configurable: true,
|
|
414
|
+
enumerable: true,
|
|
415
|
+
writable: true,
|
|
416
|
+
initializer: function initializer() {
|
|
417
|
+
return new Map();
|
|
418
|
+
}
|
|
349
419
|
})), _class2)) || _class);
|
|
@@ -20,6 +20,8 @@ export interface KernelMeta {
|
|
|
20
20
|
last_activity: string;
|
|
21
21
|
execution_state: KernelStatus;
|
|
22
22
|
connections: number;
|
|
23
|
+
readonly reason?: string;
|
|
24
|
+
readonly traceback?: string;
|
|
23
25
|
}
|
|
24
26
|
export declare const KernelMetaOption: unique symbol;
|
|
25
27
|
export declare const KernelId: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-kernel-protocol.d.ts","sourceRoot":"","sources":["../../src/kernel/libro-kernel-protocol.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,KAAK,aAAa,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,MAAM,GACN,MAAM,GACN,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,MAAM,CAAC;AAEX,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,QAAQ,CAAC;IACb,IA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;;;;OASG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -7,6 +7,7 @@ export declare class LibroKernelConnectionManager {
|
|
|
7
7
|
protected kernelManager: LibroKernelManager;
|
|
8
8
|
protected kernelConnectionMap: Map<string, IKernelConnection>;
|
|
9
9
|
constructor(sessionManager: LibroSessionManager, kernelManager: LibroKernelManager);
|
|
10
|
+
private mpKey;
|
|
10
11
|
startNew(fileInfo: IContentsModel): Promise<IKernelConnection | undefined>;
|
|
11
12
|
changeKernel(fileInfo: IContentsModel, reuseKernelInfo: {
|
|
12
13
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-kernel-connection-manager.d.ts","sourceRoot":"","sources":["../src/libro-kernel-connection-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,qBACa,4BAA4B;IACvC,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAC9C,SAAS,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAG5C,SAAS,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;gBAG/B,cAAc,EAAE,mBAAmB,EACpC,aAAa,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"libro-kernel-connection-manager.d.ts","sourceRoot":"","sources":["../src/libro-kernel-connection-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,qBACa,4BAA4B;IACvC,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAC9C,SAAS,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAG5C,SAAS,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;gBAG/B,cAAc,EAAE,mBAAmB,EACpC,aAAa,EAAE,kBAAkB;IAO/D,OAAO,CAAC,KAAK;IAIP,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAS1E,YAAY,CAChB,QAAQ,EAAE,cAAc,EACxB,eAAe,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAa1C,UAAU,CAAC,QAAQ,EAAE,cAAc;IAWzC,uBAAuB;IAIvB,mBAAmB,CAAC,QAAQ,EAAE,cAAc;CAO7C"}
|
|
@@ -26,6 +26,11 @@ export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _
|
|
|
26
26
|
LibroKernelConnectionManager = inject(LibroKernelManager)(LibroKernelConnectionManager, undefined, 1) || LibroKernelConnectionManager;
|
|
27
27
|
LibroKernelConnectionManager = inject(LibroSessionManager)(LibroKernelConnectionManager, undefined, 0) || LibroKernelConnectionManager;
|
|
28
28
|
_createClass(LibroKernelConnectionManager, [{
|
|
29
|
+
key: "mpKey",
|
|
30
|
+
value: function mpKey(fileInfo) {
|
|
31
|
+
return fileInfo.path || fileInfo.name; // 优先用path作为key
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
29
34
|
key: "startNew",
|
|
30
35
|
value: function () {
|
|
31
36
|
var _startNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fileInfo) {
|
|
@@ -43,7 +48,7 @@ export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _
|
|
|
43
48
|
}
|
|
44
49
|
throw new Error('start new kernel connection failed');
|
|
45
50
|
case 5:
|
|
46
|
-
this.kernelConnectionMap.set(fileInfo
|
|
51
|
+
this.kernelConnectionMap.set(this.mpKey(fileInfo), connection);
|
|
47
52
|
return _context.abrupt("return", connection);
|
|
48
53
|
case 7:
|
|
49
54
|
case "end":
|
|
@@ -74,7 +79,7 @@ export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _
|
|
|
74
79
|
}
|
|
75
80
|
throw new Error('change kernel connection failed');
|
|
76
81
|
case 5:
|
|
77
|
-
this.kernelConnectionMap.set(fileInfo
|
|
82
|
+
this.kernelConnectionMap.set(this.mpKey(fileInfo), connection);
|
|
78
83
|
return _context2.abrupt("return", connection);
|
|
79
84
|
case 7:
|
|
80
85
|
case "end":
|
|
@@ -91,23 +96,22 @@ export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _
|
|
|
91
96
|
key: "shutdownKC",
|
|
92
97
|
value: function () {
|
|
93
98
|
var _shutdownKC = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(fileInfo) {
|
|
94
|
-
var
|
|
99
|
+
var kc;
|
|
95
100
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
96
101
|
while (1) switch (_context3.prev = _context3.next) {
|
|
97
102
|
case 0:
|
|
98
|
-
|
|
99
|
-
kc = this.kernelConnectionMap.get(fileName);
|
|
103
|
+
kc = this.kernelConnectionMap.get(this.mpKey(fileInfo));
|
|
100
104
|
if (kc) {
|
|
101
|
-
_context3.next =
|
|
105
|
+
_context3.next = 3;
|
|
102
106
|
break;
|
|
103
107
|
}
|
|
104
108
|
throw new Error('interrupt connection failed');
|
|
105
|
-
case
|
|
106
|
-
_context3.next =
|
|
109
|
+
case 3:
|
|
110
|
+
_context3.next = 5;
|
|
107
111
|
return this.sessionManager.shutdownKC(fileInfo, kc);
|
|
112
|
+
case 5:
|
|
113
|
+
this.kernelConnectionMap.delete(this.mpKey(fileInfo));
|
|
108
114
|
case 6:
|
|
109
|
-
this.kernelConnectionMap.delete(fileName);
|
|
110
|
-
case 7:
|
|
111
115
|
case "end":
|
|
112
116
|
return _context3.stop();
|
|
113
117
|
}
|
|
@@ -126,7 +130,7 @@ export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _
|
|
|
126
130
|
}, {
|
|
127
131
|
key: "getKernelConnection",
|
|
128
132
|
value: function getKernelConnection(fileInfo) {
|
|
129
|
-
var connection = this.kernelConnectionMap.get(fileInfo
|
|
133
|
+
var connection = this.kernelConnectionMap.get(this.mpKey(fileInfo));
|
|
130
134
|
if (connection && !connection.isDisposed) {
|
|
131
135
|
return connection;
|
|
132
136
|
}
|
|
@@ -26,6 +26,7 @@ export declare class LibroSessionManager {
|
|
|
26
26
|
protected storageService: StorageService;
|
|
27
27
|
protected _models: Map<string, SessionIModel>;
|
|
28
28
|
protected _sessionConnections: Map<string, IKernelConnection>;
|
|
29
|
+
get running(): Map<string, SessionIModel>;
|
|
29
30
|
constructor(kernelManager: LibroKernelManager, serverManager: ServerManager, sessionFactory: LibroSessionFactory, kernelFactory: LibroKernelFactory, storageService: StorageService);
|
|
30
31
|
/**
|
|
31
32
|
* Execute a request to the server to poll running kernels and update state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-session-manager.d.ts","sourceRoot":"","sources":["../../src/session/libro-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,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AI,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAExC;gBAG6B,aAAa,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,EACtB,cAAc,EAAE,mBAAmB,EACpC,aAAa,EAAE,kBAAkB,EACrC,cAAc,EAAE,cAAc;IAmCxD;;OAEG;cACa,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA2D/C,SAAS,CAAC,kBAAkB,iBAAwB;IAEpD;;OAEG;IACH,IAAI,iBAAiB,IAAI,KAAK,CAAC,KAAK,CAAC,CAEpC;IAGD,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAErC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAIhD,UAAU,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,EAAE,iBAAiB;IAO1D,eAAe,CACnB,QAAQ,EAAE,cAAc,EACxB,eAAe,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC7C,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAwEnC,QAAQ,CAAC,QAAQ,EAAE,cAAc;IA2CvC;;;;;;;;OAQG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrC;;OAEG;cACa,MAAM,CACpB,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;OAQG;IACG,YAAY,CAChB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAC7B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAuDrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -32,17 +32,16 @@ import { NetworkError } from "../server/index.js";
|
|
|
32
32
|
import { ServerManager } from "../server/server-manager.js";
|
|
33
33
|
import { LibroSessionFactory } from "./libro-session-protocol.js";
|
|
34
34
|
import { SessionRestAPI } from "./restapi.js";
|
|
35
|
-
export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRestAPI), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
36
|
-
// sessionId -> kernelConnection
|
|
37
|
-
|
|
35
|
+
export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRestAPI), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
38
36
|
function LibroSessionManager(kernelManager, serverManager, sessionFactory, kernelFactory, storageService) {
|
|
39
37
|
var _this = this;
|
|
40
38
|
_classCallCheck(this, LibroSessionManager);
|
|
41
39
|
_initializerDefineProperty(this, "sessionRestAPI", _descriptor, this);
|
|
42
40
|
_initializerDefineProperty(this, "sessionIdMap", _descriptor2, this);
|
|
43
41
|
this._isReady = false;
|
|
42
|
+
_initializerDefineProperty(this, "_models", _descriptor3, this);
|
|
44
43
|
this._connectionFailure = new Emitter();
|
|
45
|
-
_initializerDefineProperty(this, "kernelConnection",
|
|
44
|
+
_initializerDefineProperty(this, "kernelConnection", _descriptor4, this);
|
|
46
45
|
this.kernelManager = kernelManager;
|
|
47
46
|
this.serverManager = serverManager;
|
|
48
47
|
this.sessionFactory = sessionFactory;
|
|
@@ -99,6 +98,14 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
99
98
|
LibroSessionManager = inject(ServerManager)(LibroSessionManager, undefined, 1) || LibroSessionManager;
|
|
100
99
|
LibroSessionManager = inject(LibroKernelManager)(LibroSessionManager, undefined, 0) || LibroSessionManager;
|
|
101
100
|
_createClass(LibroSessionManager, [{
|
|
101
|
+
key: "running",
|
|
102
|
+
get:
|
|
103
|
+
// sessionId -> kernelConnection
|
|
104
|
+
|
|
105
|
+
function get() {
|
|
106
|
+
return this._models;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
102
109
|
key: "requestRunning",
|
|
103
110
|
value: (function () {
|
|
104
111
|
var _requestRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
@@ -125,11 +132,24 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
125
132
|
}
|
|
126
133
|
throw _context3.t0;
|
|
127
134
|
case 10:
|
|
135
|
+
if (!(this._models.size === models.length && models.every(function (model) {
|
|
136
|
+
var _existing$kernel, _model$kernel, _existing$kernel2, _model$kernel2;
|
|
137
|
+
var existing = _this2._models.get(model.id);
|
|
138
|
+
if (!existing) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return ((_existing$kernel = existing.kernel) === null || _existing$kernel === void 0 ? void 0 : _existing$kernel.id) === ((_model$kernel = model.kernel) === null || _model$kernel === void 0 ? void 0 : _model$kernel.id) && ((_existing$kernel2 = existing.kernel) === null || _existing$kernel2 === void 0 ? void 0 : _existing$kernel2.name) === ((_model$kernel2 = model.kernel) === null || _model$kernel2 === void 0 ? void 0 : _model$kernel2.name) && existing.name === model.name && existing.path === model.path && existing.type === model.type;
|
|
142
|
+
}))) {
|
|
143
|
+
_context3.next = 12;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return _context3.abrupt("return");
|
|
147
|
+
case 12:
|
|
128
148
|
this._models = new Map(models.map(function (x) {
|
|
129
149
|
return [x.id, x];
|
|
130
150
|
}));
|
|
131
151
|
_iterator = _createForOfIteratorHelper(this._sessionConnections);
|
|
132
|
-
_context3.prev =
|
|
152
|
+
_context3.prev = 14;
|
|
133
153
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
134
154
|
var _step$value, sessionId, kc, filePersistKey;
|
|
135
155
|
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
@@ -159,31 +179,31 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
159
179
|
}, _loop);
|
|
160
180
|
});
|
|
161
181
|
_iterator.s();
|
|
162
|
-
case
|
|
182
|
+
case 17:
|
|
163
183
|
if ((_step = _iterator.n()).done) {
|
|
164
|
-
_context3.next =
|
|
184
|
+
_context3.next = 21;
|
|
165
185
|
break;
|
|
166
186
|
}
|
|
167
|
-
return _context3.delegateYield(_loop(), "t1",
|
|
168
|
-
case 17:
|
|
169
|
-
_context3.next = 15;
|
|
170
|
-
break;
|
|
187
|
+
return _context3.delegateYield(_loop(), "t1", 19);
|
|
171
188
|
case 19:
|
|
172
|
-
_context3.next =
|
|
189
|
+
_context3.next = 17;
|
|
173
190
|
break;
|
|
174
191
|
case 21:
|
|
175
|
-
_context3.
|
|
176
|
-
|
|
192
|
+
_context3.next = 26;
|
|
193
|
+
break;
|
|
194
|
+
case 23:
|
|
195
|
+
_context3.prev = 23;
|
|
196
|
+
_context3.t2 = _context3["catch"](14);
|
|
177
197
|
_iterator.e(_context3.t2);
|
|
178
|
-
case
|
|
179
|
-
_context3.prev =
|
|
198
|
+
case 26:
|
|
199
|
+
_context3.prev = 26;
|
|
180
200
|
_iterator.f();
|
|
181
|
-
return _context3.finish(
|
|
182
|
-
case
|
|
201
|
+
return _context3.finish(26);
|
|
202
|
+
case 29:
|
|
183
203
|
case "end":
|
|
184
204
|
return _context3.stop();
|
|
185
205
|
}
|
|
186
|
-
}, _callee2, this, [[0, 6], [
|
|
206
|
+
}, _callee2, this, [[0, 6], [14, 23, 26, 29]]);
|
|
187
207
|
}));
|
|
188
208
|
function requestRunning() {
|
|
189
209
|
return _requestRunning.apply(this, arguments);
|
|
@@ -233,7 +253,7 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
233
253
|
key: "connectToKernel",
|
|
234
254
|
value: function () {
|
|
235
255
|
var _connectToKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(fileInfo, reuseKernelInfo) {
|
|
236
|
-
var _this$serverManager$k, _fileInfo$content
|
|
256
|
+
var _this$serverManager$k, _fileInfo$content;
|
|
237
257
|
var firstKernelSpecName, _this$serverManager$k2, kernelspec, newSession, options, kernelConnection;
|
|
238
258
|
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
239
259
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -248,7 +268,7 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
248
268
|
return this.sessionRestAPI.startSession({
|
|
249
269
|
name: fileInfo.name,
|
|
250
270
|
kernel: {
|
|
251
|
-
kernelName: reuseKernelInfo ? reuseKernelInfo.name : ((_fileInfo$content
|
|
271
|
+
kernelName: reuseKernelInfo ? reuseKernelInfo.name : ((_fileInfo$content = fileInfo.content) === null || _fileInfo$content === void 0 || (_fileInfo$content = _fileInfo$content.metadata) === null || _fileInfo$content === void 0 || (_fileInfo$content = _fileInfo$content.kernelspec) === null || _fileInfo$content === void 0 ? void 0 : _fileInfo$content.name) || firstKernelSpecName // 使用ipynb文件原本的kernel name,或者使用kernel spec轮询得到的第一个kernel name
|
|
252
272
|
},
|
|
253
273
|
path: fileInfo.path,
|
|
254
274
|
type: fileInfo.type
|
|
@@ -443,7 +463,7 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
443
463
|
key: "changeKernel",
|
|
444
464
|
value: (function () {
|
|
445
465
|
var _changeKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(fileInfo, options) {
|
|
446
|
-
var reuseSessionId, newSession, model, optionsForConnectKernel, kernelConnection;
|
|
466
|
+
var reuseSessionId, _fileInfo$content2, newSession, model, optionsForConnectKernel, kernelConnection;
|
|
447
467
|
return _regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
448
468
|
while (1) switch (_context9.prev = _context9.next) {
|
|
449
469
|
case 0:
|
|
@@ -456,7 +476,7 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
456
476
|
return this.sessionRestAPI.startSession({
|
|
457
477
|
name: fileInfo.name,
|
|
458
478
|
kernel: {
|
|
459
|
-
kernelName: options.name || fileInfo.content.metadata.kernelspec.name
|
|
479
|
+
kernelName: options.name || ((_fileInfo$content2 = fileInfo.content) === null || _fileInfo$content2 === void 0 || (_fileInfo$content2 = _fileInfo$content2.metadata) === null || _fileInfo$content2 === void 0 ? void 0 : _fileInfo$content2.kernelspec.name)
|
|
460
480
|
},
|
|
461
481
|
path: fileInfo.path,
|
|
462
482
|
type: fileInfo.type
|
|
@@ -532,7 +552,12 @@ export var LibroSessionManager = (_dec = singleton(), _dec2 = inject(SessionRest
|
|
|
532
552
|
initializer: function initializer() {
|
|
533
553
|
return new Map();
|
|
534
554
|
}
|
|
535
|
-
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "
|
|
555
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_models", [_dec4], {
|
|
556
|
+
configurable: true,
|
|
557
|
+
enumerable: true,
|
|
558
|
+
writable: true,
|
|
559
|
+
initializer: null
|
|
560
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "kernelConnection", [_dec5], {
|
|
536
561
|
configurable: true,
|
|
537
562
|
enumerable: true,
|
|
538
563
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-kernel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-infra",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-common": "^0.1.
|
|
36
|
-
"@difizen/libro-core": "^0.1.
|
|
35
|
+
"@difizen/libro-common": "^0.1.16",
|
|
36
|
+
"@difizen/libro-core": "^0.1.16",
|
|
37
37
|
"@difizen/mana-app": "latest",
|
|
38
38
|
"minimist": "^1.2.8",
|
|
39
39
|
"query-string": "^8.1.0",
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
KernelStatus,
|
|
13
13
|
KernelConnectionOptions,
|
|
14
14
|
IKernelModel,
|
|
15
|
+
KernelMeta,
|
|
15
16
|
} from './libro-kernel-protocol.js';
|
|
16
17
|
import {
|
|
17
18
|
LibroKernelFactory,
|
|
@@ -31,6 +32,9 @@ export class LibroKernelManager {
|
|
|
31
32
|
@prop()
|
|
32
33
|
kernelMap = new Map<KernelId, LibroKernel>();
|
|
33
34
|
|
|
35
|
+
@prop()
|
|
36
|
+
private _models = new Map<string, KernelMeta>();
|
|
37
|
+
|
|
34
38
|
protected _pollModels: Poll;
|
|
35
39
|
protected _isReady = false;
|
|
36
40
|
protected _ready: Promise<void>;
|
|
@@ -49,6 +53,10 @@ export class LibroKernelManager {
|
|
|
49
53
|
return this.kernelMap.get(kernelId);
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
get runningKernels(): Map<string, KernelMeta> {
|
|
57
|
+
return this._models;
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
constructor(@inject(ServerManager) serverManager: ServerManager) {
|
|
53
61
|
this.serverManager = serverManager;
|
|
54
62
|
|
|
@@ -114,6 +122,22 @@ export class LibroKernelManager {
|
|
|
114
122
|
await this.refreshRunning();
|
|
115
123
|
}
|
|
116
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Shut down all kernels.
|
|
127
|
+
*/
|
|
128
|
+
async shutdownAll(): Promise<void> {
|
|
129
|
+
// Update the list of models to make sure our list is current.
|
|
130
|
+
await this.refreshRunning();
|
|
131
|
+
|
|
132
|
+
// Shut down all models.
|
|
133
|
+
await Promise.all(
|
|
134
|
+
[...this._models.keys()].map((id) => this.kernelRestAPI.shutdownKernel(id)),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Update the list of models to clear out our state.
|
|
138
|
+
await this.refreshRunning();
|
|
139
|
+
}
|
|
140
|
+
|
|
117
141
|
async connectToKernel(options: KernelConnectionOptions) {
|
|
118
142
|
const kernelConnection = this.kernelConnectionFactory(options);
|
|
119
143
|
this.startKernel(kernelConnection);
|
|
@@ -180,8 +204,10 @@ export class LibroKernelManager {
|
|
|
180
204
|
* Execute a request to the server to poll running kernels and update state.
|
|
181
205
|
*/
|
|
182
206
|
protected async requestRunning(): Promise<void> {
|
|
207
|
+
let models: KernelMeta[];
|
|
208
|
+
|
|
183
209
|
try {
|
|
184
|
-
await this.kernelRestAPI.listRunning();
|
|
210
|
+
models = await this.kernelRestAPI.listRunning();
|
|
185
211
|
} catch (err: any) {
|
|
186
212
|
// Handle network errors, as well as cases where we are on a
|
|
187
213
|
// JupyterHub and the server is not running. JupyterHub returns a
|
|
@@ -195,5 +221,29 @@ export class LibroKernelManager {
|
|
|
195
221
|
}
|
|
196
222
|
throw err;
|
|
197
223
|
}
|
|
224
|
+
|
|
225
|
+
if (
|
|
226
|
+
this._models.size === models.length &&
|
|
227
|
+
models.every((model) => {
|
|
228
|
+
const existing = this._models.get(model.id);
|
|
229
|
+
if (!existing) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
return (
|
|
233
|
+
existing.connections === model.connections &&
|
|
234
|
+
existing.execution_state === model.execution_state &&
|
|
235
|
+
existing.last_activity === model.last_activity &&
|
|
236
|
+
existing.name === model.name &&
|
|
237
|
+
existing.reason === model.reason &&
|
|
238
|
+
existing.traceback === model.traceback
|
|
239
|
+
);
|
|
240
|
+
})
|
|
241
|
+
) {
|
|
242
|
+
// Identical models list (presuming models does not contain duplicate
|
|
243
|
+
// ids), so just return
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
this._models = new Map(models.map((x) => [x.id, x]));
|
|
198
248
|
}
|
|
199
249
|
}
|
|
@@ -23,12 +23,16 @@ export class LibroKernelConnectionManager {
|
|
|
23
23
|
this.kernelConnectionMap = new Map<string, IKernelConnection>();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
private mpKey(fileInfo: IContentsModel) {
|
|
27
|
+
return fileInfo.path || fileInfo.name; // 优先用path作为key
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
async startNew(fileInfo: IContentsModel): Promise<IKernelConnection | undefined> {
|
|
27
31
|
const connection = await this.sessionManager.startNew(fileInfo);
|
|
28
32
|
if (!connection) {
|
|
29
33
|
throw new Error('start new kernel connection failed');
|
|
30
34
|
}
|
|
31
|
-
this.kernelConnectionMap.set(fileInfo
|
|
35
|
+
this.kernelConnectionMap.set(this.mpKey(fileInfo), connection);
|
|
32
36
|
return connection;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -43,20 +47,19 @@ export class LibroKernelConnectionManager {
|
|
|
43
47
|
if (!connection) {
|
|
44
48
|
throw new Error('change kernel connection failed');
|
|
45
49
|
}
|
|
46
|
-
this.kernelConnectionMap.set(fileInfo
|
|
50
|
+
this.kernelConnectionMap.set(this.mpKey(fileInfo), connection);
|
|
47
51
|
return connection;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
async shutdownKC(fileInfo: IContentsModel) {
|
|
51
|
-
const
|
|
52
|
-
const kc = this.kernelConnectionMap.get(fileName);
|
|
55
|
+
const kc = this.kernelConnectionMap.get(this.mpKey(fileInfo));
|
|
53
56
|
|
|
54
57
|
if (!kc) {
|
|
55
58
|
throw new Error('interrupt connection failed');
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
await this.sessionManager.shutdownKC(fileInfo, kc);
|
|
59
|
-
this.kernelConnectionMap.delete(
|
|
62
|
+
this.kernelConnectionMap.delete(this.mpKey(fileInfo));
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
getAllKernelConnections() {
|
|
@@ -64,7 +67,7 @@ export class LibroKernelConnectionManager {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
getKernelConnection(fileInfo: IContentsModel) {
|
|
67
|
-
const connection = this.kernelConnectionMap.get(fileInfo
|
|
70
|
+
const connection = this.kernelConnectionMap.get(this.mpKey(fileInfo));
|
|
68
71
|
if (connection && !connection.isDisposed) {
|
|
69
72
|
return connection;
|
|
70
73
|
}
|
|
@@ -52,9 +52,16 @@ export class LibroSessionManager {
|
|
|
52
52
|
protected _ready: Promise<void>;
|
|
53
53
|
protected _isReady = false;
|
|
54
54
|
protected storageService: StorageService;
|
|
55
|
+
|
|
56
|
+
@prop()
|
|
55
57
|
protected _models: Map<string, SessionIModel>;
|
|
58
|
+
|
|
56
59
|
protected _sessionConnections: Map<string, IKernelConnection>; // sessionId -> kernelConnection
|
|
57
60
|
|
|
61
|
+
get running(): Map<string, SessionIModel> {
|
|
62
|
+
return this._models;
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
constructor(
|
|
59
66
|
@inject(LibroKernelManager) kernelManager: LibroKernelManager,
|
|
60
67
|
@inject(ServerManager) serverManager: ServerManager,
|
|
@@ -117,6 +124,27 @@ export class LibroSessionManager {
|
|
|
117
124
|
throw err;
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
if (
|
|
128
|
+
this._models.size === models.length &&
|
|
129
|
+
models.every((model) => {
|
|
130
|
+
const existing = this._models.get(model.id);
|
|
131
|
+
if (!existing) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return (
|
|
135
|
+
existing.kernel?.id === model.kernel?.id &&
|
|
136
|
+
existing.kernel?.name === model.kernel?.name &&
|
|
137
|
+
existing.name === model.name &&
|
|
138
|
+
existing.path === model.path &&
|
|
139
|
+
existing.type === model.type
|
|
140
|
+
);
|
|
141
|
+
})
|
|
142
|
+
) {
|
|
143
|
+
// Identical models list (presuming models does not contain duplicate
|
|
144
|
+
// ids), so just return
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
120
148
|
this._models = new Map(models.map((x) => [x.id, x]));
|
|
121
149
|
|
|
122
150
|
for (const [sessionId, kc] of this._sessionConnections) {
|
|
@@ -181,7 +209,7 @@ export class LibroSessionManager {
|
|
|
181
209
|
kernel: {
|
|
182
210
|
kernelName: reuseKernelInfo
|
|
183
211
|
? reuseKernelInfo.name
|
|
184
|
-
: fileInfo.content
|
|
212
|
+
: fileInfo.content?.metadata?.kernelspec?.name || firstKernelSpecName, // 使用ipynb文件原本的kernel name,或者使用kernel spec轮询得到的第一个kernel name
|
|
185
213
|
},
|
|
186
214
|
path: fileInfo.path,
|
|
187
215
|
type: fileInfo.type,
|
|
@@ -328,7 +356,7 @@ export class LibroSessionManager {
|
|
|
328
356
|
{
|
|
329
357
|
name: fileInfo.name,
|
|
330
358
|
kernel: {
|
|
331
|
-
kernelName: options.name || fileInfo.content
|
|
359
|
+
kernelName: options.name || fileInfo.content?.metadata?.kernelspec.name,
|
|
332
360
|
},
|
|
333
361
|
path: fileInfo.path,
|
|
334
362
|
type: fileInfo.type,
|