feat: add system-aware tiered parallel pytest + cgroup v1/v2 support and on-behalf review standards#2
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in --parallel mode for running the repo’s pytest suite with pytest-xdist, computing a bounded worker count from detected CPU/memory constraints plus tiered OS caps, and surfacing the resolved settings in the pytest header for transparency.
Changes:
- Introduces system-aware worker sizing logic with low/medium/high tiers (
tests/_parallel.py). - Adds pytest CLI options and wiring to enable xdist only when
--parallelis provided, plus a report header line (tests/conftest.py). - Adds unit tests for sizing behavior and documents the optional parallel workflow; adds
pytest-xdistto test extras.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/test_parallel_workers.py |
Adds tests covering CPU/memory/OS caps, tier effects, and max-worker override behavior. |
tests/conftest.py |
Adds --parallel/tier/max-workers options, computes worker settings, and prints resolved settings in the pytest header. |
tests/_parallel.py |
Implements CPU/memory detection helpers (incl. cgroup-aware memory) and tiered worker sizing model. |
pyproject.toml |
Adds pytest-xdist to the test optional dependency set. |
CONTRIBUTING.md |
Documents optional parallel test execution and tier recommendations. |
.github/PULL_REQUEST_TEMPLATE.md |
Updates testing checklist to mention optional parallel tiered invocation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round updateCommit: Addressed feedback
Validation
No conversation was resolved in this update. |
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round updateCommit: Standards tag-along implementation
No conversation was resolved in this update. |
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round updateCommit: Addressed Copilot feedback
Validation
No conversation was resolved in this update; inline replies were posted for reviewer/bot closure. |
This comment was marked as resolved.
This comment was marked as resolved.
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review-round update summary:
Included commit: Validation:
|
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review-round update summary:
Included commit: Validation:
|
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review-round update summary:
Included commit: Validation:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/test_self_upgrade_execution.py:90
test_relative_installer_path_does_not_require_path_lookupnow runs on Windows but creates a relative installer file nameduv-installerwithout an executable extension. In_run_installer()(src/specify_cli/_version.py) the relative-path branch checksos.access(path, os.X_OK), which commonly returns False on Windows for non-.exe/.bat files, so this test can fail with an “invalid installer” exit instead of the expected success.
Patch specify_cli._version.os.access to return True in this test (it’s not trying to validate Windows executability semantics, just that PATH lookup isn’t required for relative paths).
with patch("specify_cli.authentication.http.urllib.request.urlopen") as mock_urlopen, patch(
"specify_cli._version.shutil.which", side_effect=lambda name: None
), patch("specify_cli._version.subprocess.run") as mock_run, patch(
"specify_cli._version._get_installed_version", return_value="0.7.5"
), patch(
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round update for 1927cb6: addressed all currently open review comments and posted inline Resolved by replies on each thread. Changes include stricter non-Windows shell path matching, tighter Windows override-path assertion, and report-header display of effective workers (with regression test coverage). Validation: uv run pytest tests/test_parallel_workers.py tests/test_setup_tasks.py tests/test_timestamp_branches.py -q (128 passed). |
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round update for 003f870: addressed all currently open review comments by guarding both parallel xdist hook paths when users pass -p no:xdist. Added regression tests for split and compact disable forms. Validation: uv run pytest tests/test_parallel_workers.py -q (19 passed). |
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round update for a83ad7b: addressed the remaining open review comment by simplifying _path_from_bash_output() in tests/test_setup_plan_no_overwrite.py and posting an inline Resolved by reply. Validation: uv run pytest tests/test_setup_plan_no_overwrite.py -q (6 passed). |
| if trim_to_pytest(actual_parts) == trim_to_pytest(expected_parts): | ||
| return |
There was a problem hiding this comment.
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Resolved by 173207b. _assert_shell_path_matches() now applies pytest-tempdir trimming only on Windows; POSIX no longer uses that relaxation and stays strict.
|
Posted on behalf of @LahkLeKey by GitHub Copilot (model: GPT-5.3-Codex). Review round update for 173207b: addressed all currently open review comments and posted inline 'Resolved by 173207b' replies on each open thread. Also backfilled a persistent Review Fix Ledger in the PR description (including both 'Addressed in' and 'Resolved by' history) to track add-on fixes and prevent feedback loops across rounds. Validation: uv run pytest tests/test_parallel_workers.py tests/test_timestamp_branches.py tests/test_self_upgrade_execution.py -q (130 passed). |
…#3) * feat: add system-aware tiered parallel pytest + cgroup v1/v2 support and on-behalf review standards (#2) * feat: add system-aware parallel pytest tiers * fix: honor cgroup v1 cpu quota for parallel worker sizing * docs: add on-behalf AI review disclosure standard * fix: support cpuacct,cpu cgroup v1 quota mount layout * test: make --parallel activate xdist workers * test: harden bash path assertions on Windows * test: handle zero available memory in parallel sizing * test: make symlink skip capability-based on Windows * test: replace platform skips with capability checks * test: address open review findings for path and xdist checks * test: restore strict setup task assertions * test: honor explicit -n auto and clean InvalidMetadata fallback * test: floor cgroup quota workers and remove dead helper * test: mock os.access for relative installer path case * test: tighten path checks and report effective workers * test: skip parallel xdist hooks when plugin is disabled * test: simplify bash path normalization helper * test: harden parallel args and cwd-safe upgrade tests * feat: add system-aware tiered parallel pytest + cgroup v1/v2 support and on-behalf review standards (#2) * feat: add system-aware parallel pytest tiers * fix: honor cgroup v1 cpu quota for parallel worker sizing * docs: add on-behalf AI review disclosure standard * fix: support cpuacct,cpu cgroup v1 quota mount layout * test: make --parallel activate xdist workers * test: harden bash path assertions on Windows * test: handle zero available memory in parallel sizing * test: make symlink skip capability-based on Windows * test: replace platform skips with capability checks * test: address open review findings for path and xdist checks * test: restore strict setup task assertions * test: honor explicit -n auto and clean InvalidMetadata fallback * test: floor cgroup quota workers and remove dead helper * test: mock os.access for relative installer path case * test: tighten path checks and report effective workers * test: skip parallel xdist hooks when plugin is disabled * test: simplify bash path normalization helper * test: harden parallel args and cwd-safe upgrade tests * test: harden upstream review fixes and unify path helpers * test: address latest upstream review findings * fix tests path normalization and xdist defaults * fix review comments on parallel and path tests * fix latest review comments and harden tests * fix latest review comments on path and xdist parsing * fix latest review comments on installer and PATH tests * fix latest posix-vs-git-bash review comments * fix latest review comments and tighten guidance * fix latest review comments and reduce test churn * test latest review edge cases for bash and parallel hooks * fix latest review comments on bash and parallel validation * fix latest review comments on path and parallel hooks * fix latest review comments and consolidate bash helpers * address remaining review comments * update PR review comment guidance * ignore pr scratch files * preserve preset scan semantics * address latest review feedback * harden preset scan fallback pipeline * harden resolver and windows chmod tests * tighten review comments on xdist and auth tests * stabilize interpreter selection and review fixes * test: address latest review hardening comments * test: fix latest review feedback round * test: address latest review comments * test: resolve latest review follow-ups * test: harden latest review edge cases * test: prevent preset strategy state leakage * test: resolve latest copilot review comments * test: consolidate bash resolver test helpers * test: refine parallel arg injection and probe reuse * fix: harden manifest path traversal guard * fix: harden parser and path edge cases * fix: tighten manifest and device path guards * chore: start fork continuation PR3 * test: address PR3 copilot follow-ups * test: remove stale self-upgrade import
Summary
Adds an opt-in, system-aware parallel pytest mode with tiered profiles, cgroup v1/v2 quota awareness, and documentation/template updates for on-behalf review disclosure standards.
Highlights
Keeps default flow unchanged:
uv sync && uv run pytestAdds optional parallel execution:
uv run pytest --parallelAdds tiered aggressiveness:
--parallel-tier low|medium|highComputes worker settings from effective CPU + available memory + OS caps
Supports both cgroup v2 and cgroup v1 CPU quota signals
Prints resolved parallel settings in pytest header
Adds standards-aligned docs/template guidance for "posted on behalf" review comments
Why
The suite can be slow in serial mode, while naive parallelism can overload machines or behave inconsistently across environments. This change provides bounded, explainable parallelism that remains optional and transparent.
A tag-along standards update was included to make AI-on-behalf review communication explicit and consistent.
Requirements Checklist
Functional
Keep existing default test workflow intact (
uv run pytestunchanged)Add optional parallel flag (
--parallel)Calculate settings from system information
Add 3-tier profile system (
low,medium,high)Allow hard cap override (
--parallel-max-workers)Avoid changing CI workflows for this feature
System-awareness
Use effective CPU count (including affinity/quota signals where available)
Use available memory with total-memory fallback
Support cgroup v2 and cgroup v1 CPU quota parsing
Consider cgroup memory constraints where available
Apply OS-specific caps to prevent over-allocation
UX / observability
Emit resolved parallel settings in pytest header
Include selected tier in reported settings
Keep command ergonomics simple for contributors
Documentation / standards
Update contributor guidance for optional parallel testing
Add tier recommendation matrix for laptop/workstation/CI usage
Update PR template testing section with optional tiered command
Add explicit on-behalf AI-comment attribution guidance in contributor docs
Add PR-template checklist item for on-behalf attribution compliance
Validation
Add/expand worker-sizing tests
Validate medium/default tier behavior
Validate low/high tier behavior
Validate max-worker cap behavior
Validate cgroup v2 and cgroup v1 quota parsing
Scope of Changes
Core logic
tests/_parallel.pyAdded system detection helpers:
effective CPU count
available memory
cgroup-aware CPU/memory constraints
Added tier model/config for
low|medium|highAdded cgroup v2 + v1 CPU quota handling
Added
ParallelSettingsmodel for transparent resolved outputtests/conftest.pyAdded pytest options:
--parallel--parallel-tier low|medium|high--parallel-max-workers NWired computed settings into xdist
numprocessesAdded report-header output for resolved settings
Tests
tests/test_parallel_workers.pyCPU-bound and memory-bound decisions
OS cap behavior
max-worker cap behavior
low vs high tier conservatism
memory-per-worker tier scaling
cgroup v2 and cgroup v1 quota parsing tests
Docs / templates
CONTRIBUTING.mdOptional parallel execution section
Tier guidance and recommendation matrix
Explicit on-behalf AI PR-comment attribution standard
.github/PULL_REQUEST_TEMPLATE.mdOptional tiered parallel invocation in testing checklist
AI on-behalf attribution checklist item
Test Evidence
Executed locally:
uv run specify --helpuv run pytest tests/test_parallel_workers.py -quv run pytest tests/test_parallel_workers.py --parallel --parallel-tier low --parallel-max-workers 2uv run pytest tests/test_parallel_workers.py --parallel --parallel-tier high --parallel-max-workers 2Output excerpts:
Incoming Copilot Reviews Checklist
Addressed inline feedback: add cgroup v1 CPU quota support for worker sizing
Added regression tests for cgroup v2 and cgroup v1 quota parsing
Replied inline with fix + validation evidence
Risk / review focus
Please review with extra focus on:
Cross-platform behavior of system detection logic
cgroup detection correctness on Linux/containerized runners
Tier defaults and cap conservatism
Interaction between custom
--paralleloptions and xdist behaviorClarity and enforceability of on-behalf review disclosure wording
AI disclosure
This PR was prepared with GitHub Copilot assistance, with human-directed implementation, validation, and review.
Update 2026-06-05: Windows/Bash path fixes + verified parallel execution
What changed after prior report
Fixed the previously reported Windows/Git Bash path assertion failures in:
tests/test_setup_plan_no_overwrite.pytests/test_setup_tasks.pytests/test_timestamp_branches.pyEnsured
--parallelnow actually activates xdist workers (not just settings reporting).New validation evidence
Repro subset (previously failing files) in serial mode:
Same subset with optional parallel high tier:
Full suite with optional parallel high tier:
Optimization outcome
Subset runtime improved from ~103s to ~32s with
--parallel --parallel-tier high.Full suite now completes green under optional parallel mode with active workers.
Commit references for this update
5ec7f40test: make--parallelactivate xdist workersc1cf15ftest: harden bash path assertions on WindowsReview Fix Ledger (On Behalf Of @LahkLeKey)
This section tracks review-driven follow-up fixes to avoid repetitive feedback loops across rounds.
3936c1c31537cf6935ad87c966ae1b757be03e30e91927cb6003f870a83ad7b173207b