Skip to content

An event system for Jupyter #780

@afshin

Description

@afshin

This is a draft document, please feel free to comment and help.

We have (at least) two concurrent efforts that overlap but are not full implementations of a generic event system for Jupyter in themselves: jupyter-telemetry and jupyterlab-notifications.

A synthesis of these extensions with generic endpoints (i.e., not specifically designed and named for telemetry or notifications) would yield a flexible general-purpose event bus for jupyter-server-based applications.

cc: @andrii-i @3coins

Architecture of events API

REST Endpoints

  • POST /api/events - create new events
  • GET /api/events/schemas - query/list registered schemas
    (maybe -- needs discussion)
  • POST /api/events/schemas - register schemas
    (maybe -- needs discussion)

WebSocket endpoints (WebsocketHandler)

  • /api/events/subscribe - fire hose of all events -- perhaps accept filters? (see open question below)
  • /api/events/subscribe/notification -- subscribe to events of type notification

Open Question: Should the WebSocket handler support making a request for multiple filters to be applied instead of just the one proposed in the URL scheme above?

Depends on jupyter_events package

  • exports EventLogger object in (formerly EventLog in jupyter_telemetry)

Case Study: JupyterLab Notifications

Server-side functionality

  • Subscribes to all notification events that pass through the event bus
  • Adds each notification as a row in a SQLite database on the server with a key for the recipient identity as well as an ID
    • notification events with multiple recipients can be de-normalized here and written as multiple rows
  • REST API

    • GET /api/notifications - retrieve a list of all notifications that authenticated user can see
    • GET /api/notifications/{ID} - retrieve a specific notification
    • DELETE /api/notifications/{ID} - delete a specific notification

Client-side functionality

  • Subscribe to the /api/events/notifications WebSocket
    • Throttle its incoming messages at some reasonable rate (on the order of 0.5-1 seconds)
  • Treat incoming messages from the events API as a notifier only -- check the /api/notifications endpoint for the actual list of messages
  • Render the badge and the notification center UI inside JupyterLab/Notebook

JupyterLab 4 extension

  • A Token (e.g., INotifications or IEvents) that exposes an IDataConnector for event CRUD and an ISignal for event subscription
  • A visual UI for an event notification center

Jupyter Notebook 7 extension

  • The Token from the JupyterLab extension
  • A version of the JupyterLab UI for notifications

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions