Skip to content

test(substrate): pin Bernhard's open mat-vis repros as strict xfails - #219

Merged
gerchowl merged 1 commit into
mainfrom
feature/3.12-substrate-repros
May 7, 2026
Merged

gerchowl merged 1 commit into
mainfrom
feature/3.12-substrate-repros

Conversation

@gerchowl

@gerchowl gerchowl commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds tests/test_substrate_repros.py with three literal repros from the open mat-vis upstream issues Bernhard flagged in build123d#1270:

Test Pins Upstream issue
TestMatVis285_GpuopenBakingScalars Two distinct gpuopen metals must NOT both return baker-default scalars (metalness=0.0, roughness=0.5, color=0xCCCCCC) mat-vis #285
TestMatVis311_MaterialNames client.materials('gpuopen', '1k') must not return bare UUIDs mat-vis #311
TestMatVis313_PhysicallybasedAccess Vis('physicallybased', 'Aluminum').to_threejs() must not raise MaterialNotStagedError mat-vis #313

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.

Why

Closes the verification gap the build123d#1270 thread surfaced: running py-mat's own test suite or Bernhard's tests/test_materials.py 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 dependency

Hits real mat-vis substrate. Skip with MAT_VIS_SKIP_LIVE=1 (mirrors the test_e2e_vis.py convention). Transient CDN failures turn into pytest.skip via the local _skip_on_upstream_outage context 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.py clean
  • uv run ruff format --check tests/test_substrate_repros.py clean

Refs build123d#1270, mat-vis #285, mat-vis #311, mat-vis #313

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.
@gerchowl
gerchowl merged commit 39a4248 into main May 7, 2026
19 checks passed
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
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.
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.

1 participant