@jupyterlab/services
- Version 7.3.5
- Published
- 1.22 MB
- 11 dependencies
- BSD-3-Clause license
Install
npm i @jupyterlab/services
yarn add @jupyterlab/services
pnpm add @jupyterlab/services
Overview
services
Index
Classes
KernelConnection
- anyMessage
- clientId
- clone()
- connectionStatus
- connectionStatusChanged
- createComm()
- dispose()
- disposed
- handleComms
- handleShutdown()
- hasComm()
- hasPendingInput
- id
- info
- interrupt()
- iopubMessage
- isDisposed
- model
- name
- pendingInput
- reconnect()
- registerCommTarget()
- registerMessageHook()
- removeCommTarget()
- removeInputGuard()
- removeMessageHook()
- requestCommInfo()
- requestComplete()
- requestDebug()
- requestExecute()
- requestHistory()
- requestInspect()
- requestIsComplete()
- requestKernelInfo()
- restart()
- sendControlMessage()
- sendInputReply()
- sendShellMessage()
- serverSettings
- shutdown()
- spec
- status
- statusChanged
- unhandledMessage
- username
Interfaces
Namespaces
KernelMessage
- Channel
- ControlMessageType
- createMessage()
- IClearOutputMsg
- ICommCloseMsg
- ICommInfoReply
- ICommInfoReplyMsg
- ICommInfoRequestMsg
- ICommMsgMsg
- ICommOpenMsg
- ICompleteReplyMsg
- ICompleteRequestMsg
- IControlMessage
- IDebugEventMsg
- IDebugReplyMsg
- IDebugRequestMsg
- IDisplayDataMsg
- IErrorMsg
- IExecuteCount
- IExecuteInputMsg
- IExecuteReply
- IExecuteReplyMsg
- IExecuteRequestMsg
- IExecuteResultMsg
- IHeader
- IHistoryReply
- IHistoryReplyMsg
- IHistoryRequestMsg
- IHistoryRequestRange
- IHistoryRequestSearch
- IHistoryRequestTail
- IInfoReply
- IInfoReplyMsg
- IInfoRequestMsg
- IInputReply
- IInputReplyMsg
- IInputRequestMsg
- IInspectReply
- IInspectReplyMsg
- IInspectRequestMsg
- IIOPubMessage
- IIsCompleteReplyIncomplete
- IIsCompleteReplyMsg
- IIsCompleteReplyOther
- IIsCompleteRequestMsg
- ILanguageInfo
- IMessage
- IOptions
- IOPubMessageType
- IReplyAbortContent
- IReplyErrorContent
- IReplyOkContent
- isClearOutputMsg()
- isCommCloseMsg()
- isCommMsgMsg()
- isCommOpenMsg()
- isDebugEventMsg()
- isDebugReplyMsg()
- isDebugRequestMsg()
- isDisplayDataMsg()
- isErrorMsg()
- isExecuteInputMsg()
- isExecuteReplyMsg()
- isExecuteResultMsg()
- IShellControlMessage
- IShellMessage
- isInfoRequestMsg()
- isInputReplyMsg()
- isInputRequestMsg()
- isStatusMsg()
- isStreamMsg()
- IStatusMsg
- IStdinMessage
- IStreamMsg
- isUpdateDisplayDataMsg()
- IUpdateDisplayDataMsg
- Message
- MessageType
- ShellMessageType
- Status
- StdinMessageType
- supportedKernelWebSocketProtocols
Classes
class BaseManager
abstract class BaseManager implements IManager {}
constructor
constructor(options: BaseManager.IOptions);
property connectionFailure
abstract connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property disposed
readonly disposed: ISignal<this, void>;
A signal emitted when the delegate is disposed.
property isActive
readonly isActive: boolean;
Whether the manager is active.
property isDisposed
readonly isDisposed: boolean;
Test whether the delegate has been disposed.
property isReady
abstract isReady: boolean;
Test whether the manager is ready.
property ready
abstract ready: Promise<void>;
A promise that fulfills when the manager is ready.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the manager.
method dispose
dispose: () => void;
Dispose of the delegate and invoke the callback function.
class ConfigWithDefaults
class ConfigWithDefaults {}
Configurable object with defaults.
constructor
constructor(options: ConfigWithDefaults.IOptions);
Create a new config with defaults.
method get
get: (key: string) => JSONValue;
Get data from the config section or fall back to defaults.
method set
set: (key: string, value: JSONValue) => Promise<JSONValue>;
Set a config value.
#### Notes 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#!/config).
The promise is fulfilled on a valid response and rejected otherwise.
Sends the update to the server, and changes our local copy of the data immediately.
class ContentsManager
class ContentsManager implements Contents.IManager {}
A contents manager that passes file operations to the server. Multiple servers implementing the
IDrive
interface can be attached to the contents manager, so that the same session can perform file operations on multiple backends.This includes checkpointing with the normal file operations.
constructor
constructor(options?: ContentsManager.IOptions);
Construct a new contents manager object.
Parameter options
The options used to initialize the object.
property fileChanged
readonly fileChanged: ISignal<this, Contents.IChangedArgs>;
A signal emitted when a file operation takes place.
property isDisposed
readonly isDisposed: boolean;
Test whether the manager has been disposed.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings associated with the manager.
method addDrive
addDrive: (drive: Contents.IDrive) => void;
Add an
IDrive
to the manager.
method copy
copy: (fromFile: string, toDir: string) => Promise<Contents.IModel>;
Copy a file into a given directory.
Parameter path
The original file path.
Parameter toDir
The destination directory path.
Returns
A promise which resolves with the new contents model when the file is copied.
#### Notes The server will select the name of the copied file.
method createCheckpoint
createCheckpoint: (path: string) => Promise<Contents.ICheckpointModel>;
Create a checkpoint for a file.
Parameter path
The path of the file.
Returns
A promise which resolves with the new checkpoint model when the checkpoint is created.
method delete
delete: (path: string) => Promise<void>;
Delete a file.
Parameter path
The path to the file.
Returns
A promise which resolves when the file is deleted.
method deleteCheckpoint
deleteCheckpoint: (path: string, checkpointID: string) => Promise<void>;
Delete a checkpoint for a file.
Parameter path
The path of the file.
Parameter checkpointID
The id of the checkpoint to delete.
Returns
A promise which resolves when the checkpoint is deleted.
method dispose
dispose: () => void;
Dispose of the resources held by the manager.
method driveName
driveName: (path: string) => string;
Given a path of the form
drive:local/portion/of/it.txt
get the name of the drive. If the path is missing a drive portion, returns an empty string.Parameter path
the path.
Returns
The drive name for the path, or the empty string.
method get
get: ( path: string, options?: Contents.IFetchOptions) => Promise<Contents.IModel>;
Get a file or directory.
Parameter path
The path to the file.
Parameter options
The options used to fetch the file.
Returns
A promise which resolves with the file content.
method getDownloadUrl
getDownloadUrl: (path: string) => Promise<string>;
Get an encoded download url given a file path.
Parameter path
An absolute POSIX file path on the server.
#### Notes It is expected that the path contains no relative paths.
The returned URL may include a query parameter.
method getSharedModelFactory
getSharedModelFactory: (path: string) => Contents.ISharedFactory | null;
Given a path, get a shared model factory from the relevant backend. Returns
null
if the backend does not provide one.
method listCheckpoints
listCheckpoints: (path: string) => Promise<Contents.ICheckpointModel[]>;
List available checkpoints for a file.
Parameter path
The path of the file.
Returns
A promise which resolves with a list of checkpoint models for the file.
method localPath
localPath: (path: string) => string;
Given a path of the form
drive:local/portion/of/it.txt
get the local part of it.Parameter path
the path.
Returns
The local part of the path.
method newUntitled
newUntitled: (options?: Contents.ICreateOptions) => Promise<Contents.IModel>;
Create a new untitled file or directory in the specified directory path.
Parameter options
The options used to create the file.
Returns
A promise which resolves with the created file content when the file is created.
method normalize
normalize: (path: string) => string;
Normalize a global path. Reduces '..' and '.' parts, and removes leading slashes from the local part of the path, while retaining the drive name if it exists.
Parameter path
the path.
Returns
The normalized path.
method rename
rename: (path: string, newPath: string) => Promise<Contents.IModel>;
Rename a file or directory.
Parameter path
The original file path.
Parameter newPath
The new file path.
Returns
A promise which resolves with the new file contents model when the file is renamed.
method resolvePath
resolvePath: (root: string, path: string) => string;
Resolve a global path, starting from the root path. Behaves like posix-path.resolve, with 3 differences: - will never prepend cwd - if root has a drive name, the result is prefixed with ":" - before adding drive name, leading slashes are removed
Parameter path
the path.
Returns
The normalized path.
method restoreCheckpoint
restoreCheckpoint: (path: string, checkpointID: string) => Promise<void>;
Restore a file to a known checkpoint state.
Parameter path
The path of the file.
Parameter checkpointID
The id of the checkpoint to restore.
Returns
A promise which resolves when the checkpoint is restored.
method save
save: ( path: string, options?: Partial<Contents.IModel>) => Promise<Contents.IModel>;
Save a file.
Parameter path
The desired file path.
Parameter options
Optional overrides to the model.
Returns
A promise which resolves with the file content model when the file is saved.
#### Notes Ensure that
model.content
is populated for the file.
class Drive
class Drive implements Contents.IDrive {}
A default implementation for an
IDrive
, talking to the server using the Jupyter REST API.
constructor
constructor(options?: Drive.IOptions);
Construct a new contents manager object.
Parameter options
The options used to initialize the object.
property fileChanged
readonly fileChanged: ISignal<this, Contents.IChangedArgs>;
A signal emitted when a file operation takes place.
property isDisposed
readonly isDisposed: boolean;
Test whether the manager has been disposed.
property name
readonly name: string;
The name of the drive, which is used at the leading component of file paths.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the drive.
method copy
copy: (fromFile: string, toDir: string) => Promise<Contents.IModel>;
Copy a file into a given directory.
Parameter localPath
The original file path.
Parameter toDir
The destination directory path.
Returns
A promise which resolves with the new contents model when the file is copied.
#### Notes The server will select the name of the copied file.
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#!/contents) and validates the response model.
method createCheckpoint
createCheckpoint: (localPath: string) => Promise<Contents.ICheckpointModel>;
Create a checkpoint for a file.
Parameter localPath
The path of the file.
Returns
A promise which resolves with the new checkpoint model when the checkpoint is created.
#### Notes 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#!/contents) and validates the response model.
method delete
delete: (localPath: string) => Promise<void>;
Delete a file.
Parameter localPath
The path to the file.
Returns
A promise which resolves when the file is deleted.
#### Notes 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#!/contents).
method deleteCheckpoint
deleteCheckpoint: (localPath: string, checkpointID: string) => Promise<void>;
Delete a checkpoint for a file.
Parameter localPath
The path of the file.
Parameter checkpointID
The id of the checkpoint to delete.
Returns
A promise which resolves when the checkpoint is deleted.
#### Notes 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#!/contents).
method dispose
dispose: () => void;
Dispose of the resources held by the manager.
method get
get: ( localPath: string, options?: Contents.IFetchOptions) => Promise<Contents.IModel>;
Get a file or directory.
Parameter localPath
The path to the file.
Parameter options
The options used to fetch the file.
Returns
A promise which resolves with the file content.
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#!/contents) and validates the response model.
method getDownloadUrl
getDownloadUrl: (localPath: string) => Promise<string>;
Get an encoded download url given a file path.
Parameter localPath
An absolute POSIX file path on the server.
#### Notes It is expected that the path contains no relative paths.
The returned URL may include a query parameter.
method listCheckpoints
listCheckpoints: (localPath: string) => Promise<Contents.ICheckpointModel[]>;
List available checkpoints for a file.
Parameter localPath
The path of the file.
Returns
A promise which resolves with a list of checkpoint models for the file.
#### Notes 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#!/contents) and validates the response model.
method newUntitled
newUntitled: (options?: Contents.ICreateOptions) => Promise<Contents.IModel>;
Create a new untitled file or directory in the specified directory path.
Parameter options
The options used to create the file.
Returns
A promise which resolves with the created file content when the file is created.
#### Notes 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#!/contents) and validates the response model.
method rename
rename: (oldLocalPath: string, newLocalPath: string) => Promise<Contents.IModel>;
Rename a file or directory.
Parameter oldLocalPath
The original file path.
Parameter newLocalPath
The new file path.
Returns
A promise which resolves with the new file contents model when the file is renamed.
#### Notes 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#!/contents) and validates the response model.
method restoreCheckpoint
restoreCheckpoint: (localPath: string, checkpointID: string) => Promise<void>;
Restore a file to a known checkpoint state.
Parameter localPath
The path of the file.
Parameter checkpointID
The id of the checkpoint to restore.
Returns
A promise which resolves when the checkpoint is restored.
#### Notes 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#!/contents).
method save
save: ( localPath: string, options?: Partial<Contents.IModel>) => Promise<Contents.IModel>;
Save a file.
Parameter localPath
The desired file path.
Parameter options
Optional overrides to the model.
Returns
A promise which resolves with the file content model when the file is saved.
#### Notes Ensure that
model.content
is populated for the file.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#!/contents) and validates the response model.
class EventManager
class EventManager implements Event.IManager {}
The events API service manager.
constructor
constructor(options?: EventManager.IOptions);
Create a new event manager.
property isDisposed
readonly isDisposed: boolean;
Whether the event manager is disposed.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings used to make API requests.
property stream
readonly stream: IStream<Event.IManager, any>;
An event stream that emits and yields each new event.
method dispose
dispose: () => void;
Dispose the event manager.
method emit
emit: (event: Event.Request) => Promise<void>;
Post an event request to be emitted by the event bus.
class KernelConnection
class KernelConnection implements Kernel.IKernelConnection {}
Implementation of the Kernel object.
#### Notes Messages from the server are handled in the order they were received and asynchronously. Any message handler can return a promise, and message handling will pause until the promise is fulfilled.
constructor
constructor(options: Kernel.IKernelConnection.IOptions);
Construct a kernel object.
property anyMessage
readonly anyMessage: ISignal<this, Kernel.IAnyMessageArgs>;
A signal emitted for any kernel message.
#### Notes This signal is emitted when a message is received, before it is handled asynchronously.
This message is emitted when a message is queued for sending (either in the websocket buffer, or our own pending message buffer). The message may actually be sent across the wire at a later time.
The message emitted in this signal should not be modified in any way.
property clientId
readonly clientId: string;
The client unique id.
property connectionStatus
readonly connectionStatus: Kernel.ConnectionStatus;
The current connection status of the kernel connection.
property connectionStatusChanged
readonly connectionStatusChanged: ISignal<this, Kernel.ConnectionStatus>;
A signal emitted when the kernel status changes.
property disposed
readonly disposed: ISignal<this, void>;
property handleComms
readonly handleComms: boolean;
Handle comm messages
#### Notes The comm message protocol currently has implicit assumptions that only one kernel connection is handling comm messages. This option allows a kernel connection to opt out of handling comms.
See https://github.com/jupyter/jupyter_client/issues/263
property hasPendingInput
hasPendingInput: boolean;
property id
readonly id: string;
The id of the server-side kernel.
property info
readonly info: Promise<KernelMessage.IInfoReply>;
The cached kernel info.
Returns
A promise that resolves to the kernel info.
property iopubMessage
readonly iopubMessage: ISignal< this, KernelMessage.IIOPubMessage<KernelMessage.IOPubMessageType>>;
A signal emitted for iopub kernel messages.
#### Notes This signal is emitted after the iopub message is handled asynchronously.
property isDisposed
readonly isDisposed: boolean;
Test whether the kernel has been disposed.
property model
readonly model: Kernel.IModel;
The kernel model
property name
readonly name: string;
The name of the server-side kernel.
property pendingInput
readonly pendingInput: ISignal<this, boolean>;
A signal emitted when a kernel has pending inputs from the user.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the kernel.
property spec
readonly spec: Promise<KernelSpec.ISpecModel>;
The kernel spec.
Returns
A promise that resolves to the kernel spec.
property status
readonly status: Kernel.Status;
The current status of the kernel.
property statusChanged
readonly statusChanged: ISignal<this, Kernel.Status>;
A signal emitted when the kernel status changes.
property unhandledMessage
readonly unhandledMessage: ISignal< this, KernelMessage.IMessage<KernelMessage.MessageType>>;
A signal emitted for unhandled kernel message.
#### Notes This signal is emitted for a message that was not handled. It is emitted during the asynchronous message handling code.
property username
readonly username: string;
The client username.
method clone
clone: ( options?: Pick< Kernel.IKernelConnection.IOptions, 'clientId' | 'username' | 'handleComms' >) => Kernel.IKernelConnection;
Clone the current kernel with a new clientId.
method createComm
createComm: (targetName: string, commId?: string) => Kernel.IComm;
Create a new comm.
#### Notes If a client-side comm already exists with the given commId, an error is thrown. If the kernel does not handle comms, an error is thrown.
method dispose
dispose: () => void;
Dispose of the resources held by the kernel.
method handleShutdown
handleShutdown: () => void;
Handles a kernel shutdown.
#### Notes This method should be called if we know from outside information that a kernel is dead (for example, we cannot find the kernel model on the server).
method hasComm
hasComm: (commId: string) => boolean;
Check if a comm exists.
method interrupt
interrupt: () => Promise<void>;
Interrupt a kernel.
#### Notes 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#!/kernels).
The promise is fulfilled on a valid response and rejected otherwise.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the kernel status is
Dead
or if the request fails or the response is invalid.
method reconnect
reconnect: () => Promise<void>;
Reconnect to a kernel.
#### Notes This may try multiple times to reconnect to a kernel, and will sever any existing connection.
method registerCommTarget
registerCommTarget: ( targetName: string, callback: ( comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg ) => void | PromiseLike<void>) => void;
Register a comm target handler.
Parameter targetName
The name of the comm target.
Parameter callback
The callback invoked for a comm open message.
Returns
A disposable used to unregister the comm target.
#### Notes Only one comm target can be registered to a target name at a time, an existing callback for the same target name will be overridden. A registered comm target handler will take precedence over a comm which specifies a
target_module
.If the callback returns a promise, kernel message processing will pause until the returned promise is fulfilled.
method registerMessageHook
registerMessageHook: ( msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Register an IOPub message hook.
Parameter msg_id
The parent_header message id the hook will intercept.
Parameter hook
The callback invoked for the message.
#### Notes The IOPub hook system allows you to preempt the handlers for IOPub messages that are responses to a given message id.
The most recently registered hook is run first. A hook can return a boolean or a promise to a boolean, in which case all kernel message processing pauses until the promise is fulfilled. If a hook return value resolves to false, any later hooks will not run and the function will return a promise resolving to false. If a hook throws an error, the error is logged to the console and the next hook is run. If a hook is registered during the hook processing, it will not run until the next message. If a hook is removed during the hook processing, it will be deactivated immediately.
See also [[IFuture.registerMessageHook]].
method removeCommTarget
removeCommTarget: ( targetName: string, callback: ( comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg ) => void | PromiseLike<void>) => void;
Remove a comm target handler.
Parameter targetName
The name of the comm target to remove.
Parameter callback
The callback to remove.
#### Notes The comm target is only removed if the callback argument matches.
method removeInputGuard
removeInputGuard: () => void;
Remove the input guard, if any.
method removeMessageHook
removeMessageHook: ( msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Remove an IOPub message hook.
Parameter msg_id
The parent_header message id the hook intercepted.
Parameter hook
The callback invoked for the message.
method requestCommInfo
requestCommInfo: ( content: KernelMessage.ICommInfoRequestMsg['content']) => Promise<KernelMessage.ICommInfoReplyMsg>;
Send a
comm_info_request
message.#### Notes Fulfills with the
comm_info_reply
content when the shell reply is received and validated.
method requestComplete
requestComplete: ( content: KernelMessage.ICompleteRequestMsg['content']) => Promise<KernelMessage.ICompleteReplyMsg>;
Send a
complete_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
Fulfills with the
complete_reply
content when the shell reply is received and validated.
method requestDebug
requestDebug: ( content: KernelMessage.IDebugRequestMsg['content'], disposeOnDone?: boolean) => Kernel.IControlFuture< KernelMessage.IDebugRequestMsg, KernelMessage.IDebugReplyMsg>;
Send an experimental
debug_request
message.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this function is *NOT* considered part of the public API, and may change without notice.
method requestExecute
requestExecute: ( content: KernelMessage.IExecuteRequestMsg['content'], disposeOnDone?: boolean, metadata?: JSONObject) => Kernel.IShellFuture< KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg>;
Send an
execute_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute).
Future
onReply
is called with theexecute_reply
content when the shell reply is received and validated. The future will resolve when this message is received and theidle
iopub status is received. The future will also be disposed at this point unlessdisposeOnDone
is specified andfalse
, in which case it is up to the caller to dispose of the future.**See also:** [[IExecuteReply]]
method requestHistory
requestHistory: ( content: KernelMessage.IHistoryRequestMsg['content']) => Promise<KernelMessage.IHistoryReplyMsg>;
Send a
history_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
Fulfills with the
history_reply
content when the shell reply is received and validated.
method requestInspect
requestInspect: ( content: KernelMessage.IInspectRequestMsg['content']) => Promise<KernelMessage.IInspectReplyMsg>;
Send an
inspect_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
Fulfills with the
inspect_reply
content when the shell reply is received and validated.
method requestIsComplete
requestIsComplete: ( content: KernelMessage.IIsCompleteRequestMsg['content']) => Promise<KernelMessage.IIsCompleteReplyMsg>;
Send an
is_complete_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
Fulfills with the
is_complete_response
content when the shell reply is received and validated.
method requestKernelInfo
requestKernelInfo: () => Promise<KernelMessage.IInfoReplyMsg | undefined>;
Send a
kernel_info_request
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
Fulfills with the
kernel_info_response
content when the shell reply is received and validated.
method restart
restart: () => Promise<void>;
Request a kernel restart.
#### Notes 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#!/kernels) and validates the response model.
Any existing Future or Comm objects are cleared once the kernel has actually be restarted.
The promise is fulfilled on a valid server response (after the kernel restarts) and rejected otherwise.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the request fails or the response is invalid.
method sendControlMessage
sendControlMessage: <T extends KernelMessage.ControlMessageType>( msg: KernelMessage.IControlMessage<T>, expectReply?: boolean, disposeOnDone?: boolean) => Kernel.IControlFuture<KernelMessage.IControlMessage<T>>;
Send a control message to the kernel.
#### Notes Send a message to the kernel's control channel, yielding a future object for accepting replies.
If
expectReply
is given andtrue
, the future is disposed when both a control reply and an idle status message are received. IfexpectReply
is not given or isfalse
, the future is resolved when an idle status message is received. IfdisposeOnDone
is not given or istrue
, the Future is disposed at this point. IfdisposeOnDone
is given andfalse
, it is up to the caller to dispose of the Future.All replies are validated as valid kernel messages.
If the kernel status is
dead
, this will throw an error.
method sendInputReply
sendInputReply: ( content: KernelMessage.IInputReplyMsg['content'], parent_header: KernelMessage.IInputReplyMsg['parent_header']) => void;
Send an
input_reply
message.#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
method sendShellMessage
sendShellMessage: <T extends KernelMessage.ShellMessageType>( msg: KernelMessage.IShellMessage<T>, expectReply?: boolean, disposeOnDone?: boolean) => Kernel.IShellFuture<KernelMessage.IShellMessage<T>>;
Send a shell message to the kernel.
#### Notes Send a message to the kernel's shell channel, yielding a future object for accepting replies.
If
expectReply
is given andtrue
, the future is disposed when both a shell reply and an idle status message are received. IfexpectReply
is not given or isfalse
, the future is resolved when an idle status message is received. IfdisposeOnDone
is not given or istrue
, the Future is disposed at this point. IfdisposeOnDone
is given andfalse
, it is up to the caller to dispose of the Future.All replies are validated as valid kernel messages.
If the kernel status is
dead
, this will throw an error.
method shutdown
shutdown: () => Promise<void>;
Shutdown a kernel.
#### Notes 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#!/kernels).
The promise is fulfilled on a valid response and rejected otherwise.
On a valid response, disposes this kernel connection.
If the kernel is already
dead
, disposes this kernel connection without a server request.
class KernelManager
class KernelManager extends BaseManager implements Kernel.IManager {}
An implementation of a kernel manager.
constructor
constructor(options?: KernelManager.IOptions);
Construct a new kernel manager.
Parameter options
The default options for kernel.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property runningChanged
readonly runningChanged: ISignal<this, Kernel.IModel[]>;
A signal emitted when the running kernels change.
property runningCount
readonly runningCount: number;
The number of running kernels.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the manager.
method connectTo
connectTo: ( options: Omit<Kernel.IKernelConnection.IOptions, 'serverSettings'>) => Kernel.IKernelConnection;
Connect to an existing kernel.
Returns
The new kernel connection.
#### Notes This will use the manager's server settings and ignore any server settings passed in the options.
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
method findById
findById: (id: string) => Promise<Kernel.IModel | undefined>;
Find a kernel by id.
Parameter id
The id of the target kernel.
Returns
A promise that resolves with the kernel's model.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running kernels.
Returns
A promise that resolves when the running list has been refreshed.
#### Notes This is not typically meant to be called by the user, since the manager maintains its own internal state.
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running kernels and update state.
method running
running: () => IterableIterator<Kernel.IModel>;
Create an iterator over the most recent running kernels.
Returns
A new iterator over the running kernels.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a kernel by id.
Parameter id
The id of the target kernel.
Returns
A promise that resolves when the operation is complete.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all kernels.
Returns
A promise that resolves when all of the kernels are shut down.
method startNew
startNew: ( createOptions?: IKernelOptions, connectOptions?: Omit< Kernel.IKernelConnection.IOptions, 'model' | 'serverSettings' >) => Promise<Kernel.IKernelConnection>;
Start a new kernel.
Parameter createOptions
The kernel creation options
Parameter connectOptions
The kernel connection options
Returns
A promise that resolves with the kernel connection.
#### Notes The manager
serverSettings
will be always be used.
class KernelSpecManager
class KernelSpecManager extends BaseManager implements KernelSpec.IManager {}
An implementation of a kernel spec manager.
constructor
constructor(options?: KernelSpecManager.IOptions);
Construct a new kernel spec manager.
Parameter options
The default options for kernel.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the manager.
property specs
readonly specs: KernelSpec.ISpecModels;
Get the most recently fetched kernel specs.
property specsChanged
readonly specsChanged: ISignal<this, KernelSpec.ISpecModels>;
A signal emitted when the specs change.
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
method refreshSpecs
refreshSpecs: () => Promise<void>;
Force a refresh of the specs from the server.
Returns
A promise that resolves when the specs are fetched.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
method requestSpecs
protected requestSpecs: () => Promise<void>;
Execute a request to the server to poll specs and update state.
class NbConvertManager
class NbConvertManager {}
The nbconvert API service manager.
constructor
constructor(options?: NbConvertManager.IOptions);
Create a new nbconvert manager.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings used to make API requests.
method fetchExportFormats
protected fetchExportFormats: () => Promise<NbConvertManager.IExportFormats>;
Fetch and cache the export formats from the expensive nbconvert handler.
method getExportFormats
getExportFormats: (force?: boolean) => Promise<NbConvertManager.IExportFormats>;
Get the list of export formats, preferring pre-cached ones.
class ServiceManager
class ServiceManager implements ServiceManager.IManager {}
A Jupyter services manager.
constructor
constructor(options?: Partial<ServiceManager.IOptions>);
Construct a new services provider.
property builder
readonly builder: Builder.IManager;
The builder for the manager.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure with the kernel.
property contents
readonly contents: Contents.IManager;
Get the contents manager instance.
property events
readonly events: Event.IManager;
The event manager instance.
property isDisposed
readonly isDisposed: boolean;
Test whether the service manager is disposed.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property kernels
readonly kernels: Kernel.IManager;
Get the kernel manager instance.
property kernelspecs
readonly kernelspecs: KernelSpec.IManager;
Get the kernelspec manager instance.
property nbconvert
readonly nbconvert: NbConvert.IManager;
Get the nbconvert manager instance.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the manager.
property sessions
readonly sessions: Session.IManager;
Get the session manager instance.
property settings
readonly settings: Setting.IManager;
Get the setting manager instance.
property terminals
readonly terminals: Terminal.IManager;
Get the terminal manager instance.
property user
readonly user: User.IManager;
Get the user manager instance.
property workspaces
readonly workspaces: Workspace.IManager;
Get the workspace manager instance.
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
class SessionManager
class SessionManager extends BaseManager implements Session.IManager {}
An implementation of a session manager.
constructor
constructor(options: SessionManager.IOptions);
Construct a new session manager.
Parameter options
The default options for each session.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property runningChanged
readonly runningChanged: ISignal<this, Session.IModel[]>;
A signal emitted when the running sessions change.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the manager.
method connectTo
connectTo: ( options: Omit< Session.ISessionConnection.IOptions, 'connectToKernel' | 'serverSettings' >) => Session.ISessionConnection;
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
method findById
findById: (id: string) => Promise<Session.IModel | undefined>;
Find a session by id.
method findByPath
findByPath: (path: string) => Promise<Session.IModel | undefined>;
Find a session by path.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running sessions.
Returns
A promise that with the list of running sessions.
#### Notes This is not typically meant to be called by the user, since the manager maintains its own internal state.
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running kernels and update state.
method running
running: () => IterableIterator<Session.IModel>;
Create an iterator over the most recent running sessions.
Returns
A new iterator over the running sessions.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a session by id.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all sessions.
Returns
A promise that resolves when all of the kernels are shut down.
method startNew
startNew: ( createOptions: Session.ISessionOptions, connectOptions?: Omit< Session.ISessionConnection.IOptions, 'model' | 'connectToKernel' | 'serverSettings' >) => Promise<Session.ISessionConnection>;
Start a new session. See also [[startNewSession]].
Parameter createOptions
Options for creating the session
Parameter connectOptions
Options for connecting to the session
method stopIfNeeded
stopIfNeeded: (path: string) => Promise<void>;
Find a session associated with a path and stop it if it is the only session using that kernel.
Parameter path
The path in question.
Returns
A promise that resolves when the relevant sessions are stopped.
class SettingManager
class SettingManager extends DataConnector<ISettingRegistry.IPlugin, string> {}
The settings API service manager.
constructor
constructor(options?: SettingManager.IOptions);
Create a new setting manager.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings used to make API requests.
method fetch
fetch: (id: string) => Promise<ISettingRegistry.IPlugin>;
Fetch a plugin's settings.
Parameter id
The plugin's ID.
Returns
A promise that resolves if successful.
method list
list: ( query?: 'ids') => Promise<{ ids: string[]; values: ISettingRegistry.IPlugin[] }>;
Fetch the list of all plugin setting bundles.
Returns
A promise that resolves if successful.
method save
save: (id: string, raw: string) => Promise<void>;
Save a plugin's settings.
Parameter id
The plugin's ID.
Parameter raw
The user setting values as a raw string of JSON with comments.
Returns
A promise that resolves if successful.
class TerminalManager
class TerminalManager extends BaseManager implements Terminal.IManager {}
A terminal session manager.
constructor
constructor(options?: TerminalManager.IOptions);
Construct a new terminal manager.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property runningChanged
readonly runningChanged: ISignal<this, Terminal.IModel[]>;
A signal emitted when the running terminals change.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the manager.
method connectTo
connectTo: ( options: Omit<Terminal.ITerminalConnection.IOptions, 'serverSettings'>) => Terminal.ITerminalConnection;
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
method isAvailable
isAvailable: () => boolean;
Whether the terminal service is available.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running terminals.
Returns
A promise that with the list of running terminals.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running terminals and update state.
method running
running: () => IterableIterator<Terminal.IModel>;
Create an iterator over the most recent running terminals.
Returns
A new iterator over the running terminals.
method shutdown
shutdown: (name: string) => Promise<void>;
Shut down a terminal session by name.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all terminal sessions.
Returns
A promise that resolves when all of the sessions are shut down.
method startNew
startNew: ( options?: Terminal.ITerminal.IOptions) => Promise<Terminal.ITerminalConnection>;
Create a new terminal session.
Parameter options
The options used to create the terminal.
Returns
A promise that resolves with the terminal connection instance.
#### Notes The manager
serverSettings
will be used unless overridden in the options.
class UserManager
class UserManager extends BaseManager implements User.IManager {}
The user API service manager.
constructor
constructor(options?: UserManager.IOptions);
Create a new user manager.
property connectionFailure
readonly connectionFailure: ISignal<this, Error>;
A signal emitted when there is a connection failure.
property identity
readonly identity: User.IIdentity;
Get the most recently fetched identity.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property permissions
readonly permissions: any;
Get the most recently fetched permissions.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the manager.
property userChanged
readonly userChanged: ISignal<this, User.IUser>;
A signal emitted when the user changes.
method dispose
dispose: () => void;
Dispose of the resources used by the manager.
method refreshUser
refreshUser: () => Promise<void>;
Force a refresh of the specs from the server.
Returns
A promise that resolves when the specs are fetched.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
method requestUser
protected requestUser: () => Promise<void>;
Execute a request to the server to poll the user and update state.
class WorkspaceManager
class WorkspaceManager extends DataConnector<Workspace.IWorkspace> {}
The workspaces API service manager.
constructor
constructor(options?: WorkspaceManager.IOptions);
Create a new workspace manager.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings used to make API requests.
method fetch
fetch: (id: string) => Promise<Workspace.IWorkspace>;
Fetch a workspace.
Parameter id
The workspace's ID.
Returns
A promise that resolves if successful.
method list
list: () => Promise<{ ids: string[]; values: Workspace.IWorkspace[] }>;
Fetch the list of workspace IDs that exist on the server.
Returns
A promise that resolves if successful.
method remove
remove: (id: string) => Promise<void>;
Remove a workspace from the server.
Parameter id
The workspaces's ID.
Returns
A promise that resolves if successful.
method save
save: (id: string, workspace: Workspace.IWorkspace) => Promise<void>;
Save a workspace.
Parameter id
The workspace's ID.
Parameter workspace
The workspace being saved.
Returns
A promise that resolves if successful.
Interfaces
interface IConfigSection
interface IConfigSection {}
A Configurable data section.
property data
readonly data: JSONObject;
The data for this section.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the section.
method update
update: (newdata: JSONObject) => Promise<JSONObject>;
Modify the stored config values.
#### Notes Updates the local data immediately, sends the change to the server, and updates the local data with the response, and fulfils the promise with that data.
interface IManager
interface IManager extends IObservableDisposable {}
Object which manages kernel instances for a given base url.
#### Notes The manager is responsible for maintaining the state of kernel specs.
property connectionFailure
connectionFailure: ISignal<IManager, ServerConnection.NetworkError>;
A signal emitted when there is a connection failure.
property isActive
readonly isActive: boolean;
Whether the manager is active.
property isReady
readonly isReady: boolean;
Whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that resolves when the manager is initially ready.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the manager.
Namespaces
namespace BaseManager
namespace BaseManager {}
The namespace for
BaseManager
class statics.
interface IOptions
interface IOptions {}
The options used to initialize a SessionManager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings for the manager.
namespace Builder
namespace Builder {}
A namespace for builder API interfaces.
interface IManager
interface IManager extends BuildManager {}
The interface for the build manager.
namespace ConfigSection
namespace ConfigSection {}
The namespace for ConfigSection statics.
function create
create: (options: ConfigSection.IOptions) => Promise<IConfigSection>;
Create a config section.
Returns
A Promise that is fulfilled with the config section is loaded.
interface IOptions
interface IOptions {}
The options used to create a config section.
property name
name: string;
The section name.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The optional server settings.
namespace ConfigWithDefaults
namespace ConfigWithDefaults {}
A namespace for ConfigWithDefaults statics.
namespace Contents
namespace Contents {}
A namespace for contents interfaces.
function validateCheckpointModel
validateCheckpointModel: (checkpoint: ICheckpointModel) => void;
Validates an ICheckpointModel, throwing an error if it does not pass.
function validateContentsModel
validateContentsModel: (contents: IModel) => void;
Validates an IModel, throwing an error if it does not pass.
interface IChangedArgs
interface IChangedArgs {}
The change args for a file change.
interface ICheckpointModel
interface ICheckpointModel {}
Checkpoint model.
property id
readonly id: string;
The unique identifier for the checkpoint.
property last_modified
readonly last_modified: string;
Last modified timestamp.
interface ICreateOptions
interface ICreateOptions {}
The options used to create a file.
interface IDrive
interface IDrive extends IDisposable {}
The interface for a network drive that can be mounted in the contents manager.
property fileChanged
fileChanged: ISignal<IDrive, IChangedArgs>;
A signal emitted when a file operation takes place.
property name
readonly name: string;
The name of the drive, which is used at the leading component of file paths.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the manager.
property sharedModelFactory
readonly sharedModelFactory?: ISharedFactory;
An optional shared model factory instance for the drive.
method copy
copy: (localPath: string, toLocalDir: string) => Promise<IModel>;
Copy a file into a given directory.
Parameter localPath
The original file path.
Parameter toLocalDir
The destination directory path.
Returns
A promise which resolves with the new content model when the file is copied.
method createCheckpoint
createCheckpoint: (localPath: string) => Promise<ICheckpointModel>;
Create a checkpoint for a file.
Parameter localPath
The path of the file.
Returns
A promise which resolves with the new checkpoint model when the checkpoint is created.
method delete
delete: (localPath: string) => Promise<void>;
Delete a file.
Parameter localPath
The path to the file.
Returns
A promise which resolves when the file is deleted.
method deleteCheckpoint
deleteCheckpoint: (localPath: string, checkpointID: string) => Promise<void>;
Delete a checkpoint for a file.
Parameter localPath
The path of the file.
Parameter checkpointID
The id of the checkpoint to delete.
Returns
A promise which resolves when the checkpoint is deleted.
method get
get: (localPath: string, options?: IFetchOptions) => Promise<IModel>;
Get a file or directory.
Parameter localPath
The path to the file.
Parameter options
The options used to fetch the file.
Returns
A promise which resolves with the file content.
method getDownloadUrl
getDownloadUrl: (localPath: string) => Promise<string>;
Get an encoded download url given a file path.
Returns
A promise which resolves with the absolute POSIX file path on the server.
#### Notes The returned URL may include a query parameter.
method listCheckpoints
listCheckpoints: (localPath: string) => Promise<ICheckpointModel[]>;
List available checkpoints for a file.
Parameter localPath
The path of the file.
Returns
A promise which resolves with a list of checkpoint models for the file.
method newUntitled
newUntitled: (options?: ICreateOptions) => Promise<IModel>;
Create a new untitled file or directory in the specified directory path.
Parameter options
The options used to create the file.
Returns
A promise which resolves with the created file content when the file is created.
method rename
rename: (oldLocalPath: string, newLocalPath: string) => Promise<IModel>;
Rename a file or directory.
Parameter oldLocalPath
The original file path.
Parameter newLocalPath
The new file path.
Returns
A promise which resolves with the new file content model when the file is renamed.
method restoreCheckpoint
restoreCheckpoint: (localPath: string, checkpointID: string) => Promise<void>;
Restore a file to a known checkpoint state.
Parameter localPath
The path of the file.
Parameter checkpointID
The id of the checkpoint to restore.
Returns
A promise which resolves when the checkpoint is restored.
method save
save: (localPath: string, options?: Partial<IModel>) => Promise<IModel>;
Save a file.
Parameter localPath
The desired file path.
Parameter options
Optional overrides to the model.
Returns
A promise which resolves with the file content model when the file is saved.
interface IFetchOptions
interface IFetchOptions {}
The options used to fetch a file.
property content
content?: boolean;
Whether to include the file content.
The default is
true
.
property format
format?: FileFormat;
The override file format for the request.
property hash
hash?: boolean;
Whether to include a hash in the response.
The default is
false
.
property type
type?: ContentType;
The override file type for the request.
interface IManager
interface IManager extends IDisposable {}
The interface for a contents manager.
property fileChanged
readonly fileChanged: ISignal<IManager, IChangedArgs>;
A signal emitted when a file operation takes place.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings associated with the manager.
method addDrive
addDrive: (drive: IDrive) => void;
Add an
IDrive
to the manager.
method copy
copy: (path: string, toDir: string) => Promise<IModel>;
Copy a file into a given directory.
Parameter path
The original file path.
Parameter toDir
The destination directory path.
Returns
A promise which resolves with the new content model when the file is copied.
method createCheckpoint
createCheckpoint: (path: string) => Promise<ICheckpointModel>;
Create a checkpoint for a file.
Parameter path
The path of the file.
Returns
A promise which resolves with the new checkpoint model when the checkpoint is created.
method delete
delete: (path: string) => Promise<void>;
Delete a file.
Parameter path
The path to the file.
Returns
A promise which resolves when the file is deleted.
method deleteCheckpoint
deleteCheckpoint: (path: string, checkpointID: string) => Promise<void>;
Delete a checkpoint for a file.
Parameter path
The path of the file.
Parameter checkpointID
The id of the checkpoint to delete.
Returns
A promise which resolves when the checkpoint is deleted.
method driveName
driveName: (path: string) => string;
Given a path of the form
drive:local/portion/of/it.txt
get the name of the drive. If the path is missing a drive portion, returns an empty string.Parameter path
the path.
Returns
The drive name for the path, or the empty string.
method get
get: (path: string, options?: IFetchOptions) => Promise<IModel>;
Get a file or directory.
Parameter path
The path to the file.
Parameter options
The options used to fetch the file.
Returns
A promise which resolves with the file content.
method getDownloadUrl
getDownloadUrl: (path: string) => Promise<string>;
Get an encoded download url given a file path.
Parameter A
promise which resolves with the absolute POSIX file path on the server.
#### Notes The returned URL may include a query parameter.
method getSharedModelFactory
getSharedModelFactory: (path: string) => ISharedFactory | null;
Given a path, get a shared model IFactory from the relevant backend. Returns
null
if the backend does not provide one.
method listCheckpoints
listCheckpoints: (path: string) => Promise<ICheckpointModel[]>;
List available checkpoints for a file.
Parameter path
The path of the file.
Returns
A promise which resolves with a list of checkpoint models for the file.
method localPath
localPath: (path: string) => string;
Given a path of the form
drive:local/portion/of/it.txt
get the local part of it.Parameter path
the path.
Returns
The local part of the path.
method newUntitled
newUntitled: (options?: ICreateOptions) => Promise<IModel>;
Create a new untitled file or directory in the specified directory path.
Parameter options
The options used to create the file.
Returns
A promise which resolves with the created file content when the file is created.
method normalize
normalize: (path: string) => string;
Normalize a global path. Reduces '..' and '.' parts, and removes leading slashes from the local part of the path, while retaining the drive name if it exists.
Parameter path
the path.
Returns
The normalized path.
method rename
rename: (path: string, newPath: string) => Promise<IModel>;
Rename a file or directory.
Parameter path
The original file path.
Parameter newPath
The new file path.
Returns
A promise which resolves with the new file content model when the file is renamed.
method resolvePath
resolvePath: (root: string, path: string) => string;
Resolve a global path, starting from the root path. Behaves like posix-path.resolve, with 3 differences: - will never prepend cwd - if root has a drive name, the result is prefixed with ":" - before adding drive name, leading slashes are removed
Parameter path
the path.
Returns
The normalized path.
method restoreCheckpoint
restoreCheckpoint: (path: string, checkpointID: string) => Promise<void>;
Restore a file to a known checkpoint state.
Parameter path
The path of the file.
Parameter checkpointID
The id of the checkpoint to restore.
Returns
A promise which resolves when the checkpoint is restored.
method save
save: (path: string, options?: Partial<IModel>) => Promise<IModel>;
Save a file.
Parameter path
The desired file path.
Parameter options
Optional overrides to the model.
Returns
A promise which resolves with the file content model when the file is saved.
interface IModel
interface IModel {}
A contents model.
property chunk
readonly chunk?: number;
The chunk of the file upload.
property content
readonly content: any;
The optional file content.
property created
readonly created: string;
File creation timestamp.
property format
readonly format: FileFormat;
The format of the file
content
.#### Notes Only relevant for type: 'file'
property hash
readonly hash?: string;
The hexdigest hash string of content, if requested (otherwise null). It cannot be null if hash_algorithm is defined.
property hash_algorithm
readonly hash_algorithm?: string;
The algorithm used to compute hash value. It cannot be null if hash is defined.
property indices
indices?: ReadonlyArray<number> | null;
The indices of the matched characters in the name.
property last_modified
readonly last_modified: string;
Last modified timestamp.
property mimetype
readonly mimetype: string;
Specify the mime-type of file contents.
#### Notes Only non-
null
whencontent
is present andtype
is"file"
.
property name
readonly name: string;
Name of the contents file.
#### Notes Equivalent to the last part of the
path
field.
property path
readonly path: string;
The full file path.
#### Notes It will *not* start with
/
, and it will be/
-delimited.
property serverPath
readonly serverPath?: string;
The path as returned by the server contents API.
#### Notes Differently to
path
it does not include IDrive API prefix.
property size
readonly size?: number;
The size of then file in bytes.
property type
readonly type: ContentType;
The type of file.
property writable
readonly writable: boolean;
Whether the requester has permission to edit the file.
interface ISharedFactory
interface ISharedFactory {}
A factory interface for creating
ISharedDocument
objects.
property collaborative
readonly collaborative?: boolean;
Whether the IDrive supports real-time collaboration or not. Note: If it is not provided, it is false by default.
method createNew
createNew: (options: ISharedFactoryOptions) => ISharedDocument | undefined;
Create a new
ISharedDocument
instance.It should return
undefined
if the factory is not able to create aISharedDocument
.
interface ISharedFactoryOptions
interface ISharedFactoryOptions {}
The options used to instantiate a ISharedDocument
property collaborative
collaborative?: boolean;
Whether the document is collaborative or not.
The default value is
true
.
property contentType
contentType: ContentType;
The content type of the document.
property format
format: FileFormat;
The format of the document. If null, the document won't be collaborative.
property path
path: string;
The path of the file.
type ContentType
type ContentType = string;
A contents file type. It can be anything but
jupyter-server
has special treatment fornotebook
anddirectory
types. Anything else is considered asfile
type.
type FileFormat
type FileFormat = 'json' | 'text' | 'base64' | null;
A contents file format. Always
json
fornotebook
anddirectory
types. It should be set to eithertext
orbase64
forfile
type. See the [jupyter server data model for filesystem entities](https://jupyter-server.readthedocs.io/en/latest/developers/contents.html#filesystem-entities) for more details.
namespace ContentsManager
namespace ContentsManager {}
A namespace for ContentsManager statics.
interface IOptions
interface IOptions {}
The options used to initialize a contents manager.
property defaultDrive
defaultDrive?: Contents.IDrive;
The default drive backend for the contents manager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings associated with the manager.
namespace Drive
namespace Drive {}
A namespace for Drive statics.
interface IOptions
interface IOptions {}
The options used to initialize a
Drive
.
property apiEndpoint
apiEndpoint?: string;
A REST endpoint for drive requests. If not given, defaults to the Jupyter REST API given by [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents).
property name
name?: string;
The name for the
Drive
, which is used in file paths to disambiguate it from other drives.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings for the server.
namespace Event
namespace Event {}
A namespace for event API interfaces.
interface IManager
interface IManager extends IDisposable {}
The interface for the event bus front-end.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings used to make API requests.
property stream
readonly stream: Event.Stream;
An event stream that emits and yields each new event.
method emit
emit: (event: Event.Request) => Promise<void>;
Post an event request to be emitted by the event bus.
type Emission
type Emission = ReadonlyJSONObject & { schema_id: string;};
The event emission type.
type Request
type Request = { data: JSONObject; schema_id: string; version: string;};
The event request type.
type Stream
type Stream = IStream<IManager, Emission>;
An event stream with the characteristics of a signal and an async iterator.
namespace EventManager
namespace EventManager {}
A namespace for
EventManager
statics.
interface IOptions
interface IOptions {}
The instantiation options for an event manager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings used to make API requests.
namespace Kernel
module 'lib/kernel/kernel.d.ts' {}
Interface of a Kernel connection that is managed by a session.
#### Notes The Kernel object is tied to the lifetime of the Kernel id, which is a unique id for the Kernel session on the server. The Kernel object manages a websocket connection internally, and will auto-restart if the websocket temporarily loses connection. Restarting creates a new Kernel process on the server, but preserves the Kernel id.
The IKernelConnection is notably missing the full IKernel signals. This interface is for situations where a kernel may change, but we want a user to not have to worry about disconnecting and reconnecting signals when a kernel is swapped. The object that maintains an IKernel, but only provides a user with an IKernelConnection should proxy the appropriate IKernel signals for the user with its own signals. The advantage is that when the kernel is changed, the object itself can take care of disconnecting and reconnecting listeners.
interface IAnyMessageArgs
interface IAnyMessageArgs {}
Arguments interface for the anyMessage signal.
interface IComm
interface IComm extends IDisposable {}
A client side Comm interface.
property commId
readonly commId: string;
The unique id for the comm channel.
property onClose
onClose: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>;
Callback for a comm close event.
#### Notes This is called when the comm is closed from either the server or client. If this is called in response to a kernel message and the handler returns a promise, all kernel message processing pauses until the promise is resolved.
property onMsg
onMsg: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>;
Callback for a comm message received event.
#### Notes If the handler returns a promise, all kernel message processing pauses until the promise is resolved.
property targetName
readonly targetName: string;
The target name for the comm channel.
method close
close: ( data?: JSONValue, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[]) => IShellFuture;
Close the comm.
Parameter data
The data to send to the server on opening.
Parameter metadata
Additional metadata for the message.
Returns
A future for the generated message.
#### Notes This will send a
comm_close
message to the kernel, and call theonClose
callback if set.This is a no-op if the comm is already closed.
method open
open: ( data?: JSONValue, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[]) => IShellFuture;
Open a comm with optional data and metadata.
Parameter data
The data to send to the server on opening.
Parameter metadata
Additional metadata for the message.
Returns
A future for the generated message.
#### Notes This sends a
comm_open
message to the server.
method send
send: ( data: JSONValue, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[], disposeOnDone?: boolean) => IShellFuture;
Send a
comm_msg
message to the kernel.Parameter data
The data to send to the server on opening.
Parameter metadata
Additional metadata for the message.
Parameter buffers
Optional buffer data.
Parameter disposeOnDone
Whether to dispose of the future when done.
Returns
A future for the generated message.
#### Notes This is a no-op if the comm has been closed.
interface IControlFuture
interface IControlFuture< REQUEST extends KernelMessage.IControlMessage = KernelMessage.IControlMessage, REPLY extends KernelMessage.IControlMessage = KernelMessage.IControlMessage> extends IFuture<REQUEST, REPLY> {}
interface IFuture
interface IFuture< REQUEST extends KernelMessage.IShellControlMessage, REPLY extends KernelMessage.IShellControlMessage> extends IDisposable {}
A Future interface for responses from the kernel.
When a message is sent to a kernel, a Future is created to handle any responses that may come from the kernel.
property done
readonly done: Promise<REPLY>;
A promise that resolves when the future is done.
#### Notes The future is done when there are no more responses expected from the kernel.
The
done
promise resolves to the reply message.
property msg
readonly msg: REQUEST;
The original outgoing message.
property onIOPub
onIOPub: (msg: KernelMessage.IIOPubMessage) => void | PromiseLike<void>;
The iopub handler for the kernel future.
#### Notes If the handler returns a promise, all kernel message processing pauses until the promise is resolved.
property onReply
onReply: (msg: REPLY) => void | PromiseLike<void>;
The reply handler for the kernel future.
#### Notes If the handler returns a promise, all kernel message processing pauses until the promise is resolved. If there is a reply message, the future
done
promise also resolves to the reply message after this handler has been called.
property onStdin
onStdin: (msg: KernelMessage.IStdinMessage) => void | PromiseLike<void>;
The stdin handler for the kernel future.
#### Notes If the handler returns a promise, all kernel message processing pauses until the promise is resolved.
method registerMessageHook
registerMessageHook: ( hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Register hook for IOPub messages.
Parameter hook
The callback invoked for an IOPub message.
#### Notes The IOPub hook system allows you to preempt the handlers for IOPub messages handled by the future.
The most recently registered hook is run first. A hook can return a boolean or a promise to a boolean, in which case all kernel message processing pauses until the promise is fulfilled. If a hook return value resolves to false, any later hooks will not run and the function will return a promise resolving to false. If a hook throws an error, the error is logged to the console and the next hook is run. If a hook is registered during the hook processing, it will not run until the next message. If a hook is removed during the hook processing, it will be deactivated immediately.
method removeMessageHook
removeMessageHook: ( hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Remove a hook for IOPub messages.
Parameter hook
The hook to remove.
#### Notes If a hook is removed during the hook processing, it will be deactivated immediately.
method sendInputReply
sendInputReply: ( content: KernelMessage.IInputReplyMsg['content'], parent_header: KernelMessage.IInputReplyMsg['parent_header']) => void;
Send an
input_reply
message.
interface IKernelConnection
interface IKernelConnection extends IObservableDisposable {}
Interface of a Kernel connection that is managed by a session.
#### Notes The Kernel object is tied to the lifetime of the Kernel id, which is a unique id for the Kernel session on the server. The Kernel object manages a websocket connection internally, and will auto-restart if the websocket temporarily loses connection. Restarting creates a new Kernel process on the server, but preserves the Kernel id.
The IKernelConnection is notably missing the full IKernel signals. This interface is for situations where a kernel may change, but we want a user to not have to worry about disconnecting and reconnecting signals when a kernel is swapped. The object that maintains an IKernel, but only provides a user with an IKernelConnection should proxy the appropriate IKernel signals for the user with its own signals. The advantage is that when the kernel is changed, the object itself can take care of disconnecting and reconnecting listeners.
property anyMessage
anyMessage: ISignal<this, IAnyMessageArgs>;
A signal emitted when any kernel message is sent or received.
#### Notes This signal is emitted before any message handling has happened. The message should be treated as read-only.
property clientId
readonly clientId: string;
The client unique id.
#### Notes This should be unique for a particular kernel connection object.
property connectionStatus
readonly connectionStatus: ConnectionStatus;
The current connection status of the kernel.
property connectionStatusChanged
connectionStatusChanged: ISignal<this, ConnectionStatus>;
A signal emitted when the kernel connection status changes.
property handleComms
handleComms: boolean;
Whether the kernel connection handles comm messages.
#### Notes The comm message protocol currently has implicit assumptions that only one kernel connection is handling comm messages. This option allows a kernel connection to opt out of handling comms.
See https://github.com/jupyter/jupyter_client/issues/263
property hasPendingInput
hasPendingInput: boolean;
Whether the kernel connection has pending input.
#### Notes This is a guard to avoid deadlock is the user asks input as second time before submitting his first input
property id
readonly id: string;
The id of the server-side kernel.
property info
readonly info: Promise<KernelMessage.IInfoReply>;
The kernel info
#### Notes This promise only resolves at startup, and is not refreshed on every restart.
property iopubMessage
iopubMessage: ISignal<this, KernelMessage.IIOPubMessage>;
A signal emitted after an iopub kernel message is handled.
property model
readonly model: IModel;
The kernel model, for convenience.
property name
readonly name: string;
The name of the server-side kernel.
property pendingInput
pendingInput: ISignal<this, boolean>;
A signal emitted when a kernel has pending inputs from the user.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the kernel.
property spec
readonly spec: Promise<KernelSpec.ISpecModel | undefined>;
Get the kernel spec.
Returns
A promise that resolves with the kernel spec for this kernel.
#### Notes This may make a server request to retrieve the spec.
property status
readonly status: KernelMessage.Status;
The current status of the kernel.
property statusChanged
statusChanged: ISignal<this, KernelMessage.Status>;
A signal emitted when the kernel status changes.
property unhandledMessage
unhandledMessage: ISignal<this, KernelMessage.IMessage>;
A signal emitted for unhandled non-iopub kernel messages that claimed to be responses for messages we sent using this kernel object.
property username
readonly username: string;
The client username.
method clone
clone: ( options?: Pick< IKernelConnection.IOptions, 'clientId' | 'username' | 'handleComms' >) => IKernelConnection;
Clone the current kernel with a new clientId.
method createComm
createComm: (targetName: string, commId?: string) => IComm;
Create a new comm.
Parameter targetName
The name of the comm target.
Parameter id
The comm id.
Returns
A comm instance.
method hasComm
hasComm: (commId: string) => boolean;
Check if a comm exists.
method interrupt
interrupt: () => Promise<void>;
Interrupt a kernel.
Returns
A promise that resolves when the kernel has interrupted.
#### Notes 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#!/kernels).
The promise is fulfilled on a valid response and rejected otherwise.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the kernel status is
'dead'
or if the request fails or the response is invalid.
method reconnect
reconnect: () => Promise<void>;
Reconnect to a disconnected kernel.
Returns
A promise that resolves when the kernel has reconnected.
#### Notes This just refreshes the connection to an existing kernel, and does not perform an HTTP request to the server or restart the kernel.
method registerCommTarget
registerCommTarget: ( targetName: string, callback: ( comm: IComm, msg: KernelMessage.ICommOpenMsg ) => void | PromiseLike<void>) => void;
Register a comm target handler.
Parameter targetName
The name of the comm target.
Parameter callback
The callback invoked for a comm open message.
#### Notes Only one comm target can be registered to a target name at a time, an existing callback for the same target name will be overridden. A registered comm target handler will take precedence over a comm which specifies a
target_module
.If the callback returns a promise, kernel message processing will pause until the returned promise is fulfilled.
method registerMessageHook
registerMessageHook: ( msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Register an IOPub message hook.
Parameter msg_id
The parent_header message id in messages the hook should intercept.
Parameter hook
The callback invoked for the message.
#### Notes The IOPub hook system allows you to preempt the handlers for IOPub messages with a given parent_header message id. The most recently registered hook is run first. If a hook return value resolves to false, any later hooks and the future's onIOPub handler will not run. If a hook throws an error, the error is logged to the console and the next hook is run. If a hook is registered during the hook processing, it will not run until the next message. If a hook is disposed during the hook processing, it will be deactivated immediately.
See also [[IFuture.registerMessageHook]].
method removeCommTarget
removeCommTarget: ( targetName: string, callback: ( comm: IComm, msg: KernelMessage.ICommOpenMsg ) => void | PromiseLike<void>) => void;
Remove a comm target handler.
Parameter targetName
The name of the comm target to remove.
Parameter callback
The callback to remove.
#### Notes The comm target is only removed if it matches the callback argument.
method removeInputGuard
removeInputGuard: () => void;
Remove the input guard, if any.
method removeMessageHook
removeMessageHook: ( msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>) => void;
Remove an IOPub message hook.
Parameter msg_id
The parent_header message id the hook intercepted.
Parameter hook
The callback invoked for the message.
method requestCommInfo
requestCommInfo: ( content: KernelMessage.ICommInfoRequestMsg['content']) => Promise<KernelMessage.ICommInfoReplyMsg>;
Send a
comm_info_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm_info).
Fulfills with the
comm_info_reply
content when the shell reply is received and validated.
method requestComplete
requestComplete: ( content: KernelMessage.ICompleteRequestMsg['content']) => Promise<KernelMessage.ICompleteReplyMsg>;
Send a
complete_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
Fulfills with the
complete_reply
content when the shell reply is received and validated.
method requestDebug
requestDebug: ( content: KernelMessage.IDebugRequestMsg['content'], disposeOnDone?: boolean) => IControlFuture< KernelMessage.IDebugRequestMsg, KernelMessage.IDebugReplyMsg>;
Send an experimental
debug_request
message.Parameter content
The content of the request.
Parameter disposeOnDone
Whether to dispose of the future when done.
Returns
A kernel future.
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this function is *NOT* considered part of the public API, and may change without notice.
method requestExecute
requestExecute: ( content: KernelMessage.IExecuteRequestMsg['content'], disposeOnDone?: boolean, metadata?: JSONObject) => IShellFuture< KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg>;
Send an
execute_request
message.Parameter content
The content of the request.
Parameter disposeOnDone
Whether to dispose of the future when done.
Returns
A kernel future.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute).
This method returns a kernel future, rather than a promise, since execution may have many response messages (for example, many iopub display messages).
Future
onReply
is called with theexecute_reply
content when the shell reply is received and validated.**See also:** [[IExecuteReply]]
method requestHistory
requestHistory: ( content: KernelMessage.IHistoryRequestMsg['content']) => Promise<KernelMessage.IHistoryReplyMsg>;
Send a
history_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
Fulfills with the
history_reply
content when the shell reply is received and validated.
method requestInspect
requestInspect: ( content: KernelMessage.IInspectRequestMsg['content']) => Promise<KernelMessage.IInspectReplyMsg>;
Send an
inspect_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
Fulfills with the
inspect_reply
content when the shell reply is received and validated.
method requestIsComplete
requestIsComplete: ( content: KernelMessage.IIsCompleteRequestMsg['content']) => Promise<KernelMessage.IIsCompleteReplyMsg>;
Send an
is_complete_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
Fulfills with the
is_complete_response
content when the shell reply is received and validated.
method requestKernelInfo
requestKernelInfo: () => Promise<KernelMessage.IInfoReplyMsg | undefined>;
Send a
kernel_info_request
message.Parameter content
The content of the request.
Returns
A promise that resolves with the response message.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
Fulfills with the
kernel_info_response
content when the shell reply is received and validated.
method restart
restart: () => Promise<void>;
Restart a kernel.
Returns
A promise that resolves when the kernel has restarted.
#### Notes 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#!/kernels) and validates the response model.
Any existing Future or Comm objects are cleared.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the kernel status is
'dead'
or if the request fails or the response is invalid.
method sendControlMessage
sendControlMessage: <T extends KernelMessage.ControlMessageType>( msg: KernelMessage.IControlMessage<T>, expectReply?: boolean, disposeOnDone?: boolean) => IControlFuture<KernelMessage.IControlMessage<T>>;
method sendInputReply
sendInputReply: ( content: KernelMessage.IInputReplyMsg['content'], parent_header: KernelMessage.IInputReplyMsg['parent_header']) => void;
Send an
input_reply
message.Parameter content
The content of the reply.
#### Notes See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
method sendShellMessage
sendShellMessage: <T extends KernelMessage.ShellMessageType>( msg: KernelMessage.IShellMessage<T>, expectReply?: boolean, disposeOnDone?: boolean) => IShellFuture<KernelMessage.IShellMessage<T>>;
Send a shell message to the kernel.
Parameter msg
The fully-formed shell message to send.
Parameter expectReply
Whether to expect a shell reply message.
Parameter disposeOnDone
Whether to dispose of the future when done.
#### Notes Send a message to the kernel's shell channel, yielding a future object for accepting replies.
If
expectReply
is given andtrue
, the future is done when both a shell reply and an idle status message are received with the appropriate parent header, in which case the.done
promise resolves to the reply. IfexpectReply
is not given or isfalse
, the future is done when an idle status message with the appropriate parent header is received, in which case the.done
promise resolves toundefined
.If
disposeOnDone
is given andfalse
, the future will not be disposed of when the future is done, instead relying on the caller to dispose of it. This allows for the handling of out-of-order output from ill-behaved kernels.All replies are validated as valid kernel messages.
If the kernel status is
'dead'
, this will throw an error.
method shutdown
shutdown: () => Promise<void>;
Shutdown a kernel.
Returns
A promise that resolves when the kernel has shut down.
#### Notes Uses the [Jupyter Notebook API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernels).
On a valid response, closes the websocket, disposes of the kernel object, and fulfills the promise.
The promise will be rejected if the kernel status is
'dead'
, the request fails, or the response is invalid.
interface IManager
interface IManager extends IBaseManager {}
Object which manages kernel instances for a given base url.
#### Notes The manager is responsible for maintaining the state of running kernels through polling the server. Use a manager if you want to be notified of changes to kernels.
property connectionFailure
connectionFailure: ISignal<IManager, ServerConnection.NetworkError>;
A signal emitted when there is a server API connection failure.
property isReady
readonly isReady: boolean;
Whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that resolves when the manager is initially ready.
property runningChanged
runningChanged: ISignal<IManager, IModel[]>;
A signal emitted when the running kernels change.
property runningCount
readonly runningCount: number;
The number of running kernels.
method connectTo
connectTo: (options: IKernelConnection.IOptions) => IKernelConnection;
Connect to an existing kernel.
Parameter model
The model of the target kernel.
Returns
A promise that resolves with the new kernel instance.
method findById
findById: (id: string) => Promise<IModel | undefined>;
Find a kernel by id.
Parameter id
The id of the target kernel.
Returns
A promise that resolves with the kernel's model, or undefined if not found.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running kernels.
Returns
A promise that resolves when the models are refreshed.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
method running
running: () => IterableIterator<IModel>;
Create an iterator over the known running kernels.
Returns
A new iterator over the running kernels.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a kernel by id.
Parameter id
The id of the target kernel.
Returns
A promise that resolves when the operation is complete.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all kernels.
Returns
A promise that resolves when all of the kernels are shut down.
method startNew
startNew: ( createOptions?: IKernelOptions, connectOptions?: Omit<IKernelConnection.IOptions, 'model' | 'serverSettings'>) => Promise<IKernelConnection>;
Start a new kernel.
Parameter createOptions
The kernel creation options
Parameter connectOptions
The kernel connection options
Returns
A promise that resolves with the kernel connection.
#### Notes The manager
serverSettings
will be always be used.
interface IModel
interface IModel {}
The kernel model provided by the server.
#### Notes See the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernels).
property connections
readonly connections?: number;
The number of active connections to the kernel.
property execution_state
readonly execution_state?: string;
The kernel execution state.
property id
readonly id: string;
Unique identifier of the kernel on the server.
property last_activity
readonly last_activity?: string;
The timestamp of the last activity on the kernel.
property name
readonly name: string;
The name of the kernel.
property reason
readonly reason?: string;
The reason the kernel died, if applicable.
property traceback
readonly traceback?: string;
The traceback for a dead kernel, if applicable.
interface IShellFuture
interface IShellFuture< REQUEST extends KernelMessage.IShellMessage = KernelMessage.IShellMessage, REPLY extends KernelMessage.IShellMessage = KernelMessage.IShellMessage> extends IFuture<REQUEST, REPLY> {}
type ConnectionStatus
type ConnectionStatus = 'connected' | 'connecting' | 'disconnected';
The valid kernel connection states.
#### Notes The status states are: *
connected
: The kernel connection is live. *connecting
: The kernel connection is not live, but we are attempting to reconnect to the kernel. *disconnected
: The kernel connection is permanently down, we will not try to reconnect.When a kernel connection is
connected
, the kernel status should be valid. When a kernel connection is eitherconnecting
ordisconnected
, the kernel status will beunknown
unless the kernel status wasdead
, in which case it staysdead
.
type IKernelOptions
type IKernelOptions = Partial<Pick<IModel, 'name'>>;
The options object used to initialize a kernel.
type Status
type Status = | 'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead';
The valid Kernel status states.
#### Notes The status states are: *
unknown
: The kernel status is unknown, often because the connection is disconnected or connecting. This state is determined by the kernel connection status. *autorestarting
: The kernel is restarting, initiated by the server. This state is set by the services library, not explicitly sent from the kernel. *starting
: The kernel is starting *idle
: The kernel has finished processing messages. *busy
: The kernel is currently processing messages. *restarting
: The kernel is restarting. This state is sent by the Jupyter server. *dead
: The kernel is dead and will not be restarted. This state is set by the Jupyter server and is a final state.
namespace Kernel.IKernelConnection
namespace Kernel.IKernelConnection {}
The namespace for
IKernelConnection
statics.
interface IOptions
interface IOptions {}
The options object used to initialize a kernel.
property clientId
clientId?: string;
The unique identifier for the kernel client.
property handleComms
handleComms?: boolean;
Whether the kernel connection should handle comm messages
#### Notes The comm message protocol currently has implicit assumptions that only one kernel connection is handling comm messages. This option allows a kernel connection to opt out of handling comms.
See https://github.com/jupyter/jupyter_client/issues/263
property model
model: IModel;
The kernel model.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings for the kernel.
property username
username?: string;
The username of the kernel client.
namespace KernelAPI
module 'lib/kernel/restapi.d.ts' {}
The kernel model provided by the server.
#### Notes See the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernels).
variable KERNEL_SERVICE_URL
const KERNEL_SERVICE_URL: string;
The url for the kernel service.
function getKernelModel
getKernelModel: ( id: string, settings?: ServerConnection.ISettings) => Promise<IModel | undefined>;
Get a full kernel model from the server by kernel id string.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response and rejected otherwise.
function interruptKernel
interruptKernel: ( id: string, settings?: ServerConnection.ISettings) => Promise<void>;
Interrupt a kernel.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response and rejected otherwise.
function listRunning
listRunning: (settings?: ServerConnection.ISettings) => Promise<IModel[]>;
Fetch the running kernels.
Parameter settings
The optional server settings.
Returns
A promise that resolves with the list of running kernels.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response and rejected otherwise.
function restartKernel
restartKernel: ( id: string, settings?: ServerConnection.ISettings) => Promise<void>;
Restart a kernel.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response (and thus after a restart) and rejected otherwise.
function shutdownKernel
shutdownKernel: ( id: string, settings?: ServerConnection.ISettings) => Promise<void>;
Shut down a kernel.
Parameter id
The id of the running kernel.
Parameter settings
The server settings for the request.
Returns
A promise that resolves when the kernel is shut down.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response and rejected otherwise.
function startNew
startNew: ( options?: IKernelOptions, settings?: ServerConnection.ISettings) => Promise<IModel>;
Start a new kernel.
Parameter options
The options used to create the kernel.
Returns
A promise that resolves with a kernel connection object.
#### Notes 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#!/kernels) and validates the response model.
The promise is fulfilled on a valid response and rejected otherwise.
interface IModel
interface IModel {}
The kernel model provided by the server.
#### Notes See the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernels).
property connections
readonly connections?: number;
The number of active connections to the kernel.
property execution_state
readonly execution_state?: string;
The kernel execution state.
property id
readonly id: string;
Unique identifier of the kernel on the server.
property last_activity
readonly last_activity?: string;
The timestamp of the last activity on the kernel.
property name
readonly name: string;
The name of the kernel.
property reason
readonly reason?: string;
The reason the kernel died, if applicable.
property traceback
readonly traceback?: string;
The traceback for a dead kernel, if applicable.
type IKernelOptions
type IKernelOptions = Partial<Pick<IModel, 'name'>>;
The options object used to initialize a kernel.
namespace KernelManager
namespace KernelManager {}
The namespace for
KernelManager
class statics.
class NoopManager
class NoopManager extends KernelManager {}
A no-op kernel manager to be used when starting kernels.
property isActive
readonly isActive: boolean;
Whether the manager is active.
property parentReady
readonly parentReady: Promise<void>;
Used for testing.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready (never).
method connectTo
connectTo: ( options: Omit<Kernel.IKernelConnection.IOptions, 'serverSettings'>) => Kernel.IKernelConnection;
Connect to an existing kernel - throws an error since it is not supported.
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running kernels and update state.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a kernel by id - throws an error since it is not supported.
method startNew
startNew: ( createOptions?: IKernelOptions, connectOptions?: Omit< Kernel.IKernelConnection.IOptions, 'model' | 'serverSettings' >) => Promise<Kernel.IKernelConnection>;
Start a new kernel - throws an error since it is not supported.
namespace KernelMessage
module 'lib/kernel/messages.d.ts' {}
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this function is *NOT* considered part of the public API, and may change without notice.
function createMessage
createMessage: { <T extends IClearOutputMsg>(options: IOptions<T>): T; <T extends ICommCloseMsg<'iopub'>>(options: IOptions<T>): T; <T extends ICommCloseMsg<'shell'>>(options: IOptions<T>): T; <T extends ICommInfoReplyMsg>(options: IOptions<T>): T; <T extends ICommInfoRequestMsg>(options: IOptions<T>): T; <T extends ICommMsgMsg<'iopub'>>(options: IOptions<T>): T; <T extends ICommMsgMsg<'shell'>>(options: IOptions<T>): T; <T extends ICommOpenMsg<'iopub'>>(options: IOptions<T>): T; <T extends ICommOpenMsg<'shell'>>(options: IOptions<T>): T; <T extends ICompleteReplyMsg>(options: IOptions<T>): T; <T extends ICompleteRequestMsg>(options: IOptions<T>): T; <T extends IDisplayDataMsg>(options: IOptions<T>): T; <T extends IErrorMsg>(options: IOptions<T>): T; <T extends IExecuteInputMsg>(options: IOptions<T>): T; <T extends IExecuteReplyMsg>(options: IOptions<T>): T; <T extends IExecuteRequestMsg>(options: IOptions<T>): T; <T extends IExecuteResultMsg>(options: IOptions<T>): T; <T extends IHistoryReplyMsg>(options: IOptions<T>): T; <T extends IHistoryRequestMsg>(options: IOptions<T>): T; <T extends IInfoReplyMsg>(options: IOptions<T>): T; <T extends IInfoRequestMsg>(options: IOptions<T>): T; <T extends IInputReplyMsg>(options: IOptions<T>): T; <T extends IInputRequestMsg>(options: IOptions<T>): T; <T extends IInspectReplyMsg>(options: IOptions<T>): T; <T extends IInspectRequestMsg>(options: IOptions<T>): T; <T extends IIsCompleteReplyMsg>(options: IOptions<T>): T; <T extends IIsCompleteRequestMsg>(options: IOptions<T>): T; <T extends IStatusMsg>(options: IOptions<T>): T; <T extends IStreamMsg>(options: IOptions<T>): T; <T extends IUpdateDisplayDataMsg>(options: IOptions<T>): T; <T extends IDebugRequestMsg>(options: IOptions<T>): T; <T extends IDebugReplyMsg>(options: IOptions<T>): T; <T extends IDebugEventMsg>(options: IOptions<T>): T;};
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this function is *NOT* considered part of the public API, and may change without notice.
function isClearOutputMsg
isClearOutputMsg: (msg: IMessage) => msg is IClearOutputMsg;
Test whether a kernel message is a
'clear_output'
message.
function isCommCloseMsg
isCommCloseMsg: (msg: IMessage) => msg is ICommCloseMsg<'iopub' | 'shell'>;
Test whether a kernel message is a
'comm_close'
message.
function isCommMsgMsg
isCommMsgMsg: (msg: IMessage) => msg is ICommMsgMsg<'iopub' | 'shell'>;
Test whether a kernel message is a
'comm_msg'
message.
function isCommOpenMsg
isCommOpenMsg: (msg: IMessage) => msg is ICommOpenMsg<'iopub' | 'shell'>;
Test whether a kernel message is a
'comm_open'
message.
function isDebugEventMsg
isDebugEventMsg: (msg: IMessage) => msg is IDebugEventMsg;
Test whether a kernel message is an experimental
'debug_event'
message.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this is *NOT* considered part of the public API, and may change without notice.
function isDebugReplyMsg
isDebugReplyMsg: (msg: IMessage) => msg is IDebugReplyMsg;
Test whether a kernel message is an experimental
'debug_reply'
message.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this is *NOT* considered part of the public API, and may change without notice.
function isDebugRequestMsg
isDebugRequestMsg: (msg: IMessage) => msg is IDebugRequestMsg;
Test whether a kernel message is an experimental
'debug_request'
message.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this is *NOT* considered part of the public API, and may change without notice.
function isDisplayDataMsg
isDisplayDataMsg: (msg: IMessage) => msg is IDisplayDataMsg;
Test whether a kernel message is an
'display_data'
message.
function isErrorMsg
isErrorMsg: (msg: IMessage) => msg is IErrorMsg;
Test whether a kernel message is an
'error'
message.
function isExecuteInputMsg
isExecuteInputMsg: (msg: IMessage) => msg is IExecuteInputMsg;
Test whether a kernel message is an
'execute_input'
message.
function isExecuteReplyMsg
isExecuteReplyMsg: (msg: IMessage) => msg is IExecuteReplyMsg;
Test whether a kernel message is an
'execute_reply'
message.
function isExecuteResultMsg
isExecuteResultMsg: (msg: IMessage) => msg is IExecuteResultMsg;
Test whether a kernel message is an
'execute_result'
message.
function isInfoRequestMsg
isInfoRequestMsg: (msg: IMessage) => msg is IInfoRequestMsg;
Test whether a kernel message is a
'kernel_info_request'
message.
function isInputReplyMsg
isInputReplyMsg: (msg: IMessage) => msg is IInputReplyMsg;
Test whether a kernel message is an
'input_reply'
message.
function isInputRequestMsg
isInputRequestMsg: (msg: IMessage) => msg is IInputRequestMsg;
Test whether a kernel message is an
'input_request'
message.
function isStatusMsg
isStatusMsg: (msg: IMessage) => msg is IStatusMsg;
Test whether a kernel message is a
'status'
message.
function isStreamMsg
isStreamMsg: (msg: IMessage) => msg is IStreamMsg;
Test whether a kernel message is a
'stream'
message.
function isUpdateDisplayDataMsg
isUpdateDisplayDataMsg: (msg: IMessage) => msg is IUpdateDisplayDataMsg;
Test whether a kernel message is an
'update_display_data'
message.
interface IClearOutputMsg
interface IClearOutputMsg extends IIOPubMessage<'clear_output'> {}
A
'clear_output'
message on the'iopub'
channel.See [Clear output](https://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output).
property content
content: { wait: boolean;};
interface ICommCloseMsg
interface ICommCloseMsg<T extends 'iopub' | 'shell' = 'iopub' | 'shell'> extends IMessage<'comm_close'> {}
A
'comm_close'
message on the'iopub'
channel.See [Comm close](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
interface ICommInfoReply
interface ICommInfoReply extends IReplyOkContent {}
A
'comm_info_reply'
message content.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
**See also:** [[ICommInfoRequest]], [[IKernel.commInfo]]
property comms
comms: { [commId: string]: { target_name: string; };};
Mapping of comm ids to target names.
interface ICommInfoReplyMsg
interface ICommInfoReplyMsg extends IShellMessage<'comm_info_reply'> {}
A
'comm_info_reply'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
**See also:** [[ICommInfoRequestMsg]], [[IKernel.commInfo]]
property content
content: ReplyContent<ICommInfoReply>;
property parent_header
parent_header: IHeader<'comm_info_request'>;
interface ICommInfoRequestMsg
interface ICommInfoRequestMsg extends IShellMessage<'comm_info_request'> {}
A
'comm_info_request'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info).
**See also:** [[ICommInfoReplyMsg]], [[IKernel.commInfo]]
property content
content: { /** * The comm target name to filter returned comms */ target_name?: string;};
interface ICommMsgMsg
interface ICommMsgMsg<T extends 'iopub' | 'shell' = 'iopub' | 'shell'> extends IMessage<'comm_msg'> {}
A
'comm_msg'
message on the'iopub'
channel.See [Comm msg](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
interface ICommOpenMsg
interface ICommOpenMsg<T extends 'shell' | 'iopub' = 'iopub' | 'shell'> extends IMessage<'comm_open'> {}
A
'comm_open'
message on the'iopub'
channel.See [Comm open](https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm).
interface ICompleteReplyMsg
interface ICompleteReplyMsg extends IShellMessage<'complete_reply'> {}
A
'complete_reply'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
**See also:** [[ICompleteRequest]], [[IKernel.complete]]
property content
content: ReplyContent<ICompleteReply>;
property parent_header
parent_header: IHeader<'complete_request'>;
interface ICompleteRequestMsg
interface ICompleteRequestMsg extends IShellMessage<'complete_request'> {}
A
'complete_request'
message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
**See also:** [[ICompleteReplyMsg]], [[IKernel.complete]]
property content
content: { code: string; cursor_pos: number;};
interface IControlMessage
interface IControlMessage<T extends ControlMessageType = ControlMessageType> extends IMessage<T> {}
A kernel message on the
'control'
channel.
property channel
channel: 'control';
interface IDebugEventMsg
interface IDebugEventMsg extends IIOPubMessage<'debug_event'> {}
An experimental
'debug_event'
message on the'iopub'
channel#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this is *NOT* considered part of the public API, and may change without notice.
property content
content: { seq: number; type: 'event'; event: string; body?: any;};
interface IDebugReplyMsg
interface IDebugReplyMsg extends IControlMessage<'debug_reply'> {}
An experimental
'debug_reply'
message on the'control'
channel.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this is *NOT* considered part of the public API, and may change without notice.
property content
content: { seq: number; type: 'response'; request_seq: number; success: boolean; command: string; message?: string; body?: any;};
interface IDebugRequestMsg
interface IDebugRequestMsg extends IControlMessage<'debug_request'> {}
An experimental
'debug_request'
message on the'control'
channel.#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, this function is *NOT* considered part of the public API, and may change without notice.
property content
content: { seq: number; type: 'request'; command: string; arguments?: any;};
interface IDisplayDataMsg
interface IDisplayDataMsg extends IIOPubMessage<'display_data'> {}
A
'display_data'
message on the'iopub'
channel.See [Display data](https://jupyter-client.readthedocs.io/en/latest/messaging.html#display-data).
property content
content: { data: nbformat.IMimeBundle; metadata: nbformat.OutputMetadata; transient?: { display_id?: string; };};
interface IErrorMsg
interface IErrorMsg extends IIOPubMessage<'error'> {}
A
'error'
message on the'iopub'
channel.See [Execution errors](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-errors).
property content
content: { ename: string; evalue: string; traceback: string[];};
interface IExecuteCount
interface IExecuteCount {}
The content of an
execute-reply
message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
property execution_count
execution_count: nbformat.ExecutionCount;
interface IExecuteInputMsg
interface IExecuteInputMsg extends IIOPubMessage<'execute_input'> {}
An
'execute_input'
message on the'iopub'
channel.See [Code inputs](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-inputs).
property content
content: { code: string; execution_count: nbformat.ExecutionCount;};
interface IExecuteReply
interface IExecuteReply extends IExecuteReplyBase {}
The
'execute_reply'
contents for an'ok'
status.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
property payload
payload?: JSONObject[];
A list of payload objects. Payloads are considered deprecated. The only requirement of each payload object is that it have a 'source' key, which is a string classifying the payload (e.g. 'page').
property user_expressions
user_expressions: JSONObject;
Results for the user_expressions.
interface IExecuteReplyMsg
interface IExecuteReplyMsg extends IShellMessage<'execute_reply'> {}
An
'execute_reply'
message on the'stream'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results).
**See also:** [[IExecuteRequest]], [[IKernel.execute]]
property content
content: ReplyContent<IExecuteReply> & IExecuteCount;
property parent_header
parent_header: IHeader<'execute_request'>;
interface IExecuteRequestMsg
interface IExecuteRequestMsg extends IShellMessage<'execute_request'> {}
An
execute_request
message on the'shell'
channel.
property content
content: { /** * The code to execute. */ code: string; /** * Whether to execute the code as quietly as possible. * The default is `false`. */ silent?: boolean; /** * Whether to store history of the execution. * The default `true` if silent is False. * It is forced to `false ` if silent is `true`. */ store_history?: boolean; /** * A mapping of names to expressions to be evaluated in the * kernel's interactive namespace. */ user_expressions?: JSONObject; /** * Whether to allow stdin requests. * The default is `true`. */ allow_stdin?: boolean; /** * Whether to the abort execution queue on an error. * The default is `false`. */ stop_on_error?: boolean;};
interface IExecuteResultMsg
interface IExecuteResultMsg extends IIOPubMessage<'execute_result'> {}
An
'execute_result'
message on the'iopub'
channel.See [Execution results](https://jupyter-client.readthedocs.io/en/latest/messaging.html#id4).
property content
content: { execution_count: nbformat.ExecutionCount; data: nbformat.IMimeBundle; metadata: nbformat.OutputMetadata; transient?: { display_id?: string; };};
interface IHeader
interface IHeader<T extends MessageType = MessageType> {}
Kernel message header content.
See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#general-message-format).
**See also:** [[IMessage]]
property date
date: string;
ISO 8601 timestamp for when the message is created
property msg_id
msg_id: string;
Message id, typically UUID, must be unique per message
property msg_type
msg_type: T;
Message type
property session
session: string;
Session id, typically UUID, should be unique per session.
property username
username: string;
The user sending the message
property version
version: string;
The message protocol version, should be 5.1, 5.2, 5.3, etc.
interface IHistoryReply
interface IHistoryReply extends IReplyOkContent {}
A
'history_reply'
message content.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryRequest]], [[IKernel.history]]
property history
history: [number, number, string][] | [number, number, [string, string]][];
interface IHistoryReplyMsg
interface IHistoryReplyMsg extends IShellMessage<'history_reply'> {}
A
'history_reply'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryRequest]], [[IKernel.history]]
property content
content: ReplyContent<IHistoryReply>;
property parent_header
parent_header: IHeader<'history_request'>;
interface IHistoryRequestMsg
interface IHistoryRequestMsg extends IShellMessage<'history_request'> {}
A
'history_request'
message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryReplyMsg]], [[[IKernel.history]]]
property content
content: IHistoryRequestRange | IHistoryRequestSearch | IHistoryRequestTail;
interface IHistoryRequestRange
interface IHistoryRequestRange {}
The content of a
'history_request'
range message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryReply]], [[[IKernel.history]]]
interface IHistoryRequestSearch
interface IHistoryRequestSearch {}
The content of a
'history_request'
search message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryReply]], [[[IKernel.history]]]
interface IHistoryRequestTail
interface IHistoryRequestTail {}
The content of a
'history_request'
tail message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history).
**See also:** [[IHistoryReply]], [[[IKernel.history]]]
property hist_access_type
hist_access_type: 'tail';
property n
n: number;
property output
output: boolean;
property raw
raw: boolean;
interface IInfoReply
interface IInfoReply extends IReplyOkContent {}
A
'kernel_info_reply'
message content.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
property banner
banner: string;
property help_links
help_links: { text: string; url: string;}[];
property implementation
implementation: string;
property implementation_version
implementation_version: string;
property language_info
language_info: ILanguageInfo;
property protocol_version
protocol_version: string;
interface IInfoReplyMsg
interface IInfoReplyMsg extends IShellMessage<'kernel_info_reply'> {}
A
'kernel_info_reply'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
property content
content: ReplyContent<IInfoReply>;
property parent_header
parent_header: IHeader<'kernel_info_request'>;
interface IInfoRequestMsg
interface IInfoRequestMsg extends IShellMessage<'kernel_info_request'> {}
A
'kernel_info_request'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
property content
content: Record<string, never>;
interface IInputReply
interface IInputReply extends IReplyOkContent {}
An
'input_reply'
message content.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
property value
value: string;
interface IInputReplyMsg
interface IInputReplyMsg extends IStdinMessage<'input_reply'> {}
An
'input_reply'
message on the'stdin'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
property content
content: ReplyContent<IInputReply>;
property parent_header
parent_header: IHeader<'input_request'>;
interface IInputRequestMsg
interface IInputRequestMsg extends IStdinMessage<'input_request'> {}
An
'input_request'
message on the'stdin'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
property content
content: { /** * The text to show at the prompt. */ prompt: string; /** * Whether the request is for a password. * If so, the frontend shouldn't echo input. */ password: boolean;};
interface IInspectReply
interface IInspectReply extends IReplyOkContent {}
A
'inspect_reply'
message content.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
**See also:** [[IInspectRequest]], [[IKernel.inspect]]
interface IInspectReplyMsg
interface IInspectReplyMsg extends IShellMessage<'inspect_reply'> {}
A
'inspect_reply'
message on the'shell'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
**See also:** [[IInspectRequest]], [[IKernel.inspect]]
property content
content: ReplyContent<IInspectReply>;
property parent_header
parent_header: IHeader<'inspect_request'>;
interface IInspectRequestMsg
interface IInspectRequestMsg extends IShellMessage<'inspect_request'> {}
An
'inspect_request'
message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
**See also:** [[IInspectReplyMsg]], [[[IKernel.inspect]]]
property content
content: { code: string; cursor_pos: number; detail_level: 0 | 1;};
interface IIOPubMessage
interface IIOPubMessage<T extends IOPubMessageType = IOPubMessageType> extends IMessage<T> {}
A kernel message on the
'iopub'
channel.
property channel
channel: 'iopub';
interface IIsCompleteReplyIncomplete
interface IIsCompleteReplyIncomplete {}
An 'incomplete' completion reply
interface IIsCompleteReplyMsg
interface IIsCompleteReplyMsg extends IShellMessage<'is_complete_reply'> {}
An
'is_complete_reply'
message on the'stream'
channel.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
**See also:** [[IIsCompleteRequest]], [[IKernel.isComplete]]
property content
content: ReplyContent<IIsCompleteReplyIncomplete | IIsCompleteReplyOther>;
property parent_header
parent_header: IHeader<'is_complete_request'>;
interface IIsCompleteReplyOther
interface IIsCompleteReplyOther {}
A completion reply for completion or invalid states.
property status
status: 'complete' | 'invalid' | 'unknown';
interface IIsCompleteRequestMsg
interface IIsCompleteRequestMsg extends IShellMessage<'is_complete_request'> {}
An
'is_complete_request'
message.See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
**See also:** [[IIsCompleteReplyMsg]], [[IKernel.isComplete]]
property content
content: { code: string;};
interface ILanguageInfo
interface ILanguageInfo extends nbformat.ILanguageInfoMetadata {}
The kernel language information specification.
See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
property nbconverter_exporter
nbconverter_exporter?: string;
property version
version: string;
interface IMessage
interface IMessage<MSGTYPE extends MessageType = MessageType> {}
Kernel message specification.
See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#general-message-format).
property buffers
buffers?: (ArrayBuffer | ArrayBufferView)[];
An optional list of binary buffers.
property channel
channel: Channel;
The channel on which the message is transmitted.
property content
content: Message['content'];
The content of the message.
property header
header: IHeader<MSGTYPE>;
The message header.
property metadata
metadata: JSONObject;
Metadata associated with the message.
property parent_header
parent_header: IHeader | Record<string, never>;
The parent message
interface IOptions
interface IOptions<T extends Message> {}
property buffers
buffers?: (ArrayBuffer | ArrayBufferView)[];
property channel
channel: T['channel'];
property content
content: T['content'];
property metadata
metadata?: JSONObject;
property msgId
msgId?: string;
property msgType
msgType: T['header']['msg_type'];
property parentHeader
parentHeader?: T['parent_header'];
property session
session: string;
property username
username?: string;
interface IReplyAbortContent
interface IReplyAbortContent {}
Reply content indicating an aborted request.
This is [deprecated](https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply) in message spec 5.1. Kernels should send an 'error' reply instead.
property status
status: 'abort';
interface IReplyErrorContent
interface IReplyErrorContent {}
Reply content indicating an error.
See the [Message spec](https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply) for details.
interface IReplyOkContent
interface IReplyOkContent {}
Reply content indicating a successful request.
property status
status: 'ok';
interface IShellMessage
interface IShellMessage<T extends ShellMessageType = ShellMessageType> extends IMessage<T> {}
A kernel message on the
'shell'
channel.
property channel
channel: 'shell';
interface IStatusMsg
interface IStatusMsg extends IIOPubMessage<'status'> {}
A
'status'
message on the'iopub'
channel.See [Kernel status](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-status).
property content
content: { execution_state: Status;};
interface IStdinMessage
interface IStdinMessage<T extends StdinMessageType = StdinMessageType> extends IMessage<T> {}
A kernel message on the
'stdin'
channel.
property channel
channel: 'stdin';
interface IStreamMsg
interface IStreamMsg extends IIOPubMessage<'stream'> {}
A
'stream'
message on the'iopub'
channel.See [Streams](https://jupyter-client.readthedocs.io/en/latest/messaging.html#streams-stdout-stderr-etc).
property content
content: { name: 'stdout' | 'stderr'; text: string;};
interface IUpdateDisplayDataMsg
interface IUpdateDisplayDataMsg extends IIOPubMessage<'update_display_data'> {}
An
'update_display_data'
message on the'iopub'
channel.See [Update Display data](https://jupyter-client.readthedocs.io/en/latest/messaging.html#update-display-data).
property content
content: IDisplayDataMsg['content'] & { transient: { display_id: string; };};
enum supportedKernelWebSocketProtocols
enum supportedKernelWebSocketProtocols { v1KernelWebsocketJupyterOrg = 'v1.kernel.websocket.jupyter.org',}
The list of supported kernel wire protocols over websocket.
member v1KernelWebsocketJupyterOrg
v1KernelWebsocketJupyterOrg = 'v1.kernel.websocket.jupyter.org'
type Channel
type Channel = 'shell' | 'control' | 'iopub' | 'stdin';
The valid Jupyter channel names in a message to a frontend.
type ControlMessageType
type ControlMessageType = 'debug_request' | 'debug_reply';
Control message types.
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, debug message types are *NOT* considered part of the public API, and may change without notice.
type IOPubMessageType
type IOPubMessageType = | 'clear_output' | 'comm_close' | 'comm_msg' | 'comm_open' | 'display_data' | 'error' | 'execute_input' | 'execute_result' | 'shutdown_reply' | 'status' | 'stream' | 'update_display_data' | 'debug_event';
IOPub message types.
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, debug message types are *NOT* considered part of the public API, and may change without notice.
type IShellControlMessage
type IShellControlMessage = IShellMessage | IControlMessage;
A message type for shell or control messages.
#### Notes This convenience is so we can use it as a generic type constraint.
type Message
type Message = | IClearOutputMsg | ICommCloseMsg<'iopub'> | ICommCloseMsg<'shell'> | ICommInfoReplyMsg | ICommInfoRequestMsg | ICommMsgMsg<'iopub'> | ICommMsgMsg<'shell'> | ICommOpenMsg<'iopub'> | ICommOpenMsg<'shell'> | ICompleteReplyMsg | ICompleteRequestMsg | IDisplayDataMsg | IErrorMsg | IExecuteInputMsg | IExecuteReplyMsg | IExecuteRequestMsg | IExecuteResultMsg | IHistoryReplyMsg | IHistoryRequestMsg | IInfoReplyMsg | IInfoRequestMsg | IInputReplyMsg | IInputRequestMsg | IInspectReplyMsg | IInspectRequestMsg | IIsCompleteReplyMsg | IIsCompleteRequestMsg | IStatusMsg | IStreamMsg | IUpdateDisplayDataMsg | IDebugRequestMsg | IDebugReplyMsg | IDebugEventMsg;
Message types.
#### Notes Debug messages are experimental messages that are not in the official kernel message specification. As such, debug message types are *NOT* considered part of the public API, and may change without notice.
type MessageType
type MessageType = | IOPubMessageType | ShellMessageType | ControlMessageType | StdinMessageType;
Jupyter message types.
type ShellMessageType
type ShellMessageType = | 'comm_close' | 'comm_info_reply' | 'comm_info_request' | 'comm_msg' | 'comm_open' | 'complete_reply' | 'complete_request' | 'execute_reply' | 'execute_request' | 'history_reply' | 'history_request' | 'inspect_reply' | 'inspect_request' | 'interrupt_reply' | 'interrupt_request' | 'is_complete_reply' | 'is_complete_request' | 'kernel_info_reply' | 'kernel_info_request' | 'shutdown_reply' | 'shutdown_request';
Shell message types.
type Status
type Status = | 'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead';
The valid Kernel status states.
#### Notes The status states are: *
unknown
: The kernel status is unknown, often because the connection is disconnected or connecting. This state is determined by the kernel connection status. *autorestarting
: The kernel is restarting, initiated by the server. This state is set by the services library, not explicitly sent from the kernel. *starting
: The kernel is starting *idle
: The kernel has finished processing messages. *busy
: The kernel is currently processing messages. *restarting
: The kernel is restarting. This state is sent by the Jupyter server. *dead
: The kernel is dead and will not be restarted. This state is set by the Jupyter server and is a final state.
type StdinMessageType
type StdinMessageType = 'input_request' | 'input_reply';
Stdin message types.
namespace KernelSpec
module 'lib/kernelspec/kernelspec.d.ts' {}
Object which manages kernel instances for a given base url.
#### Notes The manager is responsible for maintaining the state of kernel specs.
interface IManager
interface IManager extends IBaseManager {}
Object which manages kernel instances for a given base url.
#### Notes The manager is responsible for maintaining the state of kernel specs.
property specs
readonly specs: ISpecModels | null;
The kernel spec models.
#### Notes The value will be null until the manager is ready.
property specsChanged
specsChanged: ISignal<IManager, ISpecModels>;
A signal emitted when the kernel specs change.
method refreshSpecs
refreshSpecs: () => Promise<void>;
Force a refresh of the specs from the server.
Returns
A promise that resolves when the specs are fetched.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
interface ISpecModel
interface ISpecModel extends PartialJSONObject {}
Kernel Spec interface.
#### Notes See [Kernel specs](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs).
property argv
readonly argv: string[];
A list of command line arguments used to start the kernel.
property display_name
readonly display_name: string;
The kernel’s name as it should be displayed in the UI.
property env
readonly env?: PartialJSONObject;
A dictionary of environment variables to set for the kernel.
property language
readonly language: string;
The name of the language of the kernel.
property metadata
readonly metadata?: PartialJSONObject;
A dictionary of additional attributes about this kernel; used by clients to aid in kernel selection.
property name
readonly name: string;
The name of the kernel spec.
property resources
readonly resources: { [key: string]: string;};
A mapping of resource file name to download path.
interface ISpecModels
interface ISpecModels extends PartialJSONObject {}
The available kernelSpec models.
#### Notes See the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernelspecs).
property default
default: string;
The name of the default kernel spec.
property kernelspecs
readonly kernelspecs: { [key: string]: ISpecModel | undefined;};
A mapping of kernel spec name to spec.
namespace KernelSpecAPI
module 'lib/kernelspec/restapi.d.ts' {}
Fetch all of the kernel specs.
Parameter settings
The optional server settings.
Parameter useCache
Whether to use the cache. If false, always request.
Returns
A promise that resolves with the kernel specs.
#### Notes 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#!/kernelspecs).
function getSpecs
getSpecs: (settings?: ServerConnection.ISettings) => Promise<ISpecModels>;
Fetch all of the kernel specs.
Parameter settings
The optional server settings.
Parameter useCache
Whether to use the cache. If false, always request.
Returns
A promise that resolves with the kernel specs.
#### Notes 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#!/kernelspecs).
interface ISpecModel
interface ISpecModel extends PartialJSONObject {}
Kernel Spec interface.
#### Notes See [Kernel specs](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs).
property argv
readonly argv: string[];
A list of command line arguments used to start the kernel.
property display_name
readonly display_name: string;
The kernel’s name as it should be displayed in the UI.
property env
readonly env?: PartialJSONObject;
A dictionary of environment variables to set for the kernel.
property language
readonly language: string;
The name of the language of the kernel.
property metadata
readonly metadata?: PartialJSONObject;
A dictionary of additional attributes about this kernel; used by clients to aid in kernel selection.
property name
readonly name: string;
The name of the kernel spec.
property resources
readonly resources: { [key: string]: string;};
A mapping of resource file name to download path.
interface ISpecModels
interface ISpecModels extends PartialJSONObject {}
The available kernelSpec models.
#### Notes See the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernelspecs).
property default
default: string;
The name of the default kernel spec.
property kernelspecs
readonly kernelspecs: { [key: string]: ISpecModel | undefined;};
A mapping of kernel spec name to spec.
namespace KernelSpecManager
namespace KernelSpecManager {}
The namespace for
KernelManager
class statics.
namespace NbConvert
namespace NbConvert {}
A namespace for builder API interfaces.
interface IManager
interface IManager extends NbConvertManager {}
The interface for the build manager.
namespace NbConvertManager
namespace NbConvertManager {}
A namespace for
BuildManager
statics.
interface IExportFormats
interface IExportFormats {}
A namespace for nbconvert API interfaces.
index signature
[key: string]: { output_mimetype: string;};
The list of supported export formats.
interface IOptions
interface IOptions {}
The instantiation options for a setting manager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings used to make API requests.
namespace ServerConnection
namespace ServerConnection {}
The namespace for ServerConnection functions.
#### Notes This is only intended to manage communication with the Jupyter server.
The default values can be used in a JupyterLab or Jupyter Notebook context.
We use
token
authentication if available, falling back on an XSRF cookie if one has been provided on thedocument
.A content type of
'application/json'
is added when using authentication and there is no body data to allow the server to prevent malicious forms.
function makeRequest
makeRequest: ( url: string, init: RequestInit, settings: ISettings) => Promise<Response>;
Make an request to the notebook server.
Parameter url
The url for the request.
Parameter init
The initialization options for the request.
Parameter settings
The server settings to apply to the request.
Returns
a Promise that resolves with the response.
Throws
If the url of the request is not a notebook server url.
#### Notes The
url
must start withsettings.baseUrl
. Theinit
settings are merged withsettings.init
, withinit
taking precedence. The headers in the two objects are not merged. If there is no body data, we set the content type toapplication/json
because it is required by the Notebook server.
function makeSettings
makeSettings: (options?: Partial<ISettings>) => ISettings;
Create a settings object given a subset of options.
Parameter options
An optional partial set of options.
Returns
The full settings object.
class NetworkError
class NetworkError extends TypeError {}
A wrapped error for a network error.
constructor
constructor(original: TypeError);
Create a new network error.
class ResponseError
class ResponseError extends Error {}
A wrapped error for a fetch response.
constructor
constructor(response: Response, message?: string, traceback?: string);
Create a new response error.
property response
response: Response;
The response associated with the error.
property traceback
traceback: string;
The traceback associated with the error.
method create
static create: (response: Response) => Promise<ResponseError>;
Create a ResponseError from a response, handling the traceback and message as appropriate.
Parameter response
The response object.
Returns
A promise that resolves with a
ResponseError
object.
interface ISettings
interface ISettings {}
A Jupyter server settings object. Note that all of the settings are optional when passed to [[makeSettings]]. The default settings are given in [[defaultSettings]].
property appendToken
readonly appendToken: boolean;
Whether to append a token to a Websocket url. The default is
false
in the browser andtrue
in node or jest.
property appUrl
readonly appUrl: string;
The app url of the JupyterLab application.
property baseUrl
readonly baseUrl: string;
The base url of the server.
property fetch
readonly fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
The
fetch
method to use.
property Headers
readonly Headers: typeof Headers;
The
Headers
object constructor.
property init
readonly init: RequestInit;
The default request init options.
property Request
readonly Request: typeof Request;
The
Request
object constructor.
property serializer
readonly serializer: ISerializer;
Serializer used to serialize/deserialize kernel messages.
property token
readonly token: string;
The authentication token for requests. Use an empty string to disable.
property WebSocket
readonly WebSocket: typeof WebSocket;
The
WebSocket
object constructor.
property wsUrl
readonly wsUrl: string;
The base ws url of the server.
namespace ServiceManager
namespace ServiceManager {}
The namespace for
ServiceManager
statics.
interface IManager
interface IManager extends IDisposable, IManagers {}
A service manager interface.
property connectionFailure
readonly connectionFailure: ISignal<IManager, Error>;
A signal emitted when there is a connection failure with the server.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is initially ready.
interface IOptions
interface IOptions extends IManagers {}
The options used to create a service manager.
property defaultDrive
readonly defaultDrive: Contents.IDrive;
The default drive for the contents manager.
property standby
standby: Poll.Standby | (() => boolean | Poll.Standby);
When the manager stops polling the API. Defaults to
when-hidden
.
namespace Session
module 'lib/session/session.d.ts' {}
Interface of a session object.
A session object represents a live connection to a session kernel.
This represents a persistent kernel connection with a particular key, that persists across changing kernels and kernels getting terminated. As such, a number of signals are proxied from the current kernel for convenience.
The kernel is owned by the session, in that the session creates the kernel and manages its lifecycle.
interface IManager
interface IManager extends IDisposable {}
Object which manages session instances.
#### Notes The manager is responsible for maintaining the state of running sessions.
property connectionFailure
connectionFailure: ISignal<IManager, ServerConnection.NetworkError>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that is fulfilled when the manager is ready.
property runningChanged
runningChanged: ISignal<this, IModel[]>;
A signal emitted when the running sessions change.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings for the manager.
method connectTo
connectTo: ( options: Omit< ISessionConnection.IOptions, 'connectToKernel' | 'serverSettings' >) => ISessionConnection;
Connect to a running session.
Parameter model
The model of the target session.
Parameter options
The session options to use.
Returns
The new session instance.
method findById
findById: (id: string) => Promise<IModel | undefined>;
Find a session by id.
Parameter id
The id of the target session.
Returns
A promise that resolves with the session's model.
method findByPath
findByPath: (path: string) => Promise<IModel | undefined>;
Find a session by path.
Parameter path
The path of the target session.
Returns
A promise that resolves with the session's model.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running sessions.
Returns
A promise that resolves when the models are refreshed.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
method running
running: () => IterableIterator<IModel>;
Create an iterator over the known running sessions.
Returns
A new iterator over the running sessions.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a session by id.
Parameter id
The id of the target kernel.
Returns
A promise that resolves when the operation is complete.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all sessions.
Returns
A promise that resolves when all of the sessions are shut down.
method startNew
startNew: ( createOptions: ISessionOptions, connectOptions?: Omit< ISessionConnection.IOptions, 'model' | 'connectToKernel' | 'serverSettings' >) => Promise<ISessionConnection>;
Start a new session.
Parameter createOptions
Options for creating the session
Parameter connectOptions
Options for connecting to the session
Returns
A promise that resolves with a session connection instance.
#### Notes The
serverSettings
andconnectToKernel
options of the manager will be used.
method stopIfNeeded
stopIfNeeded: (path: string) => Promise<void>;
Find a session associated with a path and stop it is the only session using that kernel.
Parameter path
The path in question.
Returns
A promise that resolves when the relevant sessions are stopped.
interface IModel
interface IModel {}
The session model returned by the server.
#### Notes See 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).
interface ISessionConnection
interface ISessionConnection extends IObservableDisposable {}
Interface of a session object.
A session object represents a live connection to a session kernel.
This represents a persistent kernel connection with a particular key, that persists across changing kernels and kernels getting terminated. As such, a number of signals are proxied from the current kernel for convenience.
The kernel is owned by the session, in that the session creates the kernel and manages its lifecycle.
property anyMessage
anyMessage: ISignal<this, Kernel.IAnyMessageArgs>;
The kernel anyMessage signal, proxied from the current kernel.
property connectionStatusChanged
connectionStatusChanged: ISignal<this, Kernel.ConnectionStatus>;
The kernel connectionStatusChanged signal, proxied from the current kernel.
property id
readonly id: string;
Unique id of the session.
property iopubMessage
iopubMessage: ISignal<this, KernelMessage.IIOPubMessage>;
The kernel iopubMessage signal, proxied from the current kernel.
property kernel
readonly kernel: Kernel.IKernelConnection | null;
The kernel.
#### Notes This is a read-only property, and can be altered by [changeKernel].
A number of kernel signals are proxied through the session from whatever the current kernel is for convenience.
property kernelChanged
kernelChanged: ISignal< this, IChangedArgs< Kernel.IKernelConnection | null, Kernel.IKernelConnection | null, 'kernel' >>;
A signal emitted when the kernel changes.
property model
readonly model: IModel;
The model associated with the session.
property name
readonly name: string;
The current name associated with the session.
property path
readonly path: string;
The current path associated with the session.
property pendingInput
pendingInput: ISignal<this, boolean>;
The kernel pendingInput signal, proxied from the current kernel.
property propertyChanged
readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
A signal emitted when a session property changes.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings of the session.
property statusChanged
statusChanged: ISignal<this, Kernel.Status>;
The kernel statusChanged signal, proxied from the current kernel.
property type
readonly type: string;
The type of the session.
property unhandledMessage
unhandledMessage: ISignal<this, KernelMessage.IMessage>;
The kernel unhandledMessage signal, proxied from the current kernel.
method changeKernel
changeKernel: ( options: Partial<Kernel.IModel>) => Promise<Kernel.IKernelConnection | null>;
Change the kernel.
Parameter options
The name or id of the new kernel.
Returns
A promise that resolves with the new kernel model.
#### Notes This shuts down the existing kernel and creates a new kernel, keeping the existing session ID and path. The session assumes it owns the kernel.
To start now kernel, pass an empty dictionary.
method setName
setName: (name: string) => Promise<void>;
Change the session name.
Returns
A promise that resolves when the session has renamed.
#### Notes This uses the Jupyter REST API, and the response is validated. The promise is fulfilled on a valid response and rejected otherwise.
method setPath
setPath: (path: string) => Promise<void>;
Change the session path.
Parameter path
The new session path.
Returns
A promise that resolves when the session has renamed.
#### Notes This uses the Jupyter REST API, and the response is validated. The promise is fulfilled on a valid response and rejected otherwise.
method setType
setType: (type: string) => Promise<void>;
Change the session type.
Returns
A promise that resolves when the session has renamed.
#### Notes This uses the Jupyter REST API, and the response is validated. The promise is fulfilled on a valid response and rejected otherwise.
method shutdown
shutdown: () => Promise<void>;
Kill the kernel and shutdown the session.
Returns
A promise that resolves when the session is shut down.
#### Notes This uses the Jupyter REST API, and the response is validated. The promise is fulfilled on a valid response and rejected otherwise.
type ISessionOptions
type ISessionOptions = Pick<IModel, 'path' | 'type' | 'name'> & { kernel?: Partial<Pick<Kernel.IModel, 'name'>>;};
A session request.
#### Notes The
path
andtype
session model parameters are required. Thename
parameter is not technically required, but is often assumed to be nonempty, so we require it too.See 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).
namespace Session.ISessionConnection
namespace Session.ISessionConnection {}
interface IOptions
interface IOptions {}
The session initialization options.
property clientId
clientId?: string;
The unique identifier for the session client.
property kernelConnectionOptions
kernelConnectionOptions?: Omit< Kernel.IKernelConnection.IOptions, 'model' | 'username' | 'clientId' | 'serverSettings'>;
Kernel connection options
property model
model: IModel;
Session model.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings.
property username
username?: string;
The username of the session client.
method connectToKernel
connectToKernel: ( options: Kernel.IKernelConnection.IOptions) => Kernel.IKernelConnection;
Connects to an existing kernel
type IKernelChangedArgs
type IKernelChangedArgs = IChangedArgs< Kernel.IKernelConnection | null, Kernel.IKernelConnection | null, 'kernel'>;
An arguments object for the kernel changed signal.
namespace SessionAPI
module 'lib/session/restapi.d.ts' {}
The url for the session service.
variable SESSION_SERVICE_URL
const SESSION_SERVICE_URL: string;
The url for the session service.
function getSessionModel
getSessionModel: ( id: string, settings?: ServerConnection.ISettings) => Promise<Session.IModel>;
Get a full session model from the server by session id string.
function getSessionUrl
getSessionUrl: (baseUrl: string, id: string) => string;
Get a session url.
function listRunning
listRunning: ( settings?: ServerConnection.ISettings) => Promise<Session.IModel[]>;
List the running sessions.
function shutdownSession
shutdownSession: ( id: string, settings?: ServerConnection.ISettings) => Promise<void>;
Shut down a session by id.
function startSession
startSession: ( options: Session.ISessionOptions, settings?: ServerConnection.ISettings) => Promise<Session.IModel>;
Create a new session, or return an existing session if the session path already exists.
function updateSession
updateSession: ( model: Pick<Session.IModel, 'id'> & DeepPartial<Omit<Session.IModel, 'id'>>, settings?: ServerConnection.ISettings) => Promise<Session.IModel>;
Send a PATCH to the server, updating the session path or the kernel.
namespace SessionManager
namespace SessionManager {}
The namespace for
SessionManager
class statics.
class NoopManager
class NoopManager extends SessionManager {}
A no-op session manager to be used when starting sessions is not supported.
property isActive
readonly isActive: boolean;
Whether the manager is active.
property parentReady
readonly parentReady: Promise<void>;
Used for testing.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready (never).
method connectTo
connectTo: ( options: Omit< Session.ISessionConnection.IOptions, 'connectToKernel' | 'serverSettings' >) => Session.ISessionConnection;
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running sessions and update state.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a session by id - throw an error since it is not supported.
method startNew
startNew: ( createOptions: Session.ISessionOptions, connectOptions?: Omit< Session.ISessionConnection.IOptions, 'model' | 'connectToKernel' | 'serverSettings' >) => Promise<Session.ISessionConnection>;
Start a new session - throw an error since it is not supported.
interface IOptions
interface IOptions extends BaseManager.IOptions {}
The options used to initialize a SessionManager.
property kernelManager
kernelManager: Kernel.IManager;
Kernel Manager
property standby
standby?: Poll.Standby | (() => boolean | Poll.Standby);
When the manager stops polling the API. Defaults to
when-hidden
.
namespace Setting
namespace Setting {}
A namespace for setting API interfaces.
interface IManager
interface IManager extends SettingManager {}
The interface for the setting system manager.
namespace SettingManager
namespace SettingManager {}
A namespace for
SettingManager
statics.
interface IOptions
interface IOptions {}
The instantiation options for a setting manager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings used to make API requests.
namespace Terminal
module 'lib/terminal/terminal.d.ts' {}
The terminal name.
function isAvailable
isAvailable: () => boolean;
Whether the terminal service is available.
interface IManager
interface IManager extends IBaseManager {}
The interface for a terminal manager.
#### Notes The manager is responsible for maintaining the state of running terminal sessions.
property connectionFailure
connectionFailure: ISignal<IManager, ServerConnection.NetworkError>;
A signal emitted when there is a connection failure.
property isReady
readonly isReady: boolean;
Test whether the manager is ready.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready.
property runningChanged
runningChanged: ISignal<IManager, IModel[]>;
A signal emitted when the running terminals change.
method connectTo
connectTo: ( options: Omit<ITerminalConnection.IOptions, 'serverSettings'>) => ITerminalConnection;
method isAvailable
isAvailable: () => boolean;
Whether the terminal service is available.
method refreshRunning
refreshRunning: () => Promise<void>;
Force a refresh of the running terminal sessions.
Returns
A promise that with the list of running sessions.
#### Notes This is not typically meant to be called by the user, since the manager maintains its own internal state.
method running
running: () => IterableIterator<IModel>;
Create an iterator over the known running terminals.
Returns
A new iterator over the running terminals.
method shutdown
shutdown: (name: string) => Promise<void>;
Shut down a terminal session by name.
Parameter name
The name of the terminal session.
Returns
A promise that resolves when the session is shut down.
method shutdownAll
shutdownAll: () => Promise<void>;
Shut down all terminal sessions.
Returns
A promise that resolves when all of the sessions are shut down.
method startNew
startNew: (options?: ITerminal.IOptions) => Promise<ITerminalConnection>;
Create a new terminal session.
Parameter options
The options used to create the terminal.
Returns
A promise that resolves with the terminal connection instance.
#### Notes The manager
serverSettings
will be always be used.
interface IMessage
interface IMessage {}
A message from the terminal session.
interface IModel
interface IModel {}
The server model for a terminal session.
property name
readonly name: string;
The name of the terminal session.
interface ITerminalConnection
interface ITerminalConnection extends IObservableDisposable {}
An interface for a terminal session.
property connectionStatus
readonly connectionStatus: ConnectionStatus;
The current connection status of the terminal.
property connectionStatusChanged
connectionStatusChanged: ISignal<this, ConnectionStatus>;
A signal emitted when the terminal connection status changes.
property messageReceived
messageReceived: ISignal<ITerminalConnection, IMessage>;
A signal emitted when a message is received from the server.
property model
readonly model: IModel;
The model associated with the session.
property name
readonly name: string;
Get the name of the terminal session.
property serverSettings
readonly serverSettings: ServerConnection.ISettings;
The server settings for the session.
method reconnect
reconnect: () => Promise<void>;
Reconnect to the terminal.
Returns
A promise that resolves when the terminal has reconnected.
method send
send: (message: IMessage) => void;
Send a message to the terminal session.
method shutdown
shutdown: () => Promise<void>;
Shut down the terminal session.
type ConnectionStatus
type ConnectionStatus = 'connected' | 'connecting' | 'disconnected';
The valid terminal connection states.
#### Notes The status states are: *
connected
: The terminal connection is live. *connecting
: The terminal connection is not live, but we are attempting to reconnect to the terminal. *disconnected
: The terminal connection is down, we are not trying to reconnect.
type MessageType
type MessageType = 'stdout' | 'disconnect' | 'set_size' | 'stdin';
Valid message types for the terminal.
namespace Terminal.ITerminal
namespace Terminal.ITerminal {}
namespace Terminal.ITerminalConnection
namespace Terminal.ITerminalConnection {}
interface IOptions
interface IOptions {}
property model
model: IModel;
Terminal model.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings.
namespace TerminalAPI
module 'lib/terminal/restapi.d.ts' {}
The url for the terminal service.
variable TERMINAL_SERVICE_URL
const TERMINAL_SERVICE_URL: string;
The url for the terminal service.
function isAvailable
isAvailable: () => boolean;
Whether the terminal service is available.
function listRunning
listRunning: (settings?: ServerConnection.ISettings) => Promise<IModel[]>;
List the running terminal sessions.
Parameter settings
The server settings to use.
Returns
A promise that resolves with the list of running session models.
function shutdownTerminal
shutdownTerminal: ( name: string, settings?: ServerConnection.ISettings) => Promise<void>;
Shut down a terminal session by name.
Parameter name
The name of the target session.
Parameter settings
The server settings to use.
Returns
A promise that resolves when the session is shut down.
function startNew
startNew: ( settings?: ServerConnection.ISettings, name?: string, cwd?: string) => Promise<IModel>;
Start a new terminal session.
Parameter settings
The server settings to use.
Parameter name
The name of the target terminal.
Parameter cwd
The path in which the terminal will start.
Returns
A promise that resolves with the session model.
namespace TerminalManager
namespace TerminalManager {}
The namespace for TerminalManager statics.
class NoopManager
class NoopManager extends TerminalManager {}
A no-op terminal manager to be used when starting terminals is not supported.
property isActive
readonly isActive: boolean;
Whether the manager is active.
property parentReady
readonly parentReady: Promise<void>;
Used for testing.
property ready
readonly ready: Promise<void>;
A promise that fulfills when the manager is ready (never).
method connectTo
connectTo: ( options: Omit<Terminal.ITerminalConnection.IOptions, 'serverSettings'>) => Terminal.ITerminalConnection;
method requestRunning
protected requestRunning: () => Promise<void>;
Execute a request to the server to poll running sessions and update state.
method shutdown
shutdown: (id: string) => Promise<void>;
Shut down a session by id - throw an error since it is not supported.
method startNew
startNew: ( options?: Terminal.ITerminal.IOptions) => Promise<Terminal.ITerminalConnection>;
Create a new terminal session - throw an error since it is not supported.
namespace User
namespace User {}
A namespace for user API interfaces.
interface IIdentity
interface IIdentity extends PartialJSONObject {}
The interface describing a user identity.
property avatar_url
readonly avatar_url?: string;
User's avatar url. The url to the user's image for the icon.
property color
readonly color: string;
User's cursor color and icon color if avatar_url is undefined (there is no image).
property display_name
readonly display_name: string;
Shorter version of the name for displaying it on the UI.
property initials
readonly initials: string;
User's name initials.
property name
readonly name: string;
User's full name.
property username
readonly username: string;
User's unique identifier.
interface IManager
interface IManager extends IBaseManager {}
Object which manages user's identity.
#### Notes The manager is responsible for maintaining the state of the user.
property identity
readonly identity: User.IIdentity | null;
User's identity.
#### Notes The value will be null until the manager is ready.
property permissions
readonly permissions: ReadonlyJSONObject | null;
User's permissions.
#### Notes The value will be null until the manager is ready.
property userChanged
userChanged: ISignal<this, User.IUser>;
A signal emitted when the user changes.
method refreshUser
refreshUser: () => Promise<void>;
Force a refresh of user's identity from the server.
Returns
A promise that resolves when the identity is fetched.
#### Notes This is intended to be called only in response to a user action, since the manager maintains its internal state.
interface IUser
interface IUser {}
The interface describing a user identity.
property identity
readonly identity: IIdentity;
property permissions
readonly permissions: PartialJSONObject;
namespace UserManager
namespace UserManager {}
A namespace for
UserManager
statics.
namespace Workspace
namespace Workspace {}
A namespace for workspace API interfaces.
interface IManager
interface IManager extends WorkspaceManager {}
The interface for the workspace API manager.
interface IWorkspace
interface IWorkspace {}
The interface describing a workspace API response.
property data
data: ReadonlyPartialJSONObject;
The workspace data.
property metadata
metadata: { /** * The workspace ID. */ id: string; /** * The last modification date and time for this workspace (ISO 8601 format). */ last_modified?: string; /** * The creation date and time for this workspace (ISO 8601 format). */ created?: string;};
The metadata for a workspace.
namespace WorkspaceManager
namespace WorkspaceManager {}
A namespace for
WorkspaceManager
statics.
interface IOptions
interface IOptions {}
The instantiation options for a workspace manager.
property serverSettings
serverSettings?: ServerConnection.ISettings;
The server settings used to make API requests.
Package Files (26)
- lib/basemanager.d.ts
- lib/builder/index.d.ts
- lib/config/index.d.ts
- lib/contents/index.d.ts
- lib/event/index.d.ts
- lib/index.d.ts
- lib/kernel/default.d.ts
- lib/kernel/kernel.d.ts
- lib/kernel/manager.d.ts
- lib/kernel/messages.d.ts
- lib/kernel/restapi.d.ts
- lib/kernelspec/kernelspec.d.ts
- lib/kernelspec/manager.d.ts
- lib/kernelspec/restapi.d.ts
- lib/manager.d.ts
- lib/nbconvert/index.d.ts
- lib/serverconnection.d.ts
- lib/session/manager.d.ts
- lib/session/restapi.d.ts
- lib/session/session.d.ts
- lib/setting/index.d.ts
- lib/terminal/manager.d.ts
- lib/terminal/restapi.d.ts
- lib/terminal/terminal.d.ts
- lib/user/index.d.ts
- lib/workspace/index.d.ts
Dependencies (11)
Dev Dependencies (8)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@jupyterlab/services
.
- Markdown[](https://www.jsdocs.io/package/@jupyterlab/services)
- HTML<a href="https://www.jsdocs.io/package/@jupyterlab/services"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 13960 ms. - Missing or incorrect documentation? Open an issue for this package.