Skip to content

Jupyter Notebook Activity Recorder

License

Notifications You must be signed in to change notification settings

tomokinakamaru/redspot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redspot

Usage

  1. Install Docker

  2. Launch Redspot

    docker run --rm -it -p8888:8888 -v$(pwd):/workdir ghcr.io/tomokinakamaru/redspot:latest
  3. Open the localhost URL displayed in the terminal

    ...
    [C 2024-01-01 00:00:00.000 ServerApp]
    ...
            http://localhost:8888/tree?token=... # ← This URL
            http://127.0.0.1:8888/tree?token=...
    ...
  4. Create a notebook and do anything you want

  5. Replay your work

    docker run --rm -it -v$(pwd):/workdir ghcr.io/tomokinakamaru/redspot:latest replay

Data schema

SQLite table

Name Type Nullable
time INTEGER NO
panel TEXT NO
kind TEXT NO
args JSON NO

JSON shapes in TypeScript type notation

See the external type definitions for the following types:

ISessionContext.sessionChanged

type ISessionContext_sessionChanged = {
  val: string | undefined;
}

INotebookModel.changed:cellsChange

type INotebookModel_changed__cellsChange = {
  delta: ({
    op: "insert";
    arg: {
      id: string;
      source: string;
      cell_type: string;
      metadata: Partial<IBaseCellMetadata>;
      execution_count: ExecutionCount | undefined;
      outputs: ({
        data: IMimeBundle;
        metadata: PartialJSONObject;
        output_type: "execute_result";
      } | {
        data: IMimeBundle;
        metadata: PartialJSONObject;
        output_type: "display_data";
      } | {
        name: StreamType;
        text: MultilineString;
        output_type: "stream";
      } | {
        ename: string;
        evalue: string;
        traceback: string[];
        output_type: "error";
      })[] | undefined;
    }[];
  } | {
    op: "delete";
    arg: number;
  } | {
    op: "retain";
    arg: number;
  })[];
}

INotebookModel.changed:nbformatChanged

type INotebookModel_changed__nbformatChanged = {
  key: string;
  val: number | undefined;
}

INotebookModel.changed:metadataChange

type INotebookModel_changed__metadataChange = {
  delta: {
    key: string;
    act: "delete" | "add" | "update";
    val: any;
  }[];
}

ISharedCell.changed:attachmentsChange

type ISharedCell_changed__attachmentsChange = {
  cell: string;
  val: IAttachments | undefined;
}

ISharedCell.changed:executionCountChange

type ISharedCell_changed__executionCountChange = {
  cell: string;
  val: number | undefined;
}

ISharedCell.changed:outputsChange

type ISharedCell_changed__outputsChange = {
  cell: string;
  delta: ({
    op: "insert";
    arg: ({
      data: IMimeBundle;
      metadata: PartialJSONObject;
      output_type: "execute_result";
    } | {
      data: IMimeBundle;
      metadata: PartialJSONObject;
      output_type: "display_data";
    } | {
      name: StreamType;
      text: MultilineString;
      output_type: "stream";
    } | {
      ename: string;
      evalue: string;
      traceback: string[];
      output_type: "error";
    })[];
  } | {
    op: "delete";
    arg: number;
  } | {
    op: "retain";
    arg: number;
  })[];
}

ISharedCell.changed:sourceChange

type ISharedCell_changed__sourceChange = {
  cell: string;
  delta: ({
    op: "insert";
    arg: string;
  } | {
    op: "delete";
    arg: number;
  } | {
    op: "retain";
    arg: number;
  })[];
}

ISharedCell.changed:metadataChange

type ISharedCell_changed__metadataChange = {
  cell: string;
  delta: {
    key: string;
    act: "delete" | "add" | "update";
    val: any;
  }[];
}

Development

  1. Install Docker
  2. Open this repository using a dev container
  3. Run pdm sync to setup the environment
  4. Run sh kernel-install.sh to install the default kernel
  5. Run source .venv/bin/activate to activate the virtual environment

Build frontend extension

jlpm build

Run linters

pdm run lint
pdm run fix # Fix lint issues

Run tests

jlpm playwright install --with-deps chromium # Install dependencies
pdm run test

Run GitHub actions

# Run this command outside the dev container
act --job check --matrix python-version:3.12

Build wheel

pdm build --no-sdist

Update schema documentation

# Paste command outputs to this README
python schema-table.py
jlpm run ts-node schema-json.ts

Upgrade dependencies

Upgrade pdm-managed dependencies

pdm update --unconstrained

Upgrade jlpm-managed dependencies

jlpm plugin import @yarnpkg/plugin-interactive-tools
jlpm upgrade-interactive
jlpm plugin remove @yarnpkg/plugin-interactive-tools

Upgrade default kernel dependencies

sh kernel-upgrade.sh

Upgrade Docker image dependencies

Check the URLs listed in Dockerfile