Skip to content

Conversation

@hhzhang16
Copy link
Contributor

@hhzhang16 hhzhang16 commented Sep 10, 2025

Overview:

Details:

Where should the reviewer start?

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

Summary by CodeRabbit

  • Refactor

    • Consolidated Python path configuration in container images and made it inherited across stages, reducing duplication and improving consistency across frameworks.
  • Chores

    • Extended the environment to include profiling components, ensuring smoother module discovery in both development and runtime containers.
    • Standardized container setup to align development and runtime behavior, improving reliability and reducing environment mismatches.

Signed-off-by: Hannah Zhang <hannahz@nvidia.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Walkthrough

The Dockerfiles adjust PYTHONPATH entries. For sglang, /workspace/benchmarks/profiler is added to PYTHONPATH in both base and development stages. For vLLM, PYTHONPATH is centralized in the framework stage with multiple component paths (including benchmarks/profiler) and is inherited by later stages, removing per-stage duplication.

Changes

Cohort / File(s) Summary
SGLang Docker PYTHONPATH update
container/Dockerfile.sglang
Added /workspace/benchmarks/profiler to PYTHONPATH in base ENV and appended ${WORKSPACE_DIR}/benchmarks/profiler in development stage.
vLLM Docker PYTHONPATH refactor
container/Dockerfile.vllm
Defined a comprehensive PYTHONPATH in the framework stage covering components/* and /workspace/benchmarks/profiler, preserving $PYTHONPATH. Removed explicit PYTHONPATH in development; now inherits from runtime/framework stages.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Build as Docker Build
    participant Framework as Framework Stage
    participant Runtime as Runtime Stage
    participant Dev as Development Stage

    Build->>Framework: Build framework image
    Note over Framework: Set ENV PYTHONPATH with components/* and /workspace/benchmarks/profiler
    Framework-->>Runtime: Inherit ENV PYTHONPATH
    Runtime-->>Dev: Inherit ENV PYTHONPATH (no redefinition)
    Note over Dev: Uses inherited PYTHONPATH during development
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The current pull request description contains only the templated headings with placeholder comments and no actual content in the Overview, Details, or Where to start sections, leaving key information about the changes and review pointers missing. Populate each template section with concrete information: provide a summary of the PYTHONPATH updates under Overview, detail the specific Dockerfile changes in Details, point reviewers to container/Dockerfile.sglang and container/Dockerfile.vllm in the reviewer start section, and reference the actual issue number in Related Issues.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title succinctly and accurately summarizes the primary change of updating the PYTHONPATH configuration in the runtime image, using concise phrasing that matches the core change set without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

In burrows of bytes I hop and compile,
New paths in my pack, I traverse with a smile.
From framework to runtime, the breadcrumbs align—
Profiler in tow, along the PYTHONPATH line.
Carrots of import, neatly inherited—so fine! 🥕🐇

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

@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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 905c920 and 21f10f6.

📒 Files selected for processing (2)
  • container/Dockerfile.sglang (2 hunks)
  • container/Dockerfile.vllm (2 hunks)
⏰ 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: Build and Test - dynamo
🔇 Additional comments (3)
container/Dockerfile.sglang (1)

250-250: PYTHONPATH update in runtime looks good.

Profiler is now discoverable at runtime; ordering preserves project paths ahead of inherited ones.

container/Dockerfile.vllm (2)

523-523: Dev inherits PYTHONPATH from runtime — nice removal of duplication.

Keeps stages consistent and reduces drift.


289-292: Manual verification required: confirm PYTHONPATH includes benchmarks/profiler in runtime images

The smoke‐test script couldn’t run (no docker available), so please manually verify in container/Dockerfile.vllm (lines 289–292) and in container/Dockerfile.sglang that the ENV PYTHONPATH setting indeed prepends /workspace/benchmarks/profiler (while preserving $PYTHONPATH) before the --target=runtime stage.

# Make sure to sync this with the one specified on README.md.
# This is a generic PYTHONPATH which works for all the frameworks, so some paths may not be relevant for this particular framework.
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src:${WORKSPACE_DIR}/benchmarks/profiler
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Don’t clobber inherited PYTHONPATH in dev stage; append $PYTHONPATH.

This overwrites the runtime PYTHONPATH (drops /workspace/examples/sglang/utils and any upstream additions). Append $PYTHONPATH for parity with vLLM and to avoid surprises.

Apply this diff:

-ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src:${WORKSPACE_DIR}/benchmarks/profiler
+ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src:${WORKSPACE_DIR}/benchmarks/profiler:$PYTHONPATH

Optionally also include ${WORKSPACE_DIR}/examples/sglang/utils if those imports are expected during dev.

📝 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
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src:${WORKSPACE_DIR}/benchmarks/profiler
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src:${WORKSPACE_DIR}/benchmarks/profiler:$PYTHONPATH
🤖 Prompt for AI Agents
In container/Dockerfile.sglang around line 323, the ENV PYTHONPATH currently
overwrites any inherited PYTHONPATH; change it to append the existing
$PYTHONPATH (and optionally include ${WORKSPACE_DIR}/examples/sglang/utils) so
upstream/runtime additions like /workspace/examples/sglang/utils are preserved —
update the ENV to add your listed component paths then include :$PYTHONPATH at
the end (also add ${WORKSPACE_DIR}/examples/sglang/utils into the list if those
imports are needed).

@saturley-hall
Copy link
Member

Thats great it is working for vLLM and SGLang, was trtllm tested? I don't see such an update (or PYTHONPATH being set at all) in that dockerfile

echo "cat ~/.launch_screen" >> ~/.bashrc && \
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc

# Set PYTHONPATH to include all component paths and benchmarks/profiler for utils module access
Copy link
Contributor

Choose a reason for hiding this comment

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

benchmarks is already installed in runtime image, see L270 -- why do we need to set python path here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Benchmarks is called as a module and requires helper functions in other files; as an alternative, I can have the profiling script set PYTHONPATH within the yaml file @nv-anants

Copy link
Contributor

Choose a reason for hiding this comment

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

can we include all the helper functions in benchmarks module itself? ideally we should not be setting pythonpath anywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

from config here seems like only data_gen dir is included in benchmarks install, adding profile here might solve it as well? https://github.com/ai-dynamo/dynamo/blob/main/benchmarks/pyproject.toml#L63

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think https://github.com/ai-dynamo/dynamo/pull/2857/files has the fix you're referring to, but it doesn't appear to be in the release branch; this could also be why images I built locally (which includes this MR's changes) work properly without the need to set PYTHONPATH. I just built a runtime image locally (undoing the changes in this MR, but with !2857's changes in main) and the import issue reported in bug is resolved. Could we just cherry pick !2857 to the release branch? cc @tedzhouhk

Copy link
Contributor

Choose a reason for hiding this comment

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

sure yeah, that one looks good to me

# Make sure to sync this with the one specified on README.md.
# This is a generic PYTHONPATH which works for all the frameworks, so some paths may not be relevant for this particular framework.
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src
# PYTHONPATH is inherited from the runtime stage
Copy link
Contributor

Choose a reason for hiding this comment

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

please dont set python path in runtime image -- everything should be used from venv install there. dev image uses python path for dev purposes

COPY ATTRIBUTION* LICENSE /workspace/

ENV PYTHONPATH=/workspace/examples/sglang/utils:$PYTHONPATH
ENV PYTHONPATH=/workspace/examples/sglang/utils:/workspace/benchmarks/profiler:$PYTHONPATH
Copy link
Contributor

Choose a reason for hiding this comment

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

same as vllm -- benchmarks is installed in L240, why do we need this?

@hhzhang16 hhzhang16 closed this Sep 10, 2025
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.

4 participants