Skip to content

chore: fix the python dependency override#2651

Merged
yongwww merged 2 commits intoflashinfer-ai:mainfrom
yongwww:fix_py_override
Mar 25, 2026
Merged

chore: fix the python dependency override#2651
yongwww merged 2 commits intoflashinfer-ai:mainfrom
yongwww:fix_py_override

Conversation

@yongwww
Copy link
Copy Markdown
Member

@yongwww yongwww commented Feb 27, 2026

📌 Description

Fix the python dependency override

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

Summary by CodeRabbit

  • Chores
    • Adjusted unit test flow so test discovery and execution occur after dependencies and overrides are finalized, improving accuracy of which tests run.
    • Ensured test environment overrides are re-applied after dependency installation to maintain consistent test conditions and reduce flakiness.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses an issue where Python dependency overrides were not being correctly applied during unit test execution. By strategically reordering and adding a second sourcing of the environment setup script, the changes ensure that custom dependency configurations persist after package installations, leading to a more robust and predictable test environment.

Highlights

  • Dependency Override Fix: The setup_test_env.sh script, which handles Python dependency overrides, is now sourced a second time after the install_and_verify step. This ensures that any package overrides are applied after pip installations, preventing them from being inadvertently overwritten.
  • Script Sourcing Order: The initial sourcing of setup_test_env.sh in scripts/task_run_unit_tests.sh was reordered to occur after test_utils.sh is sourced, streamlining the script's setup flow.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • scripts/task_run_unit_tests.sh
    • Moved the initial sourcing of setup_test_env.sh to occur after test_utils.sh.
    • Added a new sourcing of setup_test_env.sh after the install_and_verify function call to re-apply dependency overrides.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56d9ac69-c98a-4c8f-b618-94eb11c3b86b

📥 Commits

Reviewing files that changed from the base of the PR and between 7399403 and 56c6d11.

📒 Files selected for processing (1)
  • scripts/task_run_unit_tests.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/task_run_unit_tests.sh

📝 Walkthrough

Walkthrough

Removed early sourcing of setup_test_env.sh and now re-source it immediately after install_and_verify, shifting pytest discovery/exclusion and test execution to occur after dependency overrides are reapplied post-installation.

Changes

Cohort / File(s) Summary
Test script
scripts/task_run_unit_tests.sh
Removed initial setup_test_env.sh sourcing before dependency install; added sourcing after install_and_verify to reapply dependency/package overrides; moved pytest discovery/exclusion and test run to occur after the post-install re-source.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI Runner
  participant Script as task_run_unit_tests.sh
  participant Installer as pip / install_and_verify
  participant Setup as setup_test_env.sh
  participant Pytest as pytest

  CI->>Script: start test job
  Script->>Installer: install_and_verify (pip install)
  Installer-->>Script: install complete
  Script->>Setup: source setup_test_env.sh (reapply overrides)
  Script->>Pytest: discover tests (apply norecursedirs), run tests
  Pytest-->>Script: test results
  Script-->>CI: exit status / results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • yzh119
  • cyx-6
  • nvmbreughe
  • kahyunnam
  • jimmyzho

Poem

🐰 I hopped into the script at dawn,
Moved my crumbs till installs were done,
Now overrides bloom after pip’s parade,
Tests find their paths, no shortcuts made,
A tiny hop, a cleaner run—hooray! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the Python dependency override in a shell script.
Description check ✅ Passed The description follows the template structure with the key section '📌 Description' filled in, though other details like related issues and reviewer notes are minimal or absent.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

Copy link
Copy Markdown
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 fixes an issue where Python dependency overrides were being overwritten by sourcing setup_test_env.sh after the install_and_verify step. However, the initial source call for setup_test_env.sh at the top of the script is now redundant. I've added a comment suggesting its removal to improve script efficiency and maintainability.

Comment on lines +14 to +15
# Source test environment setup (handles package overrides like TVM-FFI)
source "${SCRIPT_DIR}/setup_test_env.sh"
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.

medium

This source call for setup_test_env.sh is redundant. The script is sourced again within the main function on line 85, which is the correct location to ensure dependency overrides are applied after install_and_verify. Sourcing it here is inefficient as it performs an installation that may be immediately overwritten. This block can be removed to avoid the redundant operation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@yongwww makes sense to me can we strive to do it in one place and make it count?

based on the fact you moved it after test_utils.sh so i assume there is no dependency there either, so there's nothing depending on this line anywhere

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

resolved

@yongwww
Copy link
Copy Markdown
Member Author

yongwww commented Feb 27, 2026

cc: @dierksen

Copy link
Copy Markdown
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.

🧹 Nitpick comments (2)
scripts/task_run_unit_tests.sh (2)

14-16: Consider adding shellcheck disable comment for consistency.

Line 12 uses # shellcheck disable=SC1091 for sourcing test_utils.sh, but this sourcing of setup_test_env.sh lacks the same directive. For consistency and to suppress potential shellcheck warnings about files not found during static analysis:

Proposed fix
-# Source test environment setup (handles package overrides like TVM-FFI)
-source "${SCRIPT_DIR}/setup_test_env.sh"
+# Source test environment setup (handles package overrides like TVM-FFI)
+# shellcheck disable=SC1091  # File exists, checked separately
+source "${SCRIPT_DIR}/setup_test_env.sh"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/task_run_unit_tests.sh` around lines 14 - 16, Add a shellcheck
suppression comment before sourcing setup_test_env.sh to match the existing
pattern (like the existing "# shellcheck disable=SC1091" used for
test_utils.sh); specifically, insert the same "# shellcheck disable=SC1091"
directive immediately above the source "${SCRIPT_DIR}/setup_test_env.sh" line so
static analysis won't warn about the sourced file not being found.

84-86: The fix for re-applying dependency overrides is correct.

Re-sourcing setup_test_env.sh after install_and_verify ensures pip doesn't overwrite the intended dependency overrides. The comment clearly explains the rationale.

Regarding idempotency: setup_test_env.sh sources environment variables idempotently, but runs pip install --force-reinstall unconditionally when TVM_FFI_REF is set. In the current usage context, the script is sourced once, so this works fine. However, if this script were sourced multiple times, the pip install would execute repeatedly. Consider guarding the pip install (e.g., with a flag variable) to make the script truly idempotent for future robustness.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/task_run_unit_tests.sh` around lines 84 - 86, The re-source of
setup_test_env.sh is correct but its unconditional pip install when TVM_FFI_REF
is set makes repeated sourcing non-idempotent; modify setup_test_env.sh to guard
the pip install with a sentinel (e.g., a variable like SETUP_TEST_ENV_PIP_DONE)
so that when TVM_FFI_REF triggers the pip install (--force-reinstall) it only
runs once per shell session; locate the TVM_FFI_REF check and surrounding pip
install in setup_test_env.sh and add a conditional that sets and checks the
sentinel before running pip, ensuring subsequent sources skip the install.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@scripts/task_run_unit_tests.sh`:
- Around line 14-16: Add a shellcheck suppression comment before sourcing
setup_test_env.sh to match the existing pattern (like the existing "# shellcheck
disable=SC1091" used for test_utils.sh); specifically, insert the same "#
shellcheck disable=SC1091" directive immediately above the source
"${SCRIPT_DIR}/setup_test_env.sh" line so static analysis won't warn about the
sourced file not being found.
- Around line 84-86: The re-source of setup_test_env.sh is correct but its
unconditional pip install when TVM_FFI_REF is set makes repeated sourcing
non-idempotent; modify setup_test_env.sh to guard the pip install with a
sentinel (e.g., a variable like SETUP_TEST_ENV_PIP_DONE) so that when
TVM_FFI_REF triggers the pip install (--force-reinstall) it only runs once per
shell session; locate the TVM_FFI_REF check and surrounding pip install in
setup_test_env.sh and add a conditional that sets and checks the sentinel before
running pip, ensuring subsequent sources skip the install.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a337e42 and 7399403.

📒 Files selected for processing (1)
  • scripts/task_run_unit_tests.sh

Copy link
Copy Markdown
Contributor

@dierksen dierksen left a comment

Choose a reason for hiding this comment

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

Could you fix up the duplicate line per the bot suggestion?

@yongwww
Copy link
Copy Markdown
Member Author

yongwww commented Mar 20, 2026

@aleozlx @dierksen removed the first source, pls take another look

@yongwww yongwww merged commit aacc355 into flashinfer-ai:main Mar 25, 2026
31 of 36 checks passed
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