Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update @jupyterlab/services #2117

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/kernel-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Grammar } from "atom";
import { observable, action } from "mobx";
import { log } from "./utils";
import type { KernelspecMetadata } from "@nteract/types";
import type { Kernel } from "@jupyterlab/services";
import type { ISpecModel } from "@jupyterlab/services/lib/kernelspec/kernelspec";

export type ResultsCallback = (
message: any,
Expand All @@ -19,18 +19,15 @@ export default class KernelTransport {
inspector = {
bundle: {},
};
kernelSpec: Kernel.ISpecModel | KernelspecMetadata;
kernelSpec: ISpecModel | KernelspecMetadata;
grammar: Grammar;
language: string;
displayName: string;
// Only `WSKernel` would have `gatewayName` property and thus not initialize it here,
// still `KernelTransport` is better to have `gatewayName` property for code simplicity in the other parts of code
gatewayName: string | null | undefined;

constructor(
kernelSpec: Kernel.ISpecModel | KernelspecMetadata,
grammar: Grammar
) {
constructor(kernelSpec: ISpecModel | KernelspecMetadata, grammar: Grammar) {
this.kernelSpec = kernelSpec;
this.grammar = grammar;
this.language = kernelSpec.language.toLowerCase();
Expand Down
4 changes: 2 additions & 2 deletions lib/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
import InputView from "./input-view";
import KernelTransport from "./kernel-transport";
import type { ResultsCallback } from "./kernel-transport";
import type { Kernel as JupyterlabKernel } from "@jupyterlab/services";
import type { ISpecModel } from "@jupyterlab/services/lib/kernelspec/kernelspec";

import type { Message } from "./hydrogen";
import type { KernelspecMetadata } from "@nteract/types";
Expand Down Expand Up @@ -216,7 +216,7 @@ export default class Kernel {
this.middleware = [delegateToTransport];
}

get kernelSpec(): JupyterlabKernel.ISpecModel | KernelspecMetadata {
get kernelSpec(): ISpecModel | KernelspecMetadata {
return this.transport.kernelSpec;
}

Expand Down
18 changes: 10 additions & 8 deletions lib/ws-kernel-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import ws from "ws";
import { XMLHttpRequest as NodeXMLHttpRequest } from "xmlhttprequest"; // TODO use @aminya/xmlhttprequest
import { URL } from "url";
import { Kernel, Session, ServerConnection } from "@jupyterlab/services";
import type {
ISpecModel,
ISpecModels,
} from "@jupyterlab/services/lib/kernelspec/kernelspec";
import Config from "./config";
import WSKernel from "./ws-kernel";
import InputView from "./input-view";
Expand Down Expand Up @@ -38,7 +42,7 @@ export interface SessionInfoWithModel {

export interface SessionInfoWithoutModel {
name?: string;
kernelSpecs: Kernel.ISpecModel[];
kernelSpecs: ISpecModel[];
options: Parameters<typeof Session.startNew>[0];
// no model
model?: never | null | undefined;
Expand Down Expand Up @@ -110,7 +114,7 @@ class CustomListView {

export default class WSKernelPicker {
_onChosen: (kernel: WSKernel) => void;
_kernelSpecFilter: (kernelSpec: Kernel.ISpecModel) => boolean;
_kernelSpecFilter: (kernelSpec: ISpecModel) => boolean;
_path: string;
listView: CustomListView;

Expand All @@ -120,9 +124,7 @@ export default class WSKernelPicker {
}

async toggle(
_kernelSpecFilter: (
kernelSpec: Kernel.ISpecModel | KernelspecMetadata
) => boolean
_kernelSpecFilter: (kernelSpec: ISpecModel | KernelspecMetadata) => boolean
) {
setPreviouslyFocusedElement(this.listView);
this._kernelSpecFilter = _kernelSpecFilter;
Expand Down Expand Up @@ -231,7 +233,7 @@ export default class WSKernelPicker {

async promptForToken(options: DeepWriteable<KernelGatewayOptions>) {
const token = await this.promptForText("Token:");

debugger;
if (token === null) {
return false;
}
Expand Down Expand Up @@ -298,7 +300,7 @@ export default class WSKernelPicker {
...gatewayInfo.options,
};
let serverSettings = ServerConnection.makeSettings(gatewayOptions);
let specModels: Kernel.ISpecModels | undefined;
let specModels: ISpecModels | undefined;
try {
specModels = await Kernel.getSpecs(serverSettings);
} catch (error) {
Expand Down Expand Up @@ -464,7 +466,7 @@ export default class WSKernelPicker {
);
}

async onSessionChosen(gatewayName: string, session: Session.ISession) {
async onSessionChosen(gatewayName: string, session: Session.ISessionConnection) {
this.listView.cancel();
const kernelSpec = await session.kernel.getSpec();
if (!store.grammar) {
Expand Down
13 changes: 7 additions & 6 deletions lib/ws-kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ import KernelTransport from "./kernel-transport";
import type { ResultsCallback } from "./kernel-transport";
import InputView from "./input-view";
import { log, js_idx_to_char_idx } from "./utils";
import type { Session, Kernel } from "@jupyterlab/services";
import type { Session } from "@jupyterlab/services";
import type { Message } from "./hydrogen";
import type { KernelspecMetadata } from "@nteract/types";
import type { ISpecModel } from "@jupyterlab/services/lib/kernelspec/kernelspec";

export default class WSKernel extends KernelTransport {
session: Session.ISession;
session: Session.ISessionConnection;

constructor(
gatewayName: string,
kernelSpec: Kernel.ISpecModel | KernelspecMetadata,
kernelSpec: ISpecModel | KernelspecMetadata,
grammar: Grammar,
session: Session.ISession
session: Session.ISessionConnection
) {
super(kernelSpec, grammar);
this.session = session;
this.gatewayName = gatewayName;
this.session.statusChanged.connect(() =>
this.setExecutionState(this.session.status)
this.setExecutionState(this.session.kernel.status)
);
this.setExecutionState(this.session.status); // Set initial status correctly
this.setExecutionState(this.session.kernel.status); // Set initial status correctly
}

interrupt() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"dependencies": {
"@aminya/jmp": "^2.0.9",
"@jupyterlab/services": "^0.52.0",
"@jupyterlab/services": "^6.0.9",
"@nteract/commutable": "^7.1.4",
"@nteract/markdown": "^4.5.1",
"@nteract/mathjax": "^4.0.2",
Expand Down