Skip to main content

Module notebook_runner

Module notebook_runner 

Source
Expand description

Notebook cell execution backend for POST /api/v1/notebooks/{notebook_id}/{cell_id}/run.

The Python reference at /tmp/cognee-python/cognee/modules/notebooks/operations/run_in_local_sandbox.py uses in-process exec() and captures print() calls into a list. Running arbitrary user code in-process in Rust would be a remote-code-execution gun, so this module instead spawns an isolated python3 subprocess and captures stdout/stderr, then enforces wall-clock, memory, and output-size caps.

Trait shape: a single async NotebookRunner::run_cell returning a RunCellOutcome. Production wiring uses SubprocessRunner; tests that don’t want to spawn Python plug in a mock runner.

Structs§

RunCellOutcome
Wire-shape outcome of running a single cell.
SubprocessRunner
Production runner: spawns python3 -c '<wrapper>' and feeds the user’s code via stdin.

Enums§

RunnerError
Errors that can surface from a NotebookRunner implementation.

Traits§

NotebookRunner
Abstract code-execution backend.