test: skip GPU tests when CUDA is unavailable - #679
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (11)
🧰 Additional context used📓 Path-based instructions (10)**/*.{md,markdown,py}📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
Files:
tests/**📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/tests/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*📄 CodeRabbit inference engine (AGENTS.md)
Files:
⚙️ CodeRabbit configuration file
Files:
**/*.{md,py,sh,toml,yml,yaml,Dockerfile}📄 CodeRabbit inference engine (AGENTS.md)
Files:
tests/**/*.py📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Files:
⚙️ CodeRabbit configuration file
Files:
**/*.{py,sh,yaml,yml,md}📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Files:
**/*.{py,pyi}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{py,sh,yaml,yml,toml,md}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (5)📚 Learning: 2026-05-27T22:20:37.354ZApplied to files:
📚 Learning: 2026-07-27T22:07:22.590ZApplied to files:
📚 Learning: 2026-07-29T17:12:32.642ZApplied to files:
📚 Learning: 2026-08-05T19:07:15.856ZApplied to files:
📚 Learning: 2026-06-04T16:14:09.868ZApplied to files:
🔇 Additional comments (1)
WalkthroughThe pytest configuration now applies CUDA-aware handling to ChangesGPU test collection and CI enforcement
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9d9ce968-4ccb-4527-bdbc-1b64e71db3ed
📒 Files selected for processing (4)
tests/TESTING.mdtests/conftest.pytests/smoke/README.mdtests/test_pytest_configuration.py
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
**/*.{md,markdown}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown}: Bold is acceptable only in markdown tables where it's the conventional way to mark header-like cells in the body
Use##headers to segment markdown sections instead of bold text
Use--(em-dash) instead of-(hyphen) for asides in markdown
Files:
tests/smoke/README.mdtests/TESTING.md
tests/**
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
tests/**: Mirrorsrc/directory structure intests/directory for test organization
Auto-mark tests by directory:tests/e2e/→e2e,tests/smoke/→smoke, otherwise default tounit
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
**/*.md
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Do not use decorative bold in Markdown body text, list items, or docstrings; use single backticks for code identifiers, paths, and commands.
Files:
tests/smoke/README.mdtests/TESTING.md
**/*
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*: Every source file requires the SPDX copyright and license header appropriate to its file format.
End files with a newline, remove trailing whitespace, use one space between sentences, and keep code, comments, and docstrings within 120 characters.
**/*: All contributions must use verified Git commits and DCO sign-off; unsigned or unsigned-off commits cannot be merged.
Branches other thanmainmust follow<author>/<description>, optionally including an issue ID or type; branch names must use lowercase alphanumeric characters and hyphens.
Commits merged tomainmust follow Conventional Commits, using a valid lowercase type and a description of at most 100 characters.
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
**/*.{py,sh,yaml,yml,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
All Python, shell, YAML, YML, and Markdown source files require SPDX copyright headers.
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
**/*.{py,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use the repository's documented Python and Markdown style conventions and validate changes with the pinned
miseformatting and checking tasks.
Files:
tests/smoke/README.mdtests/TESTING.mdtests/test_pytest_configuration.pytests/conftest.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Place durable implementation guidance in function and class docstrings for public contracts and source comments for local invariants
Target Python 3.11–3.13 with modern syntax (X | Y,list[str],Self). Python 3.14+ is not supported
**/*.py: Use American English spelling in Python code, documentation, and messages.
UseField(description=...)for every Pydantic model field.
Use assignment-styleField()by default; useAnnotatedonly for additional metadata such as validators, constrained aliases, or discriminated unions.
Use@dataclass(frozen=True)for immutable value objects and validators; use mutable dataclasses only for builders, accumulators, and pipeline state.
Usefield(default_factory=list)instead of mutable list defaults.
UseStrEnumfor string-valued configuration or serialization enums and plainEnumfor internal constants.
Obtain loggers withobservability.get_logger(__name__); do not calllogging.getLogger()orstructlog.get_logger()directly.
Use.runtime,.user, and.systemcategory loggers appropriately.
Do not useprint()for operational library output; use the approved logger,click.echo(), orsys.stdout.write()where appropriate.
Useextra={}for machine-queryable logging data and f-strings only for human-readable context.
Raise errors from the custom Safe Synthesizer error hierarchy, using the documented dual inheritance for user and internal errors.
Keep shared package code compatible with Python 3.11; do not use Python 3.12-only syntax such as PEP 695 type statements or bracketed generic parameters.
PreferX | Y, built-in collection generics, andSelfoverOptional,Union, and legacy typing collections.
Use collection ABCs for function arguments and concrete collection types for return values.
UseProtocolfor structural subtyping and avoidAnywhenobject, generics, or protocols are suitable.
UseTYPE_CHECKINGguards for heavy imports such as pandas, torch, and transformers.
...
Files:
tests/test_pytest_configuration.pytests/conftest.py
**/test_*.py
📄 CodeRabbit inference engine (AGENTS.md)
Use the
unitmarker instead of the deprecatedunit_testmarker for test identification
Files:
tests/test_pytest_configuration.py
tests/**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
tests/**/*.py: Use absolute imports from the package in tests.
Prefix fixtures withfixture_, use function scope by default, and document each fixture with a one-line docstring.
Use bareassert,pytest.raises(..., match=...), andpytest.approx()as the primary assertion styles.
Usetmp_pathfor file operations and never write test artifacts into the repository tree.
Usepytest.mark.parametrizefor multiple input combinations and mock only external boundaries.New features must include tests, and bug fixes must include regression tests; all existing tests must pass before submitting a pull request.
tests/**/*.py: Every test should have exactly one category marker:unit,smoke, ore2e; use modifier markers such asslow,requires_gpu, andvllmonly as appropriate.
Usepytest.importorskipfor optional dependencies that require specific extras, such assentence_transformersandvllm.
Use the sharedfixture_mock_processororfixture_mock_processor_without_valid_recordsfixtures and constructParsedResponsewithvalid_records,invalid_records,errors, and integerprompt_number.
Usemock_workdir(tmp_path)fromcli/conftest.pywhen mocking a Workdir in CLI tests.
Use thefixture_prefix consistently for dataset and tokenizer fixture names.
Seed Faker withfake.seed_instance(seed)and the Python random generator withrandom.seed(seed)for reproducible tests.
Tests should mirror the source structure, using directories such astests/training/,tests/generation/, andtests/evaluation/.
print()is permitted in tests for debug output; the test configuration suppresses Ruff ruleT201for the tests directory.
Files:
tests/test_pytest_configuration.pytests/conftest.py
⚙️ CodeRabbit configuration file
Review tests against tests/TESTING.md. Check marker usage, fixture naming, tmp_path usage, determinism, and GPU/vLLM process-isolation requirements. Flag slop tests that only check that code runs, assert result is not None when stronger invariants exist, over-mock internal implementation details, patch around the bug instead of reproducing it, or add broad snapshot/golden churn without a clear contract. Flag change detector tests that fail on harmless refactors, formatting, record ordering, incidental wording, or private implementation details without demonstrating a behavior regression. Prefer existing fixtures or focused new fixtures for repeated setup; keep tests DRY when reasonable without making the behavior under test opaque. print() is allowed in tests.
Files:
tests/test_pytest_configuration.pytests/conftest.py
tests/test_*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Name test files
test_*.py, classesTest*, and functionstest_<module>_<expected_behavior>.
Files:
tests/test_pytest_configuration.py
**/*.{py,pyi}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Shared Python package code must remain compatible with Python 3.11 syntax; do not use Python 3.12-only syntax such as PEP 695
typestatements or bracketed generic class/function parameters.
Files:
tests/test_pytest_configuration.pytests/conftest.py
**/*.{py,sh}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use the repository's pinned
misetasks for formatting, linting, type checking, and testing rather than invokingruffortydirectly for project-wide checks.
Files:
tests/test_pytest_configuration.pytests/conftest.py
tests/conftest.py
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Store shared test fixtures in
tests/conftest.py
Files:
tests/conftest.py
🧠 Learnings (2)
📚 Learning: 2026-05-27T22:20:37.354Z
Learnt from: kendrickb-nvidia
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 520
File: tests/generation/test_vllm_backend.py:556-587
Timestamp: 2026-05-27T22:20:37.354Z
Learning: In NVIDIA-NeMo/Safe-Synthesizer, `tests/conftest.py`’s `pytest_collection_modifyitems` hook applies pytest category markers automatically based on each test file’s path: tests under `/e2e/` get `pytest.mark.e2e`, tests under `/smoke/` get `pytest.mark.smoke`, and all other tests get `pytest.mark.unit`. Therefore, when reviewing pytest tests outside `tests/e2e/` and `tests/smoke/`, do not flag missing explicit `pytest.mark.unit` decorators on test classes/functions as an issue (the hook will add them during collection). If a new test directory/category is introduced, ensure the hook is updated so it’s categorized correctly.
Applied to files:
tests/test_pytest_configuration.pytests/conftest.py
📚 Learning: 2026-07-27T22:07:22.590Z
Learnt from: binaryaaron
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 673
File: tests/pii_replacer/test_edit.py:327-327
Timestamp: 2026-07-27T22:07:22.590Z
Learning: When tests read structured logging context from Python `logging.LogRecord` instances, don’t access `record.ctx` directly (it isn’t declared on `LogRecord` and will break static typing). Instead, use `getattr(record, "ctx", default)` (or an appropriate fallback) to safely handle cases where `ctx` may or may not be attached. This applies even if Ruff rule `B009` isn’t enabled in the repo.
Applied to files:
tests/test_pytest_configuration.pytests/conftest.py
🔇 Additional comments (4)
tests/conftest.py (1)
19-20: LGTM!Also applies to: 59-95
tests/TESTING.md (1)
101-101: LGTM!Also applies to: 119-121
tests/smoke/README.md (1)
63-64: LGTM!tests/test_pytest_configuration.py (1)
1-35: LGTM!
Greptile SummaryThis PR centralizes CUDA availability handling for GPU-marked tests while preserving strict failure behavior in GPU CI.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (5): Last reviewed commit: "test: isolate vLLM teardown cleanup asse..." | Re-trigger Greptile |
mckornfield
left a comment
There was a problem hiding this comment.
testing pytest config, rad
| import pytest | ||
|
|
||
|
|
||
| def _root_conftest_module(config: pytest.Config) -> ModuleType: |
There was a problem hiding this comment.
lol who tests the tests
kendrickb-nvidia
left a comment
There was a problem hiding this comment.
This makes sense for development. But is there a way to not skip the tests in CI though (the gpu CI jobs), in other words only skip the tests for the development but never do this auto disable in CI? I guess controlling it via an env var we set in CI?
I worry about something in CI messing up the cuda stuff and then we just skip all the tests, everything looks green, but we've suddenly stopped running any gpu based tests and don't find out about it until a release has a bunch of broken stuff or such.
like that's ever happened before ... :) - @zywind - since you're working on related stuff too, just want to coordinate a bit. we can add the env handling here, which i think is prudent. we'll also have to modify this if we add support for Metal. |
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 81598b64-4292-4eaa-a399-c86d12014e3f
📒 Files selected for processing (7)
.github/actions/detect-changes/action.yml.github/actions/setup-gpu-test-env/action.yml.github/workflows/gpu-tests.yml.mise.gpu-ci.tomltests/TESTING.mdtests/conftest.pytests/test_pytest_configuration.py
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: Greptile Review
- GitHub Check: Analyze (python)
- GitHub Check: conventional-commit / semantic-pull-request
- GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (16)
.github/**
⚙️ CodeRabbit configuration file
Review GitHub configuration for branch protection expectations, CODEOWNERS alignment, least privilege permissions, pinned actions where practical, and consistency with CONTRIBUTING.md.
Files:
.github/actions/detect-changes/action.yml.github/workflows/gpu-tests.yml.github/actions/setup-gpu-test-env/action.yml
.github/workflows/*.yml
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Keep documentation deployment behavior consistent with the rule that changes to
docs/,mkdocs.yml, orsrc/deploy documentation when pushed tomain.
Files:
.github/workflows/gpu-tests.yml
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
tests/**
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
tests/**: Mirrorsrc/directory structure intests/directory for test organization
Auto-mark tests by directory:tests/e2e/→e2e,tests/smoke/→smoke, otherwise default tounit
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
tests/conftest.py
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Store shared test fixtures in
tests/conftest.py
Files:
tests/conftest.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Useuvfor Python dependency management and execution; never usepipor rawpython. Target Python 3.11–3.14 and use modern syntax such asX | Y,list[str], andSelf.
Run project tooling throughmisetasks or wrapper scripts intools/; do not invokeruffortydirectly. Useuv runfor Python execution.
Put durable implementation guidance in public function and class docstrings; put local invariants in source comments.
Use Python 3.11–3.14-compatible modern type syntax, includingX | Y,list[str], andSelf.
**/*.py: Use American English spelling in Python code, comments, and documentation; usefrom __future__ import annotationsin every module.
UseBaseSettingsfor environment/CLI settings; preferAliasChoicesfor fields accepting both Python and environment-variable names.
Pydantic model fields must includeField(description=...); prefer assignment-styleField()and useAnnotatedonly for additional metadata or constraints.
Use@dataclass(frozen=True)for immutable value objects and validators, andfield(default_factory=...)for mutable defaults; never use mutable default values directly.
UseStrEnumfor string-valued configuration or serialization enums and plainEnumfor internal-only constants.
Obtain loggers withobservability.get_logger(__name__); do not calllogging.getLogger()orstructlog.get_logger()directly.
Do not useprint()for operational library output; use the approved logger,click.echo()for CLI output, orsys.stdout.write()for raw tool output.
Use loggerextra={}for metrics, counts, durations, and other data intended for machine querying; use f-strings for human-readable context.
Raise known errors through the Safe Synthesizer custom hierarchy, using dual inheritance where callers should also catch a built-in exception.
UseX | Y, built-in generic types,Selffor fluent returns, collection ABCs for arguments,Protocolfor structural boundaries, and avoidAny.
Pre...
Files:
tests/conftest.pytests/test_pytest_configuration.py
**/tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Use the
unitpytest marker instead of the deprecatedunit_testmarker; async tests do not need@pytest.mark.asynciobecauseasyncio_mode = auto.
Files:
tests/conftest.pytests/test_pytest_configuration.py
**/*
📄 CodeRabbit inference engine (AGENTS.md)
**/*: ReadAGENTS.local.mdif it exists and give its instructions top priority.
When a task matches a repository-specific skill, read the corresponding skill under.agents/skills/instead of duplicating its workflow instructions.
Do not commit unless the user explicitly asks for a commit or PR work.
When committing, require DCO sign-off and GPG signing usinggit commit --signoff --gpg-sign(or-s -S); never manually addSigned-off-byor use--no-gpg-sign.
Use feature branches based onmain; branch names commonly include an issue-number prefix such as<author>/123-short-name.
For recurring testing, building, syncing, bootstrapping, worktree, and GitHub workflows, use the matching skill under.agents/skills/.
For a full GPU/development environment, useuv sync --frozen --extra cu129 --extra engine --group dev; bareuv sync --frozenis incomplete and can causety, import-check, and GPU-test failures.End files with a newline, contain no trailing whitespace, use one space between sentences, and keep code, comments, and docstrings within 120 characters.
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
**/*.{md,py,sh,toml,yml,yaml,Dockerfile}
📄 CodeRabbit inference engine (AGENTS.md)
Follow the detailed language and file-format conventions defined in
STYLE_GUIDE.md.
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
tests/**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
tests/**/*.py: Use absolute imports in tests.
Name test filestest_*.py, classesTest*, and functionstest_<module>_<expected_behavior>; prefix fixtures withfixture_and give each fixture a one-line purpose docstring.
Use function-scoped fixtures by default, bareassert,pytest.raises(match=...),pytest.approx(), andpytest.mark.parametrizefor input combinations.
Usetmp_pathfor file operations, mock only external boundaries, avoid shared mutable state and order dependencies, and mark CUDA-dependent tests appropriately.All existing tests must pass before submitting a pull request; new features must include tests and bug fixes must include regression tests.
tests/**/*.py: Every test must have exactly one category marker:unit,smoke, ore2e; use modifier markers such asslow,requires_gpu, andvllmonly in addition to a category marker.
Usepytest.importorskipfor optional dependencies that require specific extras, such assentence_transformersandvllm.
Use the shared test-data helpersload_test_dataset(filename)andload_test_dataframe(filename)from the root test configuration when loading test datasets.
Use thefixture_prefix for dataset and tokenizer fixtures; CLI helpers such asmock_workdirmay use descriptive names.
RepresentParsedResponsetest values withvalid_records,invalid_records,errors, and integerprompt_number; preferfixture_mock_processororfixture_mock_processor_without_valid_recordsfor processor mocks.
Seed both Faker and the standard random module for reproducible generated test data: callfake.seed_instance(seed)andrandom.seed(seed).
Tokenizers should generally use function-scoped fixtures; use session scope forfixture_session_cache_dirwhere specified.
Tests should mirror the source structure, using directories such astests/training/,tests/generation/, and corresponding source areas.
print()is allowed in tests for debug output; Ruff ruleT201is suppr...
Files:
tests/conftest.pytests/test_pytest_configuration.py
⚙️ CodeRabbit configuration file
Review tests against tests/TESTING.md. Check marker usage, fixture naming, tmp_path usage, determinism, and GPU/vLLM process-isolation requirements. Flag slop tests that only check that code runs, assert result is not None when stronger invariants exist, over-mock internal implementation details, patch around the bug instead of reproducing it, or add broad snapshot/golden churn without a clear contract. Flag change detector tests that fail on harmless refactors, formatting, record ordering, incidental wording, or private implementation details without demonstrating a behavior regression. Prefer existing fixtures or focused new fixtures for repeated setup; keep tests DRY when reasonable without making the behavior under test opaque. print() is allowed in tests.
Files:
tests/conftest.pytests/test_pytest_configuration.py
**/*.{py,sh,yaml,yml,md}
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Include the required SPDX copyright and Apache-2.0 license headers, using comment syntax appropriate to the file format.
Include SPDX copyright headers in all source files, except files explicitly listed in
.copyrightignore.
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
**/*.{py,pyi}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.{py,pyi}: Keep shared Python package code compatible with Python 3.11; do not use Python 3.12-only syntax such as PEP 695 type statements or bracketed generic parameters.
Use the repository's pinned Ruff tasks for Python formatting, import sorting, and linting rather than invoking unpinned tools directly.
Run the repository's pinnedtytype checker and maintain type-correct Python code.
Files:
tests/conftest.pytests/test_pytest_configuration.py
**/*.{py,sh,yaml,yml,toml,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use
misetasks with the repository's pinned tool versions for formatting, checking, and testing before submitting changes.
Files:
tests/conftest.pytests/test_pytest_configuration.pytests/TESTING.md
**/*.{md,markdown}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown}: Bold is acceptable only in markdown tables where it's the conventional way to mark header-like cells in the body
Use##headers to segment markdown sections instead of bold text
Use--(em-dash) instead of-(hyphen) for asides in markdown
Files:
tests/TESTING.md
tests/TESTING.md
📄 CodeRabbit inference engine (AGENTS.md)
Keep test-suite guidance in
tests/TESTING.md.
Files:
tests/TESTING.md
**/*.md
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Do not use decorative bold text in body content; use single backticks for inline code and
--for asides. In Python docstrings, use double backticks and MkDocs autorefs rather than Sphinx roles.
Files:
tests/TESTING.md
🧠 Learnings (3)
📚 Learning: 2026-05-27T22:20:37.354Z
Learnt from: kendrickb-nvidia
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 520
File: tests/generation/test_vllm_backend.py:556-587
Timestamp: 2026-05-27T22:20:37.354Z
Learning: In NVIDIA-NeMo/Safe-Synthesizer, `tests/conftest.py`’s `pytest_collection_modifyitems` hook applies pytest category markers automatically based on each test file’s path: tests under `/e2e/` get `pytest.mark.e2e`, tests under `/smoke/` get `pytest.mark.smoke`, and all other tests get `pytest.mark.unit`. Therefore, when reviewing pytest tests outside `tests/e2e/` and `tests/smoke/`, do not flag missing explicit `pytest.mark.unit` decorators on test classes/functions as an issue (the hook will add them during collection). If a new test directory/category is introduced, ensure the hook is updated so it’s categorized correctly.
Applied to files:
tests/conftest.pytests/test_pytest_configuration.py
📚 Learning: 2026-07-27T22:07:22.590Z
Learnt from: binaryaaron
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 673
File: tests/pii_replacer/test_edit.py:327-327
Timestamp: 2026-07-27T22:07:22.590Z
Learning: When tests read structured logging context from Python `logging.LogRecord` instances, don’t access `record.ctx` directly (it isn’t declared on `LogRecord` and will break static typing). Instead, use `getattr(record, "ctx", default)` (or an appropriate fallback) to safely handle cases where `ctx` may or may not be attached. This applies even if Ruff rule `B009` isn’t enabled in the repo.
Applied to files:
tests/conftest.pytests/test_pytest_configuration.py
📚 Learning: 2026-07-29T17:12:32.642Z
Learnt from: zywind
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 654
File: tests/config/test_parameters.py:116-118
Timestamp: 2026-07-29T17:12:32.642Z
Learning: In Pydantic validation tests (e.g., models configured with `from_attributes`), when asserting failures from `model_validate(...)`, assert the structured error details (such as `ValidationError.errors()[0]["type"]`, e.g. `"model_attributes_type"`) rather than relying on the human-readable error message text. This keeps tests stable even if wording changes, while still verifying the correct validation rule is triggered.
Applied to files:
tests/conftest.pytests/test_pytest_configuration.py
🔇 Additional comments (4)
.mise.gpu-ci.toml (1)
4-5: LGTM!.github/workflows/gpu-tests.yml (1)
108-128: LGTM!Also applies to: 161-161
tests/TESTING.md (1)
101-101: LGTM!Also applies to: 119-132
.github/actions/detect-changes/action.yml (1)
87-87: 🗄️ Data Integrity & IntegrationNo change needed.
src_test_depsincludes thecifilter, which matches.mise.gpu-ci.toml, and both GPU jobs use this output.> Likely an incorrect or invalid review comment.
9799cc3 to
06fab77
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Summary
requires_gputests when CUDA is unavailableTest plan
mise run formatmise run checkrequires_gputests skipped as intendedmise run test: 1,688 passed and 5 skipped; unrelated telemetry failures are tracked separatelySummary by CodeRabbit