UNPKG

6.49 kBTypeScriptView Raw
1import { ISignal } from '@lumino/signaling';
2import { Kernel, KernelMessage } from '../kernel';
3import { ServerConnection } from '..';
4import * as Session from './session';
5/**
6 * Session object for accessing the session REST api. The session
7 * should be used to start kernels and then shut them down -- for
8 * all other kernel operations, the kernel object should be used.
9 */
10export declare class SessionConnection implements Session.ISessionConnection {
11 /**
12 * Construct a new session.
13 */
14 constructor(options: Session.ISessionConnection.IOptions);
15 /**
16 * A signal emitted when the session is disposed.
17 */
18 get disposed(): ISignal<this, void>;
19 /**
20 * A signal emitted when the kernel changes.
21 */
22 get kernelChanged(): ISignal<this, Session.ISessionConnection.IKernelChangedArgs>;
23 /**
24 * A signal proxied from the connection about the kernel status.
25 */
26 get statusChanged(): ISignal<this, Kernel.Status>;
27 /**
28 * A signal proxied from the kernel about the connection status.
29 */
30 get connectionStatusChanged(): ISignal<this, Kernel.ConnectionStatus>;
31 /**
32 * A signal proxied from the kernel pending input.
33 */
34 get pendingInput(): ISignal<this, boolean>;
35 /**
36 * A signal proxied from the kernel about iopub kernel messages.
37 */
38 get iopubMessage(): ISignal<this, KernelMessage.IIOPubMessage>;
39 /**
40 * A signal proxied from the kernel for an unhandled kernel message.
41 */
42 get unhandledMessage(): ISignal<this, KernelMessage.IMessage>;
43 /**
44 * A signal proxied from the kernel emitted for any kernel message.
45 *
46 * #### Notes
47 * The behavior is undefined if the message is modified during message
48 * handling. As such, it should be treated as read-only.
49 */
50 get anyMessage(): ISignal<this, Kernel.IAnyMessageArgs>;
51 /**
52 * A signal emitted when a session property changes.
53 */
54 get propertyChanged(): ISignal<this, 'path' | 'name' | 'type'>;
55 /**
56 * Get the session id.
57 */
58 get id(): string;
59 /**
60 * Get the session kernel connection object.
61 *
62 * #### Notes
63 * This is a read-only property, and can be altered by [changeKernel].
64 */
65 get kernel(): Kernel.IKernelConnection | null;
66 /**
67 * Get the session path.
68 */
69 get path(): string;
70 /**
71 * Get the session type.
72 */
73 get type(): string;
74 /**
75 * Get the session name.
76 */
77 get name(): string;
78 /**
79 * Get the model associated with the session.
80 */
81 get model(): Session.IModel;
82 /**
83 * The server settings of the session.
84 */
85 readonly serverSettings: ServerConnection.ISettings;
86 /**
87 * Test whether the session has been disposed.
88 */
89 get isDisposed(): boolean;
90 /**
91 * Update the session based on a session model from the server.
92 *
93 * #### Notes
94 * This only updates this session connection instance. Use `setPath`,
95 * `setName`, `setType`, and `changeKernel` to change the session values on
96 * the server.
97 */
98 update(model: Session.IModel): void;
99 /**
100 * Dispose of the resources held by the session.
101 */
102 dispose(): void;
103 /**
104 * Change the session path.
105 *
106 * @param path - The new session path.
107 *
108 * @returns A promise that resolves when the session has renamed.
109 *
110 * #### Notes
111 * This uses the Jupyter REST API, and the response is validated.
112 * The promise is fulfilled on a valid response and rejected otherwise.
113 */
114 setPath(path: string): Promise<void>;
115 /**
116 * Change the session name.
117 */
118 setName(name: string): Promise<void>;
119 /**
120 * Change the session type.
121 */
122 setType(type: string): Promise<void>;
123 /**
124 * Change the kernel.
125 *
126 * @param options - The name or id of the new kernel.
127 *
128 * #### Notes
129 * This shuts down the existing kernel and creates a new kernel,
130 * keeping the existing session ID and session path.
131 */
132 changeKernel(options: Partial<Kernel.IModel>): Promise<Kernel.IKernelConnection | null>;
133 /**
134 * Kill the kernel and shutdown the session.
135 *
136 * @returns - The promise fulfilled on a valid response from the server.
137 *
138 * #### Notes
139 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/sessions), and validates the response.
140 * Disposes of the session and emits a [sessionDied] signal on success.
141 */
142 shutdown(): Promise<void>;
143 /**
144 * Create a new kernel connection and connect to its signals.
145 *
146 * #### Notes
147 * This method is not meant to be subclassed.
148 */
149 protected setupKernel(model: Kernel.IModel | null): void;
150 /**
151 * Handle to changes in the Kernel status.
152 */
153 protected onKernelStatus(sender: Kernel.IKernelConnection, state: Kernel.Status): void;
154 /**
155 * Handle to changes in the Kernel status.
156 */
157 protected onKernelConnectionStatus(sender: Kernel.IKernelConnection, state: Kernel.ConnectionStatus): void;
158 /**
159 * Handle a change in the pendingInput.
160 */
161 protected onPendingInput(sender: Kernel.IKernelConnection, state: boolean): void;
162 /**
163 * Handle iopub kernel messages.
164 */
165 protected onIOPubMessage(sender: Kernel.IKernelConnection, msg: KernelMessage.IIOPubMessage): void;
166 /**
167 * Handle unhandled kernel messages.
168 */
169 protected onUnhandledMessage(sender: Kernel.IKernelConnection, msg: KernelMessage.IMessage): void;
170 /**
171 * Handle any kernel messages.
172 */
173 protected onAnyMessage(sender: Kernel.IKernelConnection, args: Kernel.IAnyMessageArgs): void;
174 /**
175 * Send a PATCH to the server, updating the session path or the kernel.
176 */
177 private _patch;
178 /**
179 * Handle a change to the model.
180 */
181 private _handleModelChange;
182 private _id;
183 private _path;
184 private _name;
185 private _type;
186 private _username;
187 private _clientId;
188 private _kernel;
189 private _isDisposed;
190 private _disposed;
191 private _kernelChanged;
192 private _statusChanged;
193 private _connectionStatusChanged;
194 private _pendingInput;
195 private _iopubMessage;
196 private _unhandledMessage;
197 private _anyMessage;
198 private _propertyChanged;
199 private _connectToKernel;
200 private _kernelConnectionOptions;
201}
202
\No newline at end of file