Skip to content

refactor: Refactor builder registry - #276

Open
OCopping wants to merge 5 commits into
mainfrom
refactor-builder-registry
Open

OCopping wants to merge 5 commits into
mainfrom
refactor-builder-registry

Conversation

@OCopping

@OCopping OCopping commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refactors the entity registry from root-PV-keyed to full-PV-keyed, enabling both direct lookups (e.g. BL19I-MO-DCM-01:BRAGG → single motor) and root-prefix lookups (e.g. BL19I-MO-DCM-01 → all motors) through a single helper method.

This supports a stripped-down techui.yaml where only custom components need explicit entries, while simple components are auto-discovered by root PV.

Changes

  • models.py — Added Entity.base_prefix computed property
  • builder.py — entities changed from defaultdict[str, list[Entity]] → dict[str, Entity]; new get_entities_for_prefix() helper that collects from exact match + root-prefix children; create_screens() updated to use it
  • tests/ — Updated entity lookups for the new dict structure; added builder_with_entities fixture and 4 tests covering single match, root+children, no-match, and root-without-root-entity

…eModel for the screen dict in techui-support yaml entities
Also added new 'base_prefix' computed value for Entity to just return
the PV prefix without any colons or suffixes
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.08197% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.27%. Comparing base (2dd3dc6) to head (5f7aa91).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/techui_builder/generate.py 91.30% 2 Missing ⚠️
src/techui_builder/builder.py 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
- Coverage   96.55%   96.27%   -0.29%     
==========================================
  Files          17       17              
  Lines        1075     1101      +26     
==========================================
+ Hits         1038     1060      +22     
- Misses         37       41       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OCopping
OCopping requested review from adedamola-sode, niamhdougan and tomkane-dls and removed request for adedamola-sode September 29, 2026 15:06
@OCopping OCopping changed the title feat: Refactor builder registry refactor: Refactor builder registry Sep 30, 2026
@OCopping
OCopping requested a balanced review from Copilot October 2, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Screen labels leak between mappings, and existing suffixes support mappings lose their overrides.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Refactors entity lookup to use full PV keys while supporting root-prefix discovery.

Changes:

  • Adds full-PV entity registration and prefix lookup.
  • Introduces typed support-screen mappings.
  • Updates generator behavior and tests.
File Description
src/​techui_builder/​builder.py Refactors entity storage and lookup.
src/​techui_builder/​models.py Adds base prefixes and typed screen models.
src/​techui_builder/​generate.py Uses typed screen mappings and macro overrides.
src/​techui_builder/​utils.py Defines public module exports.
tests/​conftest.py Updates fixtures for new models.
tests/​test_builder.py Tests full and root-prefix lookups.
tests/​test_generate.py Updates typed screen access.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/techui_builder/generate.py Outdated
Comment on lines +322 to +323
screen_macros: Annotated[
dict[str, str] | None,
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
.removesuffix(":")
)
component.macros["label"] = component_name
if not self.label_flag:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already in the previous PR that was approved and merged, is this branched from that?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants