-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathkernel-transport.ts
More file actions
83 lines (70 loc) · 2.33 KB
/
kernel-transport.ts
File metadata and controls
83 lines (70 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Grammar } from "atom";
import { observable, action } from "mobx";
import { log } from "./utils";
import type { KernelspecMetadata } from "@nteract/types";
import type { ISpecModel } from "@jupyterlab/services/lib/kernelspec/kernelspec";
export type ResultsCallback = (
message: any,
channel: "shell" | "iopub" | "stdin"
) => void;
export default class KernelTransport {
@observable
executionState = "loading";
@observable
executionCount = 0;
@observable
lastExecutionTime = "No execution";
@observable
inspector = {
bundle: {},
};
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: ISpecModel | KernelspecMetadata, grammar: Grammar) {
this.kernelSpec = kernelSpec;
this.grammar = grammar;
this.language = kernelSpec.language.toLowerCase();
this.displayName = kernelSpec.display_name;
}
@action
setExecutionState(state: string) {
this.executionState = state;
}
@action
setExecutionCount(count: number) {
this.executionCount = count;
}
@action
setLastExecutionTime(timeString: string) {
this.lastExecutionTime = timeString;
}
interrupt() {
throw new Error("KernelTransport: interrupt method not implemented");
}
shutdown() {
throw new Error("KernelTransport: shutdown method not implemented");
}
restart(onRestarted: ((...args: Array<any>) => any) | null | undefined) {
throw new Error("KernelTransport: restart method not implemented");
}
execute(code: string, onResults: ResultsCallback) {
throw new Error("KernelTransport: execute method not implemented");
}
complete(code: string, onResults: ResultsCallback) {
throw new Error("KernelTransport: complete method not implemented");
}
inspect(code: string, cursorPos: number, onResults: ResultsCallback) {
throw new Error("KernelTransport: inspect method not implemented");
}
inputReply(input: string) {
throw new Error("KernelTransport: inputReply method not implemented");
}
destroy() {
log("KernelTransport: Destroying base kernel");
}
}