Repository navigation
test(substrate): pin Bernhard's open mat-vis repros as strict xfails - #219
Merged
Merged
Conversation
Adds tests/test_substrate_repros.py with three literal repros from
the open mat-vis upstream issues Bernhard flagged in build123d#1270:
* TestMatVis285_GpuopenBakingScalars: two distinct gpuopen metals
must NOT both return the baker-default scalars (metalness=0.0,
roughness=0.5, color=0xCCCCCC). Catches the symptom where every
gpuopen material renders as flat grey plastic.
* TestMatVis311_MaterialNames: client.materials('gpuopen', '1k')
must not return bare UUIDs — users select by webpage names.
* TestMatVis313_PhysicallybasedAccess: Vis('physicallybased',
'Aluminum').to_threejs() must not raise MaterialNotStagedError.
Each test is a strict xfail today (the bugs are open upstream); when
mat-vis-client ships the fixes and py-mat picks up the new dep
version, the tests XPASS and the strict marker prompts dropping the
xfail.
Closes the verification gap the build123d#1270 thread surfaced:
running py-mat's own test suite or Bernhard's integration tests
passed cleanly even while these substrate paths were broken. The
literal repro snippets from filed issues are the cheapest way to
catch this class of 'unasserted contract on a covered codepath'.
Network-dependent — skip with MAT_VIS_SKIP_LIVE=1 (mirrors the
test_e2e_vis.py convention). Transient CDN failures turn into
pytest.skip via _skip_on_upstream_outage.
#312 (download progress) deliberately omitted: testing progress-
callback behavior requires callback-capture infrastructure that
doesn't exist on either side yet.
3 tasks done
gerchowl
added a commit
that referenced
this pull request
May 7, 2026
* test(vis): pin Bernhard's pymat-surface repros for #220/#221/#222 as strict xfails Adds tests/test_vis_bernhard_repros.py covering the three pymat-side issues filed from Bernhard's mat-vis#311 / #313 feedback: * TestIssue220ScalarsAccessor: Vis.scalars accessor missing — three tests for attribute existence, authored-PBR after fetch, and lazy (no texture fetch). * TestIssue221ReprObservability: pre-fetch repr shows fetched=False, post-fetch shows fetched=True with scalars/available_textures summary, and repr visibly differs across fetch. * TestIssue222ScalarOnlySources: Vis("physicallybased", "Aluminum") must resolve tier→"scalar" automatically; .textures returns {}; .to_threejs() succeeds. Plus a non-regression guard pinning textured-source default tier='1k' (kept outside the xfail class so it must keep passing today AND after the fix). Complements the substrate-level live-network xfails in #219 (test_substrate_repros.py) — that file pins the upstream mat-vis-client surface; this one pins the pymat Vis surface using mocked clients so unit-level regressions surface without network. Each xfail is strict: when the fix lands the test XPASSes and CI fails until the marker is removed. Refs #220, #221, #222 * style: ruff format + import sort
5 tasks done
gerchowl
added a commit
that referenced
this pull request
May 7, 2026
Vis('physicallybased', 'Aluminum').to_threejs() previously raised
MaterialNotStagedError because the substrate path treated
physicallybased like a textured source — tier defaulted to "1k"
which doesn't exist in physicallybased's manifest, so
fetch_all_textures raised before scalars could be read.
Three pieces:
1. **Type widening**: `tier: str = "1k"` → `tier: str | None = "1k"`
matches the type already used in `set_identity` / `_validate_tier`.
Setting `vis.tier = None` is a documented un-mapping operation
(per `has_mapping` docstring).
2. **`__post_init__` auto-resolution** via new
`_auto_resolve_tier_from_manifest()`. When source + material_id
are set and the configured tier isn't in the source's manifest
tier list, fall back to "scalar" if available. Permissive on
client / manifest unavailability — mirrors `_validate_tier`'s
policy. The default stays "1k" (textured-source majority);
physicallybased silently re-resolves to "scalar".
3. **`_fetch` short-circuit**: when tier == "scalar", skip
`client.fetch_all_textures` entirely and mark the Vis fetched
with an empty texture dict. The scalars are already on the Vis
(loaded from TOML or set explicitly); downstream adapters fall
back to `Vis._PBR_DEFAULTS` for anything still None.
Closes the py-mat-side manifestation of mat-vis #313 — upstream
issue stays open for the substrate-path fix, but consumers no
longer hit the symptom because we route around it.
## Tests
- `tests/test_vis_bernhard_repros.py::TestIssue222ScalarOnlySources`
(added in PR #224 as strict-xfail) flips to passing — drops the
xfail marker.
- `tests/test_substrate_repros.py::TestMatVis313_PhysicallybasedAccess`
(added in PR #219 as strict-xfail) also flips to passing as a
cascade — drops the xfail, tightens the assertion to verify
tier auto-resolution lands on "scalar" rather than just "doesn't
raise."
Suite: 823 passed, 43 skipped, 15 xfailed (down from 17 — the two
that flipped were the #222 + #313 markers).
## Caller compatibility
- Existing `Vis(source="ambientcg", material_id="Wood095")` —
unchanged. Auto-resolution sees "1k" is in ambientcg's tier
list, leaves it alone.
- New `Vis(source="physicallybased", material_id="Aluminum")` —
auto-resolves tier to "scalar"; `.to_threejs()` returns
populated dict; `.textures` returns `{}`.
- Offline / cache-miss callers: auto-resolution silently skips
rather than blocking construction.
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
Adds
tests/test_substrate_repros.pywith three literal repros from the open mat-vis upstream issues Bernhard flagged in build123d#1270:TestMatVis285_GpuopenBakingScalarsmetalness=0.0,roughness=0.5,color=0xCCCCCC)TestMatVis311_MaterialNamesclient.materials('gpuopen', '1k')must not return bare UUIDsTestMatVis313_PhysicallybasedAccessVis('physicallybased', 'Aluminum').to_threejs()must not raiseMaterialNotStagedErrorEach test is a strict
xfailtoday (the bugs are open upstream); whenmat-vis-clientships the fixes and py-mat picks up the new dep version, the testsXPASSand the strict marker prompts dropping the xfail.Why
Closes the verification gap the build123d#1270 thread surfaced: running py-mat's own test suite or Bernhard's
tests/test_materials.pypassed cleanly even while these substrate paths were broken. The literal repro snippets from filed issues are the cheapest way to catch this class of "unasserted contract on a covered codepath."Network dependency
Hits real mat-vis substrate. Skip with
MAT_VIS_SKIP_LIVE=1(mirrors thetest_e2e_vis.pyconvention). Transient CDN failures turn intopytest.skipvia the local_skip_on_upstream_outagecontext manager.Out of scope
mat-vis #312 (download progress) deliberately omitted: testing progress-callback behavior requires callback-capture infrastructure that doesn't exist on either side yet. Worth a separate issue once the callback API is designed.
Test plan
uv run python -m pytest tests/test_substrate_repros.py -v→ 3 xfail (or skip-on-outage)uv run ruff check tests/test_substrate_repros.pycleanuv run ruff format --check tests/test_substrate_repros.pycleanRefs build123d#1270, mat-vis #285, mat-vis #311, mat-vis #313