Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClientSession

The default implementation of client session object. A namespace for ClientSession statics.

Hierarchy

  • ClientSession

Implements

Index

Constructors

constructor

Properties

Private _busyDisposable

_busyDisposable: IDisposable | null = null

Private _dialog

_dialog: Dialog<any> | null = null

Private _initializing

_initializing: boolean = false

Private _iopubMessage

_iopubMessage: Signal<this, IMessage<"clear_output" | "comm_close" | "comm_msg" | "comm_open" | "display_data" | "error" | "execute_input" | "execute_result" | "status" | "stream" | "update_display_data" | "comm_info_reply" | "comm_info_request" | "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" | "input_request" | "input_reply">> = new Signal<this, KernelMessage.IMessage>(this)

Private _isDisposed

_isDisposed: boolean = false

Private _isReady

_isReady: boolean = false

Private _kernelChanged

_kernelChanged: Signal<this, IKernelChangedArgs> = new Signal<this, Session.IKernelChangedArgs>(this)

Private _kernelPreference

_kernelPreference: IKernelPreference

Private _name

_name: string = ""

Private _path

_path: string = ""

Private _prevKernelName

_prevKernelName: string = ""

Private _propertyChanged

_propertyChanged: Signal<this, "path" | "name" | "type"> = new Signal<this, 'path' | 'name' | 'type'>(this)

Private _ready

_ready: PromiseDelegate<void> = new PromiseDelegate<void>()

Private _session

_session: ISession | null = null

Private _setBusy

_setBusy: function

Type declaration

    • (): IDisposable | undefined
    • Returns IDisposable | undefined

Private _statusChanged

_statusChanged: Signal<this, "unknown" | "starting" | "reconnecting" | "idle" | "busy" | "restarting" | "autorestarting" | "dead" | "connected"> = new Signal<this, Kernel.Status>(this)

Private _terminated

_terminated: Signal<this, void> = new Signal<this, void>(this)

Private _type

_type: string = ""

Private _unhandledMessage

_unhandledMessage: Signal<this, IMessage<"clear_output" | "comm_close" | "comm_msg" | "comm_open" | "display_data" | "error" | "execute_input" | "execute_result" | "status" | "stream" | "update_display_data" | "comm_info_reply" | "comm_info_request" | "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" | "input_request" | "input_reply">> = new Signal<this, KernelMessage.IMessage>(this)

manager

manager: IManager

The session manager used by the session.

Accessors

iopubMessage

  • get iopubMessage(): ISignal<this, IMessage>
  • A signal emitted for iopub kernel messages.

    Returns ISignal<this, IMessage>

isDisposed

  • get isDisposed(): boolean

isReady

  • get isReady(): boolean

kernel

  • get kernel(): IKernelConnection | null

kernelChanged

  • get kernelChanged(): ISignal<this, IKernelChangedArgs>
  • A signal emitted when the kernel changes.

    Returns ISignal<this, IKernelChangedArgs>

kernelDisplayName

  • get kernelDisplayName(): string

kernelPreference

name

  • get name(): string

path

  • get path(): string

propertyChanged

  • get propertyChanged(): ISignal<this, "path" | "name" | "type">
  • A signal emitted when a session property changes.

    Returns ISignal<this, "path" | "name" | "type">

ready

  • get ready(): Promise<void>
  • A promise that is fulfilled when the session is ready.

    Returns Promise<void>

status

  • get status(): Kernel.Status

statusChanged

  • get statusChanged(): ISignal<this, Kernel.Status>
  • A signal emitted when the status changes.

    Returns ISignal<this, Kernel.Status>

terminated

  • get terminated(): ISignal<this, void>
  • A signal emitted when the session is shut down.

    Returns ISignal<this, void>

type

  • get type(): string

unhandledMessage

  • get unhandledMessage(): ISignal<this, IMessage>
  • A signal emitted for an unhandled kernel message.

    Returns ISignal<this, IMessage>

Methods

Private _changeKernel

  • _changeKernel(options: Partial<IModel>): Promise<IKernelConnection>
  • Change the kernel.

    Parameters

    • options: Partial<IModel>

    Returns Promise<IKernelConnection>

Private _handleNewSession

  • _handleNewSession(session: ISession): IKernelConnection
  • Handle a new session object.

    Parameters

    • session: ISession

    Returns IKernelConnection

Private _handleSessionError

  • _handleSessionError(err: ResponseError): Promise<void>
  • Handle an error in session startup.

    Parameters

    • err: ResponseError

    Returns Promise<void>

Private _onIopubMessage

  • _onIopubMessage(sender: ISession, message: IIOPubMessage): void
  • Handle an iopub message.

    Parameters

    • sender: ISession
    • message: IIOPubMessage

    Returns void

Private _onKernelChanged

  • _onKernelChanged(sender: ISession, args: IKernelChangedArgs): void
  • Handle a change to the kernel.

    Parameters

    • sender: ISession
    • args: IKernelChangedArgs

    Returns void

Private _onPropertyChanged

  • _onPropertyChanged(sender: ISession, property: "path" | "name" | "type"): void
  • Handle a change to a session property.

    Parameters

    • sender: ISession
    • property: "path" | "name" | "type"

    Returns void

Private _onStatusChanged

  • _onStatusChanged(): void

Private _onTerminated

  • _onTerminated(): void

Private _onUnhandledMessage

  • _onUnhandledMessage(sender: ISession, message: IMessage): void
  • Handle an unhandled message.

    Parameters

    • sender: ISession
    • message: IMessage

    Returns void

Private _selectKernel

  • _selectKernel(cancelable: boolean): Promise<void>

Private _startIfNecessary

  • _startIfNecessary(): Promise<void>

Private _startSession

  • _startSession(model: Partial<IModel>): Promise<IKernelConnection>
  • Start a session and set up its signals.

    Parameters

    • model: Partial<IModel>

    Returns Promise<IKernelConnection>

changeKernel

  • changeKernel(options: Partial<IModel>): Promise<IKernelConnection>
  • Change the current kernel associated with the document.

    Parameters

    • options: Partial<IModel>

    Returns Promise<IKernelConnection>

dispose

  • dispose(): void

initialize

  • initialize(): Promise<void>
  • Initialize the session.

    Notes

    If a server session exists on the current path, we will connect to it. If preferences include disabling canStart or shouldStart, no server session will be started. If a kernel id is given, we attempt to start a session with that id. If a default kernel is available, we connect to it. Otherwise we ask the user to select a kernel.

    Returns Promise<void>

restart

  • restart(): Promise<boolean>
  • Restart the session.

    Returns Promise<boolean>

    A promise that resolves with whether the kernel has restarted.

    Notes

    If there is a running kernel, present a dialog. If there is no kernel, we start a kernel with the last run kernel name and resolves with true.

selectKernel

  • selectKernel(): Promise<void>

setName

  • setName(name: string): Promise<void>
  • Change the session name.

    Parameters

    • name: string

    Returns Promise<void>

setPath

  • setPath(path: string): Promise<void>
  • Change the session path.

    Parameters

    • path: string

      The new session path.

    Returns Promise<void>

    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.

setType

  • setType(type: string): Promise<void>
  • Change the session type.

    Parameters

    • type: string

    Returns Promise<void>

shutdown

  • shutdown(): Promise<void>
  • Kill the kernel and shutdown the session.

    Returns Promise<void>

    A promise that resolves when the session is shut down.

Static getDefaultKernel

Static populateKernelSelect

  • populateKernelSelect(node: HTMLSelectElement, options: IKernelSearch): void
  • Populate a kernel dropdown list.

    Parameters

    • node: HTMLSelectElement

      The node to populate.

    • options: IKernelSearch

      The options used to populate the kernels.

      Notes

      Populates the list with separated sections:

      • Kernels matching the preferred language (display names).
      • "None" signifying no kernel.
      • The remaining kernels.
      • Sessions matching the preferred language (file names).
      • The remaining sessions. If no preferred language is given or no kernels are found using the preferred language, the default kernel is used in the first section. Kernels are sorted by display name. Sessions display the base name of the file with an ellipsis overflow and a tooltip with the explicit session information.

    Returns void

Static restartKernel

  • restartKernel(kernel: IKernelConnection): Promise<boolean>
  • Restart a kernel if the user accepts the risk.

    Returns a promise resolving with whether the kernel was restarted.

    Parameters

    • kernel: IKernelConnection

    Returns Promise<boolean>

Generated using TypeDoc