Skip to content

lunartrace.workbench.presets

Preset research operations: real Python the researcher can read, run and edit.

Each preset is the body of one marimo cell. Cells share the names defined by the Lab setup cell: mo, np, sq (slope_quality), wroi (workbench ROI API), figures, site, ring and taus. “Show Python” displays exactly these bodies; nothing here is pseudocode.

class

Preset

One researcher-facing analysis preset.

NameTypeDescription
idstrStable key used by the Lab request (for example "roi-rows").
titlestrShort menu label.
summarystrOne-sentence description shown beside the title.
codestrPython source of one marimo cell body, executed verbatim in the Lab.
def as_json(self) -> dict[str, str]

Serialise the preset for the GET /presets response.

  • dict of str to str — Keys id, title, summary and code.

attribute

SETUP

Setup cell body; MANIFEST and STORE are placeholders bound by setup_with_paths.

RING and TAUS stay free names that the caller defines in the notebook.

function

def setup_with_paths(manifest: Path, store: Path) -> str

Bind the manifest and store paths into the setup cell.

NameTypeDescription
manifestpathlib.PathSite source manifest path; stored as a POSIX string literal.
storepathlib.PathSource store root; stored as a POSIX string literal.
  • str — SETUP with the placeholders replaced, so a downloaded script and the Lab notebook load the same Site.

RING and TAUS are left as names for the caller to define.

attribute

STEEP_FOLLOWUP

Follow-up cell appended after the steep-share preset; it reads the slider it defines.

function

def preset(preset_id: str) -> Preset

Look up a preset by its id.

NameTypeDescription
preset_idstrId of a member of PRESETS.
  • Preset — The matching preset.
  • KeyError — If no preset has this id.

function

def cells_for(preset_ids: list[str]) -> list[str]

Return the marimo cell bodies for the chosen presets, in order.

NameTypeDescription
preset_idslist of strPreset ids in the order they should appear in the notebook.
  • list of str — One code body per preset, plus STEEP_FOLLOWUP immediately after "steep-share".
  • KeyError — If any id is not a known preset.