Skip to content

Conversation

@Cunxiao2002
Copy link
Contributor

@Cunxiao2002 Cunxiao2002 commented Sep 5, 2025

Adds a timeout to pytest runs in CI to prevent jobs from hanging indefinitely. This also adds pytest-timeout to the test requirements.

Summary by CodeRabbit

  • Tests

    • Enforced per-test timeouts in automated test runs to prevent hangs and improve reliability while keeping existing reporting and parallelization.
  • Chores

    • Updated CI workflows to add test timeouts without changing other steps.
    • Added pytest-timeout to test dependencies to support the new timeout behavior.
  • Notes

    • No changes to product functionality or public interfaces.

Adds a timeout to pytest runs in CI to prevent jobs from hanging indefinitely.
This also adds `pytest-timeout` to the test requirements.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds the pytest-timeout dependency and updates two CI workflows to pass a per-test timeout flag (--timeout=3600) to pytest; existing pytest flags are unchanged. No other workflow steps or source code were modified.

Changes

Cohort / File(s) Summary of Changes
CI workflows
.github/workflows/amd_ci.yml, .github/workflows/ci.yml
Appended --timeout=3600 to existing pytest invocations (existing flags like -n 4 -v -r fE --durations=0 retained). No other workflow logic changed.
Test dependencies
requirements-test.txt
Added pytest-timeout to test requirements (inserted after pytest-durations).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant DevOps as CI Runner
    participant Pytest as pytest
    note right of DevOps #DDEBF7: workflow job invokes test command
    DevOps->>Pytest: Run `pytest ... --durations=0 --timeout=3600`
    alt test completes within timeout
        Pytest-->>DevOps: Exit 0 (success) 
    else timeout exceeded
        Pytest-->>DevOps: Timeout (non-zero exit) 
    end
    note left of Pytest #F7F7F7: pytest-timeout enforces per-test cap
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • LeiWang1999

Poem

Hop, I guard the testy lair,
A timeout burrow hides my care.
3600 ticks I kindly lend,
So rogue tests don’t never end.
CI carrots crunch—no endless blend. 🐰⏱️

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Cunxiao2002, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the CI pipeline by introducing a timeout mechanism for pytest test runs. This change ensures that CI jobs complete within a reasonable timeframe, preventing indefinite hangs and providing more reliable feedback on test execution status.

Highlights

  • Pytest Timeout in CI: Implemented a timeout for pytest runs within the Continuous Integration (CI) pipeline to prevent jobs from hanging indefinitely.
  • New Dependency Added: Added the pytest-timeout package to the requirements-test.txt file, making it available for test environments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Sep 5, 2025

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run bash format.sh in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work!

🚀

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds pytest-timeout to the test dependencies. However, it's missing the crucial step of configuring the timeout value. As a result, the plugin won't be active, and the goal of preventing hanging CI jobs is not met. I've left a specific comment with suggestions on how to configure the timeout.

pytest>=6.2.4
pytest_xdist>=2.2.1
pytest-durations
pytest-timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Adding pytest-timeout is the first step, but the timeout itself is not configured anywhere in this PR. Without configuration, the plugin will not be active, and tests can still hang indefinitely. To fix this, you need to set a timeout value. You can do this, for example, by adding timeout = 600 (for a 10-minute timeout) under the [pytest] section of a pytest.ini file, or by adding the --timeout=600 flag to your pytest command in your CI scripts.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/ci.yml (1)

121-121: Good addition; also cover the examples test run.

--timeout=200 is fine. To ensure consistency, apply the same flag to the earlier “Run examples” pytest invocation so hanging example tests don’t slip through.

You can update that step’s command to:

python -m pytest -n 4 **/test*.py -v -r fE --durations=0 --timeout=200

Optionally centralize via pytest.ini/pyproject.toml addopts (e.g., addopts = "-n 4 -v -r fE --durations=0 --timeout=200") to avoid divergence across workflows.

.github/workflows/amd_ci.yml (1)

118-118: Add a trailing newline.

YAML linter flags “no new line character at the end of file”.

requirements-test.txt (1)

16-16: Dependency addition looks good; consider version pinning.

Adding pytest-timeout unblocks the new flag. Consider pinning (exact or minimum) aligned with your pytest/xdist versions to reduce resolver drift in CI.

If helpful, I can propose a pin after checking what versions you currently resolve in CI.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cda5ea1 and f886213.

📒 Files selected for processing (3)
  • .github/workflows/amd_ci.yml (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • requirements-test.txt (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/amd_ci.yml

[error] 118-118: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: bot-task

cd testing/python/amd
unset PYTHONPATH
python -m pytest -v test_tilelang_test_amd.py --durations=0
python -m pytest -v test_tilelang_test_amd.py --durations=0 --timeout=200
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

AMD job will fail without pytest-timeout installed.

This adds --timeout=200, but the AMD venv installs from requirements-rocm.txt (not requirements-test.txt), which doesn’t include pytest-timeout. Pytest will error with “unrecognized arguments: --timeout=200”.

Please ensure the plugin is present in the AMD environment. For example, in the “Ensure venv (local & persistent)” step after installing requirements-rocm.txt:

PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-rocm.txt
pip install pytest-timeout

Or add pytest-timeout to requirements-rocm.txt.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 118-118: no new line character at the end of file

(new-line-at-end-of-file)

🤖 Prompt for AI Agents
.github/workflows/amd_ci.yml around line 118: the AMD CI runs pytest with
--timeout=200 but the AMD virtualenv installs requirements-rocm.txt which
doesn’t include the pytest-timeout plugin, causing pytest to error with
"unrecognized arguments: --timeout=200"; fix by ensuring pytest-timeout is
installed into the AMD venv—either add a pip install pytest-timeout step
immediately after installing requirements-rocm.txt in the "Ensure venv (local &
persistent)" step, or add pytest-timeout to requirements-rocm.txt so the plugin
is present when pytest runs.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/amd_ci.yml (1)

118-118: AMD pytest will error unless pytest-timeout is installed in the ROCm venv

AMD job installs only requirements-rocm.txt; without adding pytest-timeout, pytest will fail with “unrecognized arguments: --timeout=3600”. Either add pytest-timeout to requirements-rocm.txt (preferred) or explicitly install it in the AMD venv (cover both reuse and recreate paths).

Option A (preferred): add pytest-timeout to requirements-rocm.txt.

Option B: explicitly install in workflow. Minimal patch:

@@
       if [[ -f "$MARKER" ]] && [[ -f "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" ]]; then
         echo "venv exists and hash matches – reuse it"
       else
@@
           if [[ -f requirements-rocm.txt ]]; then
             pip install --pre torch torchvision torchaudio --index-url ${{ env.PYTORCH_INDEX_URL }}
             PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-rocm.txt
+            pip install pytest-timeout
           fi
@@
         fi
+
+    - name: Ensure pytest-timeout plugin (idempotent)
+      run: |
+        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate"
+        python - <<'PY'
+import sys
+try:
+    import pytest_timeout  # noqa: F401
+    print("pytest-timeout present")
+except Exception:
+    sys.exit("pytest-timeout missing")
+PY
🧹 Nitpick comments (1)
.github/workflows/amd_ci.yml (1)

118-118: Add newline at EOF to satisfy yamllint

Fix the “no new line character at the end of file” warning.

-        python -m pytest -v test_tilelang_test_amd.py --durations=0 --timeout=3600
+        python -m pytest -v test_tilelang_test_amd.py --durations=0 --timeout=3600
+
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f886213 and 403577d.

📒 Files selected for processing (2)
  • .github/workflows/amd_ci.yml (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/amd_ci.yml

[error] 118-118: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: format-check
  • GitHub Check: bot-task
🔇 Additional comments (1)
.github/workflows/amd_ci.yml (1)

118-118: Timeout values consistent across workflows
Both ci.yml and amd_ci.yml set --timeout=3600 per test; no discrepancies found. Proceed if 3600 s is the intended timeout.

@LeiWang1999 LeiWang1999 merged commit bcfc834 into tile-ai:main Sep 6, 2025
4 of 5 checks passed
@Cunxiao2002 Cunxiao2002 deleted the pytest_timeout branch September 13, 2025 07:51
@coderabbitai coderabbitai bot mentioned this pull request Sep 16, 2025
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.

2 participants