fix(vis): custom __repr__ overlays lazy state on field section (closes mat#221)#232
Merged
Conversation
…s mat#221)
Bernhard's mat-vis#311 'Inconsistent outputs' sub-bullet: after
``v.textures`` triggers a fetch, ``repr(v)`` still shows every PBR
field as ``None`` — no signal anything happened. The dataclass
auto-repr is technically truthful (those fields are the *override*
channel; user hasn't overridden them), but it leaves Bernhard
debugging from a half-truth.
Pythonic fix: keep two namespaces, two purposes — don't conflate
overrides with resolved state. The dataclass field section keeps its
override-channel semantics; ``__repr__`` appends a lazy-state suffix
so both perspectives are legible at a glance.
Pre-fetch::
Vis(source='gpuopen', material_id='Aluminum Brushed', tier='1k',
finishes={}, roughness=None, metallic=None, ..., fetched=False)
Post-fetch (catalog-backed)::
Vis(source='gpuopen', material_id='Aluminum Brushed', tier='1k',
finishes={}, roughness=None, metallic=None, ..., fetched=True,
scalars={'metalness': 1.0, 'roughness': 0.4, 'color_hex': '#cccccc', 'ior': 1.5},
available_textures=['color', 'normal', 'roughness'])
Post-fetch with caller override (``v.metallic = 0.7``)::
Vis(source='gpuopen', material_id='Aluminum Brushed', tier='1k',
finishes={}, roughness=None, metallic=0.7, ..., fetched=True,
scalars={'metalness': 0.7, 'roughness': 0.4, ...}, ← override won
available_textures=['color', 'normal', 'roughness'])
Field section reflects what *the user* set (None = no override).
``scalars=`` reflects what will actually render (catalog merged with
overrides — same view as ``Vis.scalars``). Both visible without
inverting either's meaning.
Implementation notes:
- Touches ``self.scalars`` only when ``_fetched=True`` so an
unfetched repr doesn't trip catalog index loads.
- Honors ``field(repr=False)`` on private cache slots (``_textures``,
``_fetched``, ``_finish``).
- 3 strict-xfail tests in ``TestIssue221ReprObservability`` flip to
passing — xfail markers dropped.
1fd47d4 to
da39df8
Compare
7 tasks
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
Closes mat#221 — Bernhard's mat-vis#311 'Inconsistent outputs' sub-bullet. After
v.texturestriggers a fetch,repr(v)still showed every PBR field asNone— no signal anything happened, even though the catalog data was loaded.Pythonic decision: two namespaces, two purposes
The dataclass auto-repr was technically truthful (those fields are the override channel — user hadn't set them) but visually misleading. Two ways to fix:
_overridden: set[str]to disambiguate, breaksreplace/ equality / pickle semantics, conflates inputs with outputs__repr__overlaying lazy statescalars=andavailable_textures=surface the resolved/cached view. Two clearly separate sections, no provenance ambiguityWe took the second. Same separation already pioneered by
Vis.scalars(the public sparse view from the dispatch refactor): dataclass fields = caller overrides; property accessors = computed/resolved.Output shape
Pre-fetch:
Post-fetch (catalog-backed):
Post-fetch with caller override (
v.metallic = 0.7):Implementation notes
self.scalars(catalog dict lookup) only when_fetched=True— unfetched repr stays cheap, no index IO triggered byprint(v)or debugger inspection.field(repr=False)on private cache slots (_textures,_fetched,_finish) — same fields excluded as the auto-repr.Vis, drops xfail decorator on 3 tests.Test plan
TestIssue221ReprObservabilityxfails flip to passingtest_repr_does_not_leak_private_path(the existing repr contract test) still passes — class name + module unchangedOut of scope
Bernhard's remaining mat-vis#280-rooted error annotation gaps in
test_error_messages.py(5 xfails) — separate concern, separate PR.Refs mat#221, Bernhard's mat-vis#311