Fix: take platform and devices from fixtures in notify-demo tests - #1568
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe notify demo tests now use pytest markers and fixtures for platform and device selection. A new AST-based lint script detects hardcoded platform literals, and pre-commit runs it on relevant test files. The capability survey documents the updated routing and CI coverage. ChangesPlatform-aware test routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.pre-commit-config.yaml:
- Line 33: Update the pre-commit `files` regex to match test files directly
under `examples` and `tests/st` as well as within nested directories, while
preserving the existing test filename pattern and root scope.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 19974d66-13b6-4308-bc04-dcf7391cad77
📒 Files selected for processing (7)
.pre-commit-config.yamldocs/capability-survey.mdexamples/a2a3/tensormap_and_ringbuffer/async_notify_demo/test_async_notify_demo.pyexamples/a2a3/tensormap_and_ringbuffer/deferred_notify_demo/test_deferred_notify_demo.pyexamples/a5/tensormap_and_ringbuffer/async_notify_demo/test_async_notify_demo.pyexamples/a5/tensormap_and_ringbuffer/deferred_notify_demo/test_deferred_notify_demo.pytests/lint/check_test_platform_literals.py
546b6d3 to
044d8d7
Compare
Fixes hw-native-sys#1561 Four `*_notify_demo` tests were plain pytest functions that hardcoded both the platform string and the device IDs, so `--platform` and `--device` were ignored. The tests grabbed devices 0 and 1 whatever `task-submit` had allocated, and the a5 variants built an a5 callable on a2a3-only silicon, where the forked chip child segfaults in `ChipWorker.init`. They also never ran in CI. `_collect_resource_jobs` in `conftest.py` dispatches a standalone function only when it declares both `@pytest.mark.device_count` and `@pytest.mark.runtime`; carrying neither, these four were collected but never selected. They fired only on a hand-scoped `--runtime`/`--level` invocation, which enters child mode and bypasses the dispatcher — so the failure looked like a regression in whatever branch was being validated. Adopt the marker + fixture pattern the sibling demos in the same directories already use. That both honours the CLI options and enrols the tests in resource-phase dispatch. `deferred_notify_demo` stays sim-only, matching its docstring and the platform it has been validated on. Add `tests/lint/check_test_platform_literals.py` and wire it into pre-commit. It AST-walks test bodies under `examples/` and `tests/st/` and rejects a platform name passed as a call argument; a literal compared against the `st_platform` fixture is correct usage and is not flagged. Platform names come from `PLATFORM_MAP` in `simpler_setup/platform_info.py`, parsed rather than imported so the hook runs in pre-commit's isolated environment. The hook's file filter matches test files both directly under those roots and nested within them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #1561
Problem
Four
*_notify_demotests were plain pytest functions that hardcoded both the platform string and the device IDs, so--platformand--devicewere ignored:They grabbed devices 0 and 1 whatever
task-submithad allocated, and the a5 variants built an a5 callable on a2a3-only silicon, where the forked chip child segfaults inChipWorker.init.Why CI never caught it.
_collect_resource_jobs(conftest.py:634) dispatches a standalone function only when it declares both@pytest.mark.device_countand@pytest.mark.runtime. Carrying neither, these four were collected but never selected — the full-CI invocation never ran them at all. They fired only on a hand-scoped--runtime/--levelinvocation, which enters child mode and bypasses the dispatcher. That is what makes them an efficient trap: the failure looks like a regression in whatever branch is being validated.Change
Adopt the marker + fixture pattern the sibling demos in the same directories already use (
sdma_async_completion_demo,urma_deferred_completion_demo):This both honours the CLI options and enrols the tests in resource-phase dispatch, so they genuinely run in CI.
main()andrun()are untouched —python test_*.py -p ... -d ...still works.deferred_notify_demostays sim-only on both arches. It does pass onboard a2a3 in isolation, but it failed in the full sweep when temporarily widened, so widening it would trade one trap for another; that is logged for follow-up rather than shipped here.New lint
tests/lint/check_test_platform_literals.py, wired into pre-commit. It AST-walks test bodies underexamples/andtests/st/and rejects a platform name passed as a call argument. A literal compared against the fixture (if st_platform != "a2a3": pytest.skip(...)) is correct usage and is not flagged, and@pytest.mark.platforms([...])lives indecorator_listso it is out of scope by construction. Platform names come fromPLATFORM_MAPinsimpler_setup/platform_info.py, parsed rather than imported so the hook runs in pre-commit's isolated env and cannot drift when an arch is added.The four fixed here were the only violations in the tree.
Verification
Onboard a2a3 (
task-submit-locked) and sim:The actual fix —
async_notify_demonow runs on the allocated devices:[scheduler] START standalone test_async_notify_demo (dev=2) devices=[3, 5]→ PASS. Previously it used 0 and 1 regardless.Wrong-arch trap closed —
pytest examples/a2a3/.../{async,deferred}_notify_demo --platform a5 --collect-only→2 deselected(was: collected and run).Sim — both
deferred_notify_demopass on--device 6-7undera2a3sim/a5sim, i.e. no longer pinned to 0/1.No regression — full
examples/a2a3 tests/st/a2a3 --platform a2a3 --runtime tensormap_and_ringbuffersweep on devices 1,3,5,7:5768aac2: 3 failed, 51 passed, 25 deselectedqwen3_14b_decode,sdma_async_completion_demo,prepared_callable) — pre-existing, independent of this change. Two of the three are quarantined out of this sweep in CI (HEAVY_IGNORE/SDMA_IGNORE).The 51→50 / 25→26 delta is this change working: on main,
deferred_notify_demowas selected during an onboard sweep and ran aa2a3simworkload there. It is now correctly deselected.pre-commit run— all hooks pass, including the new one; verified it fails when one file is reverted.Note for the a5 owner
This box is a2a3-only, so the a5 markers (
["a5"]for async,["a5sim"]for deferred) preserve existing behaviour and are not onboard-validated here. Adding the markers means the a5 demos now actually run in the a5 CI job, where they previously did not — worth a look at the first a5 pipeline on this PR.🤖 Generated with Claude Code