scitex_todo — Python API
scitex-todo: a canonical YAML task store with pluggable adapters.
The task store (YAML, top-level tasks: list) is the single source of
truth. Adapters render or import it; the mermaid adapter (YAML -> dependency
PNG) ships today. See the project roadmap for org and Web-UI adapters.
Quick Start
>>> import scitex_todo as todo
>>> tasks = todo.load_tasks("tasks.yaml")
>>> src = todo.build_mermaid(tasks)
>>> todo.render(src, "tasks.png")
'mmdc'
- exception scitex_todo.TaskValidationError[source]
Bases:
ValueErrorRaised when a task store fails structural validation.
- exception scitex_todo.RenderError[source]
Bases:
RuntimeErrorRaised when every render path (mmdc, kroki) fails.
- scitex_todo.build_mermaid(tasks)[source]
Render the task list as a mermaid
flowchart TBsource string.- Parameters:
tasks (
list[dict]) – Validated tasks, typically fromscitex_todo.load_tasks().- Returns:
Mermaid
flowchart TBsource, newline-terminated. Includes node labels,depends_onandblocksedges, and per-statusclassDefstyling.- Return type:
Notes
Edges referencing an unknown task id are skipped with a warning on stderr rather than raising — a partial graph is more useful than none.
Examples
>>> src = build_mermaid([{"id": "a", "title": "A", "status": "done"}]) >>> src.startswith("flowchart TB") True
- scitex_todo.bundled_example()[source]
Path to the generic example task store shipped inside the wheel.
- Return type:
- scitex_todo.find_chromium()[source]
Locate a puppeteer- or playwright-cached chromium for headless render.
Resolution order:
$PUPPETEER_EXECUTABLE_PATH, then the puppeteer cache, then the playwright cache. Snap chromium is excluded.
- scitex_todo.load_tasks(path)[source]
Load and validate the task list from a YAML store.
- Parameters:
path (
str|Path) – Path to the YAML task store. The document must have a top-leveltasks:list.- Returns:
The validated task mappings, in document order.
- Return type:
- Raises:
FileNotFoundError – If
pathdoes not exist.TaskValidationError – If the store is structurally invalid:
tasksis not a list, a task is missingidortitle, anidis duplicated, astatusis not inVALID_STATUSES, or apriorityis present but not an integer.
Examples
>>> tasks = load_tasks("tasks.yaml") >>> tasks[0]["id"] 'design'
- scitex_todo.save_tasks(tasks, path)[source]
Validate then write a task list back to a YAML store, preserving comments.
Re-runs the same validation gate as
load_tasks()before touching disk, so a malformed mutation can never corrupt the store. Usesruamel.yamlround-trip mode so hand-written comments and key layout in the existing store survive the rewrite.- Parameters:
- Raises:
TaskValidationError – If
tasksfails structural validation (nothing is written).- Return type:
Examples
>>> tasks = load_tasks("tasks.yaml") >>> tasks[0]["priority"] = 1 >>> save_tasks(tasks, "tasks.yaml")
- scitex_todo.render(mermaid_src, out_png)[source]
Render mermaid source to PNG, mmdc-first with kroki fallback.
- Parameters:
mermaid_src (
str) – Mermaid source, typically fromscitex_todo.build_mermaid().out_png (
str|Path) – Destination PNG path. Parent directories are created if missing.
- Returns:
The engine that produced the output:
"mmdc"or"kroki".- Return type:
- Raises:
RenderError – If both the mmdc and kroki render paths fail.
- scitex_todo.render_with_kroki(mermaid_src, out_png)[source]
Fallback: render via kroki.io.
- Returns:
Trueon success,Falseon any network/HTTP failure.- Return type:
- scitex_todo.render_with_mmdc(mermaid_src, out_png)[source]
Render via mermaid-cli.
- Returns:
Trueon success,Falseto allow the caller to fall back.- Return type:
- scitex_todo.resolve_tasks_path(explicit=None)[source]
Resolve which task store to use, following the precedence chain.
- Parameters:
explicit (
str|Path|None) – An explicit path (e.g. a CLI--tasksflag). When given and it exists, it wins outright.- Returns:
The first existing task store in precedence order. Falls back to the bundled generic example if no personal store is found.
- Return type:
Examples
>>> p = resolve_tasks_path() >>> p.name 'tasks.yaml'