Phase 6: local Streamlit UI for the toolkit#6
Merged
Merged
Conversation
Wraps the existing CLI pipeline (tray capture, train, eval, predict, settings) in a Streamlit + Plotly app a non-technical user can drive end-to-end. Highlights - New `ui` optional-deps group (streamlit + plotly); `almendra ui` CLI subcommand + `make ui` shortcut. - Six pages behind a sidebar radio: Home (dataset stats + recent runs + inline wizard), Tray Capture, Train, Evaluate, Predict, Settings. - Bilingual ES/EN from day one — every string lives in a central dict; toggling languages takes one click. Default: Spanish. - Live training charts — `train.loop` writes one JSONL line per epoch to `outputs/<run>/live_metrics.jsonl` (env-var `ALMENDRA_LIVE_METRICS` lets the UI redirect it). The Train page launches training as a subprocess and tails the file every ~2 s into a two-line Plotly chart. - Inline wizard on Home walks Ingest → Train → Eval with sensible defaults; advanced controls (gated fusion, view-dropout, augmentation) live behind an Advanced expander on the Train page. - Stateless across reruns — runs, checkpoints, ONNX files and metrics are all discovered from disk. Any process that writes the same JSONL schema works with the UI. Tests - AppTest smoke-renders every page in ES and EN (12 cases) without exceptions. - i18n dictionary checked for complete bilingual coverage. - Unit tests for the live-metrics JSONL writer/reader file protocol. - All 45 tests in the suites that don't require torch/onnxruntime pass; ruff + ruff format clean. Closes #5 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Without streamlit installed, test_ui_smoke.py was being skipped via pytest.importorskip — the page render tests never ran in CI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A dedicated docs/ui.md walks through install, launch, the full E2E test flow through the six pages, a sanity-check list, and the common troubleshooting paths. README links to it from the Quickstart. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…s → views - Add two screenshots (`docs/images/ui-home.png`, `ui-train.png`) so the README shows what the app actually looks like. - Inline launch instructions, the per-extra unlock table, the six-page tour, and a 5-minute end-to-end walkthrough into the README itself (docs/ui.md stays as the deeper troubleshooting guide). - Rename `src/almendra/ui/pages/` → `src/almendra/ui/views/` so Streamlit does not auto-discover the directory as its multi-page navigation system and shadow our custom sidebar radio. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps the existing CLI pipeline in a local Streamlit + Plotly app a non-technical user can run end-to-end: prepare data (tray capture + visual cropping), train models with real-time charts, evaluate, predict on a single bean, and view settings.
Closes #5.
What's in
uioptional-deps group (streamlit + plotly),almendra uiCLI subcommand,make uiMakefile target.data/raw/proprietary_tray/sessions/<id>/.train_loss+val_macro_f1tailingoutputs/<run>/live_metrics.jsonl. Advanced controls (gated fusion, view-dropout, augmentation) behind an expander.ui/components/i18n.py. Sidebar radio toggles between languages. Default: Spanish.train.loopnow writes one JSONL line per epoch to a metrics file. Controlled by theALMENDRA_LIVE_METRICSenv var, so the CLI use case is untouched.outputs/. Anything that writes the same JSONL schema interoperates.Decisions locked (from issue #5)
Test plan
streamlit.testing.v1.AppTestsmoke-renders all 6 pages in ES and EN (12 cases) without exceptions.ruff check+ruff format --checkclean.Notes for review
cmd_uidefers thestreamlitimport until the subcommand is invoked, so the CLI still works without theuiextra installed.use_container_width=True(Streamlit's modern replacement for the deprecateduse_column_width).v2 (Phase 6.1) — out of scope here
🤖 Generated with Claude Code