Options
All
  • Public
  • Public/Protected
  • All
Menu

Package rx-jupyter

rx-jupyter

This package is a ReactiveX wrapper around the Jupyter Server API. rx-jupyter can help you query local and remote Jupyter Server instances using Jupyter's Services APIs. Also, rx-jupyter integrates responses seamlessly with RxJS's functional tooling.

Roadmap

Primary coverage of the [Jupyter Server API]:

  • Contents
    • Checkpoints
  • Kernels
  • Kernelspecs
  • Sessions
  • Terminals

Optional coverage:

  • Config
  • nbconvert
  • spec.yaml /api/spec.yaml

Installation

$ yarn add rx-jupyter
$ npm install --save rx-jupyter

Usage

The example below shows how we can use this package to get the version of the Jupyter server API our endpoint is running.

import jupyter from "rx-jupyter";
import { of } from "rxjs";
import { mergeMap, catchError } from "rxjs/operators";

const apiVersion = jupyter.apiVersion({ endpoint: "https://myjupyterendpoint.com", crossDomain: true }); apiVersion.pipe( mergeMap(apiVersion => of(apiVersionFulfilled({ apiVersion }))), catchError(error => of(apiVersionFailed({ error }))) );

Documentation

You can view the reference documentation for rx-jupyter in the package docs.

Support

If you experience an issue while using this package or have a feature request, please file an issue on the issue board and add the pkg:rx-jupyter label.

License

BSD-3-Clause

Index

Type aliases

FileType

FileType: "directory" | "file" | "notebook"

Functions

Const apiVersion

  • apiVersion(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Get the version of the API for a given server.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable containing the API version information

Const connect

  • connect(serverConfig: ServerConfig, kernelID: string, sessionID?: string): Subject<any>
  • Creates a connection to a kernel with the given kernelID scoped under a particular sessionID.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • kernelID: string

      The ID of the kernel to connect to

    • Optional sessionID: string

      The ID of the session to connect as

    Returns Subject<any>

    A websocket Subject that can be subscribed to

create

  • create<FT>(serverConfig: ServerConfig, path: string, model: Partial<IContent<FT>> & object): Observable<AjaxResponse>
  • Creates an AjaxObservable for creating content

    Type parameters

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The path to the content

    • model: Partial<IContent<FT>> & object

      The data to send in the server request

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const create

  • create(serverConfig: ServerConfig, body: object): Observable<AjaxResponse>
  • Creates an AjaxObservable for getting a particular session's information.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • body: object

      Payload containing kernel name, kernel_id, session name, and path for creation of a new session.

    Returns Observable<AjaxResponse>

    An Observable with the request/response

Const create

  • create(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Create a terminal session.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const createAJAXSettings

  • createAJAXSettings(serverConfig: ServerConfig, uri?: string, opts?: Partial<AjaxRequest & object>): AjaxRequest
  • Creates an AJAX request to connect to a given server. This function handles setting the authorization tokens on the request.

    Parameters

    • serverConfig: ServerConfig

      Details about the server to connect to.

    • Default value uri: string = "/"

      The URL to connect to, not including the base URL

    • Default value opts: Partial<AjaxRequest & object> = {}

      A set of options to pass to the AJAX request. We mimic jquery.ajax support of a cache option here.

    Returns AjaxRequest

    A fully-configured AJAX request for connecting to the server.

Const createCheckpoint

  • createCheckpoint(serverConfig: ServerConfig, path: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for creating a new checkpoint with the current state of a file. With the default Jupyter FileContentsManager, only one checkpoint is supported, so creating new checkpoints clobbers existing ones.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content containing the checkpoint to be created

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const deleteCheckpoint

  • deleteCheckpoint(serverConfig: ServerConfig, path: string, checkpointID: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for deleting a checkpoint for a given file.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content containing the checkpoint to be deleted

    • checkpointID: string

      ID of checkpoint to be deleted

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const destroy

  • destroy(serverConfig: ServerConfig, sessionID: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for destroying a particular session.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • sessionID: string

      Unique id for session to be requested

    Returns Observable<AjaxResponse>

    An Observable with the request/response

Const destroy

  • destroy(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Delete a running terminal session.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      ID of the terminal to be fetched

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const formCheckpointURI

  • formCheckpointURI(path: string, checkpointID: string): any

Const formURI

  • formURI(path: string): any

Const formURI

  • formURI(path: string): any

Const formURI

  • formURI(path: string): any

Const formWebSocketURL

  • formWebSocketURL(serverConfig: ServerConfig, kernelID: string, sessionID?: string): string
  • Creates a Websocket URL that can be used to initialize a connection with a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • kernelID: string

      The ID of the kernel to connect to

    • Optional sessionID: string

      The ID of the session to connect as

    Returns string

    A string with the fully formed Websocket URL

Const formWebSocketURL

  • formWebSocketURL(serverConfig: ServerConfig, id: string): string
  • Given a server configuration and a terminal ID, this function generates a Websocket URL that can be used

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      ID of the terminal to be fetched

    Returns string

    A websocket URL for connecting to a terminal

get

  • Creates an AjaxObservable for getting content at a path

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content to fetch

    • Default value params: Partial<IGetParams> = {}

      type, format, content

    Returns Observable<JupyterAjaxResponse<IContent<"directory" | "file" | "notebook">, string>>

    An Observable with the request response

Const get

  • get(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for getting info about a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      The id of the kernel to fetch

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const get

  • get(serverConfig: ServerConfig, name: string): Observable<AjaxResponse>
  • Returns the specification of available kernels with the given kernel name.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • name: string

      The name of the kernel

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const get

  • get(serverConfig: ServerConfig, sessionID: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for getting a particular session's information.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • sessionID: string

      Universally unique id for session to be requested

    Returns Observable<AjaxResponse>

    An Observable with the request/response

Const get

  • get(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Fetch a terminal session.

    Parameters

    • serverConfig: ServerConfig

      The server configuration.

    • id: string

      ID of the terminal to be fetched.

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const interrupt

  • interrupt(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for interrupting a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      The id of the kernel to interrupt

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const kill

  • kill(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for killing a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      The id of the kernel to kill

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const list

  • list(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Creates an AjaxObservable for listing running kernels.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const list

  • list(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Creates an AjaxObservable for listing available kernelspecs.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const list

  • list(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Creates an AjaxObservable for listing available sessions.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const list

  • list(serverConfig: ServerConfig): Observable<AjaxResponse>
  • List all available running terminals.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const listCheckpoints

  • listCheckpoints(serverConfig: ServerConfig, path: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for listing checkpoints for a given file.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content containing checkpoints to be listed.

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const normalizeBaseURL

  • normalizeBaseURL(url?: string): string

publish

  • publish(serverConfig: ServerConfig, path: string, model: BookstoreDataModel): Observable<AjaxResponse>
  • Creates an AjaxObservable for publishing content to Bookstore https://github.com/nteract/bookstore

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The path to the content

    • model: BookstoreDataModel

      The data to send in the server request

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const remove

  • remove(serverConfig: ServerConfig, path: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for removing content.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The path to the content

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const restart

  • restart(serverConfig: ServerConfig, id: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for restarting a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • id: string

      The id of the kernel to restart

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const restoreFromCheckpoint

  • restoreFromCheckpoint(serverConfig: ServerConfig, path: string, checkpointID: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for restoring a file to a specified checkpoint.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content to restore to a previous checkpoint

    • checkpointID: string

      ID of checkpoint to be used for restoration

    Returns Observable<AjaxResponse>

    An Observable with the request response

save

  • Creates an AjaxObservable for saving the file in the location specified by name and path in the model.

    Type parameters

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The path to the content

    • model: Partial<IContent<FT>>

      The data to send in the server request

    Returns Observable<JupyterAjaxResponse<object, string>>

    An Observable with the request response

Const shutdown

  • shutdown(serverConfig: ServerConfig): Observable<AjaxResponse>
  • Creates an AjaxObservable for shutting down a notebook server.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    Returns Observable<AjaxResponse>

    An Observable with the request/response

Const start

  • start(serverConfig: ServerConfig, name: string, path: string): Observable<AjaxResponse>
  • Creates an AjaxObservable for starting a kernel.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • name: string

      The name of the kernel to start

    • path: string

      The path to start the kernel in

    Returns Observable<AjaxResponse>

    An Observable with the request response

update

  • update<FT>(serverConfig: ServerConfig, path: string, model: Partial<IContent>): Observable<AjaxResponse>
  • Creates an AjaxObservable for renaming a file.

    Type parameters

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • path: string

      The content to rename.

    • model: Partial<IContent>

      The data to send in the server request

    Returns Observable<AjaxResponse>

    An Observable with the request response

Const update

  • update(serverConfig: ServerConfig, sessionID: string, body: object): Observable<AjaxResponse>
  • Creates an AjaxObservable for updating a session.

    Parameters

    • serverConfig: ServerConfig

      The server configuration

    • sessionID: string

      Unique identifier for session to be changed

    • body: object

      Payload containing new kernel_name, new kernel_id, name of the new session, and the new path.

    Returns Observable<AjaxResponse>

    An Observable with the request/response

Generated using TypeDoc