UNPKG

4.33 kBTypeScriptView Raw
1import { ServerConnection } from '../serverconnection';
2/**
3 * The kernel model provided by the server.
4 *
5 * #### Notes
6 * See the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels).
7 */
8export interface IModel {
9 /**
10 * Unique identifier of the kernel on the server.
11 */
12 readonly id: string;
13 /**
14 * The name of the kernel.
15 */
16 readonly name: string;
17 /**
18 * The kernel execution state.
19 */
20 readonly execution_state?: string;
21 /**
22 * The timestamp of the last activity on the kernel.
23 */
24 readonly last_activity?: string;
25 /**
26 * The number of active connections to the kernel.
27 */
28 readonly connections?: number;
29 /**
30 * The reason the kernel died, if applicable.
31 */
32 readonly reason?: string;
33 /**
34 * The traceback for a dead kernel, if applicable.
35 */
36 readonly traceback?: string;
37}
38/**
39 * The url for the kernel service.
40 */
41export declare const KERNEL_SERVICE_URL = "api/kernels";
42/**
43 * Fetch the running kernels.
44 *
45 * @param settings - The optional server settings.
46 *
47 * @returns A promise that resolves with the list of running kernels.
48 *
49 * #### Notes
50 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
51 *
52 * The promise is fulfilled on a valid response and rejected otherwise.
53 */
54export declare function listRunning(settings?: ServerConnection.ISettings): Promise<IModel[]>;
55/**
56 * Start a new kernel.
57 *
58 * @param options - The options used to create the kernel.
59 *
60 * @returns A promise that resolves with a kernel connection object.
61 *
62 * #### Notes
63 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
64 *
65 * The promise is fulfilled on a valid response and rejected otherwise.
66 */
67export declare function startNew(options?: IKernelOptions, settings?: ServerConnection.ISettings): Promise<IModel>;
68/**
69 * The options object used to initialize a kernel.
70 */
71export declare type IKernelOptions = Partial<Pick<IModel, 'name'>>;
72/**
73 * Restart a kernel.
74 *
75 * #### Notes
76 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
77 *
78 * The promise is fulfilled on a valid response (and thus after a restart) and rejected otherwise.
79 */
80export declare function restartKernel(id: string, settings?: ServerConnection.ISettings): Promise<void>;
81/**
82 * Interrupt a kernel.
83 *
84 * #### Notes
85 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
86 *
87 * The promise is fulfilled on a valid response and rejected otherwise.
88 */
89export declare function interruptKernel(id: string, settings?: ServerConnection.ISettings): Promise<void>;
90/**
91 * Shut down a kernel.
92 *
93 * @param id - The id of the running kernel.
94 *
95 * @param settings - The server settings for the request.
96 *
97 * @returns A promise that resolves when the kernel is shut down.
98 *
99 *
100 * #### Notes
101 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
102 *
103 * The promise is fulfilled on a valid response and rejected otherwise.
104 */
105export declare function shutdownKernel(id: string, settings?: ServerConnection.ISettings): Promise<void>;
106/**
107 * Get a full kernel model from the server by kernel id string.
108 *
109 * #### Notes
110 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.
111 *
112 * The promise is fulfilled on a valid response and rejected otherwise.
113 */
114export declare function getKernelModel(id: string, settings?: ServerConnection.ISettings): Promise<IModel | undefined>;