Skip to content

[TRTLLMINF-191][infra] Preserve pytest progress with S3 capture#16268

Open
niukuo wants to merge 1 commit into
NVIDIA:mainfrom
niukuo:test_output
Open

[TRTLLMINF-191][infra] Preserve pytest progress with S3 capture#16268
niukuo wants to merge 1 commit into
NVIDIA:mainfrom
niukuo:test_output

Conversation

@niukuo

@niukuo niukuo commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved test output readability when uploading test results.
    • Ensured captured test output is released at the correct reporting stage, keeping progress information visible.
    • Added a safe fallback for test runs where standard reporting stages are unavailable.
  • Tests

    • Added coverage for capture lifecycle handling and fallback warnings.
    • Extended validation of readable test progress output.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

Signed-off-by: Yiteng Niu <6831097+niukuo@users.noreply.github.com>
@niukuo niukuo requested review from a team as code owners July 11, 2026 03:11
@niukuo niukuo requested review from ZhanruiSunCh and mlefeb01 July 11, 2026 03:11
@niukuo

niukuo commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates UploadLogPlugin capture closure timing, adds lifecycle coverage for pytest report phases and teardown fallback, and enables pytest progress output when test results are uploaded.

Changes

Test output handling

Layer / File(s) Summary
Pytest capture lifecycle
tests/test_common/s3_output.py, tests/unittest/test_s3_output.py
Capture closes after call reports or failed setup reports, while teardown provides a warning-producing fallback; tests cover closure timing, report outcomes, and active-capture cleanup.
Progress output configuration
jenkins/L0_Test.groovy, tests/unittest/tools/test_test_to_stage_mapping.py
Uploaded test runs add pytest’s console_output_style=progress-even-when-capture-no option, with a corresponding configuration assertion.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: ZhanruiSunCh, dpitman-nvda, mzweilz

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description mostly contains the template placeholders and lacks filled Description and Test Coverage sections. Add a short Description explaining the issue and solution, plus Test Coverage listing the tests that validate the change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and matches the main change with the required ticket and type format.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8bcec87 and 10a276b.

📒 Files selected for processing (4)
  • jenkins/L0_Test.groovy
  • tests/test_common/s3_output.py
  • tests/unittest/test_s3_output.py
  • tests/unittest/tools/test_test_to_stage_mapping.py

Comment on lines +381 to +399
@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,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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]}")
PY

Repository: 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

Comment on lines 24 to +36
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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}")
PY

Repository: 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

Comment on lines +100 to +101
assert any('console_output_style=progress-even-when-capture-no' in line
for line in lines)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58734 [ run ] triggered by Bot. Commit: 10a276b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58734 [ run ] completed with state FAILURE. Commit: 10a276b
/LLM/main/L0_MergeRequest_PR pipeline #47317 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@niukuo

niukuo commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "ci part passed"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58922 [ skip ] triggered by Bot. Commit: 10a276b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58922 [ skip ] completed with state SUCCESS. Commit: 10a276b
Skipping testing for commit 10a276b

Link to invocation

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.

3 participants