Skip to content

fix(benchmarks): isolate router benchmark imports - #14745

Merged
jthomson04 merged 3 commits into
mainfrom
jthomson04/fix-router-benchmark-import-isolation
Sep 11, 2026
Merged

jthomson04 merged 3 commits into
mainfrom
jthomson04/fix-router-benchmark-import-isolation

Conversation

@jthomson04

@jthomson04 jthomson04 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix the pytest import collision introduced by #14165. Collecting the router benchmark loaded benchmarks/router/common.py as the top-level common module, which prevented component tests from importing common.backend and common.utils.

  • Remove benchmarks/router from the test setup's sys.path; retain the parent path required by prefix_data_generator.
  • Move the priority-tagging helper into benchmarks/router/common.py and import both tested helpers through benchmarks.router.common. Pytest no longer imports the CLI script.
  • Keep the priority benchmark as a directly executed script, using the same helper imports as the other router benchmarks. No __package__ conditional is needed.
  • Keep the three existing OSL/priority behavior tests with explicit CI markers. Add no new tests or fixtures.

The same No module named 'common.backend'; 'common' is not a package error appears in both:

This change is limited to benchmark import isolation. Trace-hint behavior and CI configuration are unchanged.

Validation

Checked the revised patch in the local dynamo:dev container with Python 3.12.3, the worktree mounted at /workspace, and source paths for components, Python bindings, and benchmarks on PYTHONPATH.

  • Ran python3 -m pytest -c pyproject.toml benchmarks/router/tests/test_common.py components/src/dynamo/common/backend/tests components/src/dynamo/common/utils/tests -n 0 -q --tb=short --continue-on-collection-errors --junitxml=..., then repeated with both component paths before the benchmark path. Each run completed with 3 passed, 6 skipped, 41 errors, confirmed in JUnit. The three benchmark tests passed in both orders; neither log contained the common collision.
  • Full component validation remains blocked by missing native bindings in this local image, including AicPerfConfig and dynamo._core.backend. These runs are not a passing component-suite result; the affected suites still require validation in the CI image.
  • Standalone python3 real_data_priority_benchmark.py --help: passed with PYTHONPATH=/workspace/benchmarks and MPLBACKEND=Agg.
  • pre-commit run --files benchmarks/router/common.py benchmarks/router/real_data_priority_benchmark.py benchmarks/router/tests/conftest.py benchmarks/router/tests/test_common.py: passed.
  • git diff --check: passed.

Keep benchmark collection from occupying the top-level common module used
by component test packages. Preserve direct script invocation and cover
both import orders in isolated subprocesses.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: jthomson04 <[email protected]>
@jthomson04
jthomson04 requested review from a team as code owners September 11, 2026 21:19
@copy-pr-bot

copy-pr-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 766fbaf9-1eb0-49f6-8fda-345cf081e3ff

📥 Commits

Reviewing files that changed from the base of the PR and between d7d1b59 and 6db4a49.

📒 Files selected for processing (3)
  • benchmarks/router/real_data_priority_benchmark.py
  • benchmarks/router/tests/conftest.py
  • benchmarks/router/tests/test_common.py

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


Walkthrough

The router priority benchmark now supports package and standalone execution. Tests configure an isolated benchmark environment and validate imports with a preloaded unrelated common package, plus CLI help in both execution modes.

Changes

Router benchmark import compatibility

Layer / File(s) Summary
Package-aware imports
benchmarks/router/real_data_priority_benchmark.py, benchmarks/router/tests/test_common.py
The benchmark uses relative helper imports when loaded as a package and absolute imports when run as a script. Tests use benchmarks.router package imports.
Environment and execution validation
benchmarks/router/tests/conftest.py, benchmarks/router/tests/test_common.py
The test fixture configures paths and Matplotlib for subprocesses. Tests validate unrelated common package resolution and --help execution as a module and script.

Priority: ⬇️ Low

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

Merge Risk: ⚪ Minimal · up to 6db4a

The import-isolation change retains both package and standalone execution paths, with targeted subprocess and CLI coverage. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed scope, implementation details, affected errors, and validation results. However, it omits the required Related Issues section and does not identify where the reviewer… Add the required Related Issues section with either a valid issue reference or the confirmed no-related-issue checkbox. Add a Where should the reviewer start? section that names the key files for review.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: isolating router benchmark imports to fix import collisions.
Full details: Description check

Explanation

The description provides detailed scope, implementation details, affected errors, and validation results. However, it omits the required Related Issues section and does not identify where the reviewer should start.

  • Fix all pre-merge checks with AI

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

@pull-request-size pull-request-size Bot added size/M and removed size/L labels Sep 11, 2026
@jthomson04

Copy link
Copy Markdown
Contributor Author

/ok to test 37a3de7

@jthomson04
jthomson04 enabled auto-merge (squash) September 11, 2026 21:54
@jthomson04
jthomson04 merged commit 062a495 into main Sep 11, 2026
110 checks passed
@jthomson04
jthomson04 deleted the jthomson04/fix-router-benchmark-import-isolation branch September 11, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants