[TRTLLMINF-191][infra] Preserve pytest progress with S3 capture#16268
[TRTLLMINF-191][infra] Preserve pytest progress with S3 capture#16268niukuo wants to merge 1 commit into
Conversation
Signed-off-by: Yiteng Niu <6831097+niukuo@users.noreply.github.com>
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughThe PR updates ChangesTest output handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@tests/test_common/s3_output.py`:
- Around line 381-399: Add explicit type annotations and concise docstrings to
the pytest_runtest_setup, pytest_runtest_makereport, and pytest_runtest_teardown
hook methods, documenting when each starts, closes, or falls back for S3 capture
lifecycle management. Use appropriate pytest hook argument, generator/yield, and
report types consistent with the existing implementation.
In `@tests/unittest/test_s3_output.py`:
- Around line 24-36: Add parameter and return type annotations throughout the
new `Report` and `CaptureContext` constructors, helper functions, and test
functions in the test module; use `-> None` for constructors, helpers, and tests
that do not return a value, and annotate optional parameters and other values
appropriately.
In `@tests/unittest/tools/test_test_to_stage_mapping.py`:
- Around line 100-101: Harden the test around the existing
`console_output_style=progress-even-when-capture-no` assertion by also verifying
that the matching configuration line is guarded by `if
(ENABLE_UPLOAD_TEST_RESULTS)`. Update the relevant test in
`test_test_to_stage_mapping.py` to inspect nearby lines or the generated
configuration structure, ensuring non-upload pytest jobs remain unchanged and
the upload-only contract is covered.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9d6b58f3-3046-4e0c-9973-0d2de5e9cb9d
📒 Files selected for processing (4)
jenkins/L0_Test.groovytests/test_common/s3_output.pytests/unittest/test_s3_output.pytests/unittest/tools/test_test_to_stage_mapping.py
| @pytest.hookimpl(wrapper=True) | ||
| def pytest_runtest_makereport(self, item, call): | ||
| report = yield | ||
| if report.when == "call" or (report.when == "setup" and report.outcome != "passed"): | ||
| self._close_capture(self._active_capture.pop(item.nodeid, None)) | ||
| return report | ||
|
|
||
| @pytest.hookimpl(wrapper=True) | ||
| def pytest_runtest_teardown(self, item, nextitem): | ||
| # Stop capturing BEFORE teardown runs, so the captured log files are | ||
| # final by the time we upload in pytest_runtest_logreport(teardown). | ||
| self._close_capture(self._active_capture.pop(item.nodeid, None)) | ||
| # Fallback for custom or interrupted runtest protocols that did not | ||
| # produce a call report. Normal execution closes capture earlier. | ||
| state = self._active_capture.pop(item.nodeid, None) | ||
| self._close_capture(state) | ||
| if state is not None: | ||
| logger.warning( | ||
| "S3 capture for %r remained active until teardown; " | ||
| "pytest result/progress output may have been captured", | ||
| item.nodeid, | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
python3 - <<'PY'
from pathlib import Path
path = Path("tests/test_common/s3_output.py")
text = path.read_text()
lines = text.splitlines()
# Print a focused window around the commented lines.
start, end = 340, 430
for i in range(start, min(end, len(lines)) + 1):
print(f"{i:4d}: {lines[i-1]}")
PYRepository: NVIDIA/TensorRT-LLM
Length of output: 4001
Annotate the new pytest hooks
pytest_runtest_setup, pytest_runtest_makereport, and pytest_runtest_teardown should have explicit type hints and short docstrings describing the capture-lifetime contract.
🤖 Prompt for 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.
In `@tests/test_common/s3_output.py` around lines 381 - 399, Add explicit type
annotations and concise docstrings to the pytest_runtest_setup,
pytest_runtest_makereport, and pytest_runtest_teardown hook methods, documenting
when each starts, closes, or falls back for S3 capture lifecycle management. Use
appropriate pytest hook argument, generator/yield, and report types consistent
with the existing implementation.
Source: Coding guidelines
| class Report: | ||
| def __init__(self): | ||
| def __init__(self, when=None, outcome=None): | ||
| self.sections = [] | ||
| self.when = when | ||
| self.outcome = outcome | ||
|
|
||
|
|
||
| class CaptureContext: | ||
| def __init__(self): | ||
| self.closed = False | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| self.closed = True |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
python3 - <<'PY'
from pathlib import Path
path = Path("tests/unittest/test_s3_output.py")
text = path.read_text()
for i, line in enumerate(text.splitlines(), 1):
if 1 <= i <= 220:
print(f"{i:4d}: {line}")
PYRepository: NVIDIA/TensorRT-LLM
Length of output: 8756
Annotate the new helpers and tests. tests/unittest/test_s3_output.py:24-125 should add parameter and return type annotations for the new constructors, helper functions, and test functions (-> None where applicable).
🤖 Prompt for 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.
In `@tests/unittest/test_s3_output.py` around lines 24 - 36, Add parameter and
return type annotations throughout the new `Report` and `CaptureContext`
constructors, helper functions, and test functions in the test module; use `->
None` for constructors, helpers, and tests that do not return a value, and
annotate optional parameters and other values appropriately.
Source: Coding guidelines
| assert any('console_output_style=progress-even-when-capture-no' in line | ||
| for line in lines) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the upload-only guard as well.
Coverage is insufficient: this passes if the option becomes unconditional, changing all non-upload pytest jobs. Locate matching lines and assert they are guarded by if (ENABLE_UPLOAD_TEST_RESULTS).
Proposed test hardening
- assert any('console_output_style=progress-even-when-capture-no' in line
- for line in lines)
+ progress_lines = [
+ idx for idx, line in enumerate(lines)
+ if 'console_output_style=progress-even-when-capture-no' in line
+ ]
+ assert progress_lines
+ for idx in progress_lines:
+ context = lines[max(0, idx - 3):idx]
+ assert any('if (ENABLE_UPLOAD_TEST_RESULTS)' in line for line in context)As per path instructions, test feedback must state whether coverage is sufficient; coverage is insufficient for the upload-only configuration contract.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert any('console_output_style=progress-even-when-capture-no' in line | |
| for line in lines) | |
| progress_lines = [ | |
| idx for idx, line in enumerate(lines) | |
| if 'console_output_style=progress-even-when-capture-no' in line | |
| ] | |
| assert progress_lines | |
| for idx in progress_lines: | |
| context = lines[max(0, idx - 3):idx] | |
| assert any('if (ENABLE_UPLOAD_TEST_RESULTS)' in line for line in context) |
🤖 Prompt for 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.
In `@tests/unittest/tools/test_test_to_stage_mapping.py` around lines 100 - 101,
Harden the test around the existing
`console_output_style=progress-even-when-capture-no` assertion by also verifying
that the matching configuration line is guarded by `if
(ENABLE_UPLOAD_TEST_RESULTS)`. Update the relevant test in
`test_test_to_stage_mapping.py` to inspect nearby lines or the generated
configuration structure, ensuring non-upload pytest jobs remain unchanged and
the upload-only contract is covered.
Source: Path instructions
|
PR_Github #58734 [ run ] triggered by Bot. Commit: |
|
PR_Github #58734 [ run ] completed with state
|
|
/bot skip --comment "ci part passed" |
|
PR_Github #58922 [ skip ] triggered by Bot. Commit: |
|
PR_Github #58922 [ skip ] completed with state |
Summary by CodeRabbit
Bug Fixes
Tests
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.