refactor(gui): tool registry + components package for per-tool builds
Two low-risk seam moves to enable selling per-tool subsets without
breaking the existing all-in-one bundle. Behaviour identical; every
existing import still resolves; full pytest suite + every page returns
HTTP 200.
1. **Tool registry** (src/gui/tools_registry.py) — replaces the
inline dict-of-dicts in app.py with a Tool dataclass and a TOOLS
list. Adds a tier field ("core" today, "pro" / "enterprise" later)
and tools_for_tier() / tool_by_id() / display_name() helpers. A
per-tool build slices TOOLS at import time without code changes.
2. **components package** (src/gui/components/) — converts the former
single components.py into a package with:
_legacy.py — original file, unchanged.
__init__.py — re-exports the legacy surface; existing
"from src.gui.components import …" calls
continue to work.
shared.py — hide_streamlit_chrome, pickup_or_upload
(every build needs these).
gate.py — require_normalization_gate (Pro / Suite SKUs).
findings.py — analyzer-finding widgets (drops out of a
standalone-Dedup build).
dedup_review.py — match-group cards + apply pipeline (drops out
of a non-dedup build).
The seam modules are narrow re-exports today. As code migrates out
of _legacy.py into the focused modules, the public import path
stays stable via the shim.
E2E: 765 passed, 17 xfailed (unchanged); home page + all 9 tool pages
+ Review page render HTTP 200; full pipeline (analyze → auto_fix →
apply_decisions → output bytes) round-trips on the kitchen-sink
fixture with zero high-confidence findings remaining post-fix.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
57
src/gui/components/__init__.py
Normal file
57
src/gui/components/__init__.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""Reusable Streamlit widgets for the DataTools GUI.
|
||||
|
||||
This package replaces the former single ``components.py`` module. Public
|
||||
behaviour is identical — every name that used to be importable from
|
||||
``src.gui.components`` is still importable from the same path because
|
||||
this ``__init__`` re-exports the legacy surface in full.
|
||||
|
||||
The package layout exists so per-tool builds can ship only the seams
|
||||
they need without dragging the entire kitchen-sink module:
|
||||
|
||||
components/
|
||||
__init__.py ← compatibility shim (this file)
|
||||
_legacy.py ← original components.py, unchanged
|
||||
gate.py ← gate-only seam (require_normalization_gate)
|
||||
findings.py ← analyzer-finding rendering seam
|
||||
dedup_review.py ← dedup match-group cards + review pipeline
|
||||
shared.py ← chrome / file-pickup helpers used by every tool
|
||||
|
||||
A standalone Deduplicator build, for example, can ship without
|
||||
``findings.py`` and ``gate.py`` — those modules import the analyzer /
|
||||
gate code that the Lite SKU does not include.
|
||||
|
||||
Adding new tooling: drop new helpers into the appropriate seam module.
|
||||
Add their names to its ``__all__`` and to this file's ``__all__`` if
|
||||
they should remain importable from ``src.gui.components`` directly.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# Re-export the full legacy surface so existing pages continue to
|
||||
# import unchanged. Once individual tool packages start consuming
|
||||
# the focused seam modules directly, names can migrate out of
|
||||
# _legacy.py without breaking those imports — this shim is what
|
||||
# absorbs the move.
|
||||
from ._legacy import * # noqa: F401,F403
|
||||
from . import _legacy as _legacy # noqa: F401 (keep for direct access)
|
||||
|
||||
# Names exported from _legacy.py that pages currently use. Kept here as
|
||||
# the canonical public list so a removal from _legacy is a visible
|
||||
# breaking change instead of a silent drop.
|
||||
__all__ = [
|
||||
# Shared chrome / pickup / gate
|
||||
"hide_streamlit_chrome",
|
||||
"pickup_or_upload",
|
||||
"require_normalization_gate",
|
||||
# Dedup widgets
|
||||
"config_panel",
|
||||
"match_group_card",
|
||||
"results_summary",
|
||||
"apply_review_decisions",
|
||||
# Analyzer widgets
|
||||
"tool_display_name",
|
||||
"render_findings_panel",
|
||||
"render_hidden_aware_preview",
|
||||
"upload_and_analyze_section",
|
||||
"findings_count_for_tool",
|
||||
]
|
||||
Reference in New Issue
Block a user