Skip to content

Conversation

@biswapanda
Copy link
Contributor

@biswapanda biswapanda commented May 29, 2025

Overview:

Decouple dynamo from bentoml as a hard dependency

  • Removed bentoml dependency
  • Deleted: All BentoML related code

Where should the reviewer start?

More details in
#1266 (comment)

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

  • closes GitHub issue: #xxx

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved Docker image builds by removing redundant package uninstall/reinstall steps.
  • Chores

    • Removed the dependency on BentoML and related CLI/API features from the SDK.
    • Updated type checking configuration and cleaned up imports and type annotations.
    • Simplified and standardized CLI commands and deployment scripts.
    • Removed internal service, dependency, and pipeline management code related to BentoML integration.
    • Refactored lifecycle hooks to replace asynchronous shutdown with synchronous shutdown support.
    • Enhanced graceful shutdown behavior with new shutdown hook registration and signal handling.
    • Updated documentation and examples to reflect lifecycle hook changes.
    • Cleaned up service loading and interface references for consistency.
  • New Features

    • Added a synchronous shutdown decorator for improved lifecycle management.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

This update removes all BentoML-specific integration and dependency management from the Dynamo SDK. It deletes modules and classes related to BentoML service adaptation, dependency injection, and CLI management of Bento bundles and pipelines. Dockerfiles are simplified by eliminating redundant package management steps. The deployment script and SDK imports are updated to reflect these removals and new interfaces.

Changes

Files/Paths Change Summary
container/Dockerfile.sglang, container/Dockerfile.tensorrt_llm, container/Dockerfile.vllm Removed redundant/unnecessary uninstall and reinstall steps for kantoku and circus Python packages.
deploy/helm/deploy.sh Updated Helm values file path from BentoML-based to Dynamo-specific location.
pyproject.toml Removed bentoml dependency; narrowed mypy skip list to only vllm.*.
deploy/sdk/src/dynamo/sdk/init.py Changed import source for async_on_shutdown to Dynamo SDK's decorators; replaced with on_shutdown.
deploy/sdk/src/dynamo/sdk/cli/allocator.py Switched from BentoML Service to ServiceInterface for type annotations; removed unused imports/decorators.
deploy/sdk/src/dynamo/sdk/cli/build.py Explicitly cast output_path to string in Docker build subprocess call.
deploy/sdk/src/dynamo/sdk/cli/cli.py Removed CLI registration for the get command from pipeline management.
deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py Removed all BentoML container/context setup and related environment variables; added graceful shutdown hooks.
deploy/sdk/src/dynamo/sdk/cli/serving.py Simplified serve_dynamo_graph to only accept string pipeline identifiers; removed service instance support.
deploy/sdk/src/dynamo/sdk/lib/decorators.py Added type variable for decorators; introduced new on_shutdown decorator replacing async_on_shutdown.
deploy/sdk/src/dynamo/sdk/lib/loader.py Replaced DynamoService references with ServiceInterface throughout.
deploy/sdk/src/dynamo/sdk/cli/bento_util.py, deploy/sdk/src/dynamo/sdk/cli/bentos.py, deploy/sdk/src/dynamo/sdk/cli/pipeline.py Deleted: All CLI and utility code for BentoML bento/pipeline management.
deploy/sdk/src/dynamo/sdk/core/runner/bentoml.py Deleted: All BentoML service/dependency adapters and deployment target integration.
deploy/sdk/src/dynamo/sdk/lib/dependency.py Deleted: All Dynamo-specific dependency/client management code.
deploy/sdk/src/dynamo/sdk/lib/service.py Deleted: All DynamoService and related config/decorator code.
examples/tensorrt_llm/common/utils.py Added type alias AsyncTask for asynchronous callable annotations in ManagedThread.
examples/hello_world/hello_world.py Added @on_shutdown lifecycle hooks with shutdown logging to Backend, Middle, and Frontend services.
examples/llm/components/frontend.py Replaced @async_on_shutdown with @on_shutdown decorator on Frontend.cleanup method.
docs/API/sdk.md Updated lifecycle hook documentation to use @on_shutdown instead of @async_on_shutdown with synchronous shutdown example.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant DynamoSDK

    User->>CLI: Run pipeline/build/serve commands
    CLI->>DynamoSDK: Use ServiceInterface and core SDK logic
    Note over CLI,DynamoSDK: No BentoML integration or dependency code invoked
    DynamoSDK-->>CLI: Returns results (build/serve/deploy)
    CLI-->>User: Outputs status/results
Loading

Possibly related PRs

Poem

A rabbit hopped in, BentoML in its pack,
But now the code is lighter—no more Bento on its back!
Dockerfiles are cleaner, the CLI less dense,
With ServiceInterface shining, it all makes sense.
So here’s to the hop—Dynamo stands tall,
No more Bento baggage, just pure rabbit thrall!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81e86d5 and a4c6c15.

📒 Files selected for processing (2)
  • deploy/sdk/src/dynamo/sdk/tests/test_resources.py (1 hunks)
  • examples/llm/configs/agg_router.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • examples/llm/configs/agg_router.yaml
🧰 Additional context used
🧬 Code Graph Analysis (1)
deploy/sdk/src/dynamo/sdk/tests/test_resources.py (3)
deploy/sdk/src/dynamo/sdk/tests/test_e2e_args.py (1)
  • setup_and_teardown (30-74)
deploy/sdk/src/dynamo/sdk/core/lib.py (1)
  • service (53-77)
deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (2)
  • ServiceInterface (102-195)
  • config (113-115)
🪛 Pylint (3.3.7)
deploy/sdk/src/dynamo/sdk/tests/test_resources.py

[warning] 51-51: Redefining name 'setup_and_teardown' from outer scope (line 26)

(W0621)


[error] 54-54: Unable to import 'dynamo.sdk'

(E0401)


[convention] 54-54: Import outside toplevel (dynamo.sdk.service)

(C0415)


[convention] 60-60: Missing class docstring

(C0115)


[refactor] 60-60: Too few public methods (0/2)

(R0903)


[error] 65-65: Class 'MockService' has no 'config' member

(E1101)


[error] 66-66: Class 'MockService' has no 'config' member

(E1101)


[error] 67-67: Class 'MockService' has no 'config' member

(E1101)


[error] 68-68: Class 'MockService' has no 'config' member

(E1101)


[warning] 51-51: Unused argument 'setup_and_teardown'

(W0613)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (2)
deploy/sdk/src/dynamo/sdk/tests/test_resources.py (2)

49-50: LGTM: Formatting improvement

The additional spacing improves readability between test functions.


51-68: Excellent addition addressing previous feedback

This test perfectly addresses ajcasagrande's previous suggestion to test integer coercion for resource values. The implementation correctly verifies that integer inputs (3, 4) are coerced to string outputs ("3", "4") while maintaining consistency with the existing test structure.

Good practices observed:

  • Different class name (MockService) to avoid conflicts
  • Different test values to distinguish from the original test
  • Comprehensive assertion coverage for the coercion behavior
🧰 Tools
🪛 Pylint (3.3.7)

[warning] 51-51: Redefining name 'setup_and_teardown' from outer scope (line 26)

(W0621)


[error] 54-54: Unable to import 'dynamo.sdk'

(E0401)


[convention] 54-54: Import outside toplevel (dynamo.sdk.service)

(C0415)


[convention] 60-60: Missing class docstring

(C0115)


[refactor] 60-60: Too few public methods (0/2)

(R0903)


[error] 65-65: Class 'MockService' has no 'config' member

(E1101)


[error] 66-66: Class 'MockService' has no 'config' member

(E1101)


[error] 67-67: Class 'MockService' has no 'config' member

(E1101)


[error] 68-68: Class 'MockService' has no 'config' member

(E1101)


[warning] 51-51: Unused argument 'setup_and_teardown'

(W0613)


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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)
deploy/sdk/src/dynamo/sdk/cli/cli.py (2)

29-31: Remove commented-out pipeline import and extraneous blank lines
Since the pipeline.py module and its get command have been removed, the commented import (# from dynamo.sdk.cli.pipeline import get) and surrounding blank lines are obsolete. Please delete these lines to clean up dead code.


85-85: Eliminate commented CLI registration of get command
The registration for the get command (# cli.command()(get)) is commented out. Remove this dead code entry to maintain clarity and ensure the CLI help output accurately reflects available commands.

deploy/sdk/src/dynamo/sdk/cli/build.py (1)

132-136: Good fallback mechanism with room for error message improvement.

The image fallback logic correctly prioritizes service.config.image over the DYNAMO_IMAGE environment variable. However, the assertion error message could be more helpful by specifying the exact configuration options.

Consider improving the error message:

-        assert (
-            image is not None
-        ), "Please set DYNAMO_IMAGE environment variable or image field in service config"
+        assert (
+            image is not None
+        ), "Image must be specified either via service.config.image or DYNAMO_IMAGE environment variable"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93ca9df and a8158e0.

📒 Files selected for processing (24)
  • container/Dockerfile.sglang (0 hunks)
  • container/Dockerfile.tensorrt_llm (0 hunks)
  • container/Dockerfile.vllm (0 hunks)
  • deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go (2 hunks)
  • deploy/helm/deploy.sh (1 hunks)
  • deploy/sdk/src/dynamo/sdk/__init__.py (1 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/allocator.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/bento_util.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/bentos.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/build.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/cli.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/pipeline.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/serving.py (6 hunks)
  • deploy/sdk/src/dynamo/sdk/core/lib.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/core/runner/bentoml.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/decorators.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/dependency.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/loader.py (6 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/service.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/tests/test_resources.py (2 hunks)
  • examples/llm/configs/agg_router.yaml (1 hunks)
  • pyproject.toml (1 hunks)
💤 Files with no reviewable changes (11)
  • deploy/sdk/src/dynamo/sdk/core/lib.py
  • container/Dockerfile.vllm
  • container/Dockerfile.sglang
  • container/Dockerfile.tensorrt_llm
  • deploy/sdk/src/dynamo/sdk/lib/dependency.py
  • deploy/sdk/src/dynamo/sdk/cli/bento_util.py
  • deploy/sdk/src/dynamo/sdk/lib/service.py
  • deploy/sdk/src/dynamo/sdk/cli/bentos.py
  • deploy/sdk/src/dynamo/sdk/core/runner/bentoml.py
  • deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py
  • deploy/sdk/src/dynamo/sdk/cli/pipeline.py
🧰 Additional context used
🧬 Code Graph Analysis (5)
deploy/sdk/src/dynamo/sdk/__init__.py (1)
deploy/sdk/src/dynamo/sdk/lib/decorators.py (2)
  • async_on_shutdown (102-106)
  • async_on_start (95-99)
deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go (2)
deploy/cloud/operator/internal/consts/consts.go (1)
  • KubeLabelDynamoComponent (47-47)
deploy/cloud/operator/internal/dynamo/graph.go (1)
  • ComponentTypePlanner (48-48)
deploy/sdk/src/dynamo/sdk/cli/build.py (3)
deploy/sdk/src/dynamo/sdk/core/lib.py (1)
  • service (53-77)
deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (4)
  • config (116-118)
  • ServiceConfig (73-81)
  • name (89-91)
  • name (110-112)
deploy/sdk/src/dynamo/sdk/core/runner/dynamo.py (3)
  • config (111-112)
  • name (61-62)
  • name (107-108)
deploy/sdk/src/dynamo/sdk/cli/serving.py (1)
deploy/sdk/src/dynamo/sdk/lib/loader.py (1)
  • find_and_load_service (35-84)
deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (2)
deploy/sdk/src/dynamo/sdk/cli/build.py (1)
  • ServiceConfig (97-109)
deploy/cloud/operator/internal/dynamo/graph.go (2)
  • ServiceConfig (87-91)
  • DynamoConfig (53-58)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (18)
examples/llm/configs/agg_router.yaml (1)

43-44: LGTM! Resource specifications properly added.

The explicit CPU and memory specifications are correctly formatted for Kubernetes resource management and align well with the existing GPU allocation. This standardization supports the broader resource configuration improvements in the SDK.

pyproject.toml (1)

197-197: LGTM! Mypy configuration correctly updated for BentoML removal.

The mypy module skip configuration has been appropriately narrowed to only skip vllm.* modules, removing the previously skipped BentoML-related modules (bentoml.*, fs.*, _bentoml_sdk.*). This aligns perfectly with the BentoML dependency removal and ensures proper type checking for the remaining codebase.

deploy/sdk/src/dynamo/sdk/__init__.py (1)

26-26: LGTM! Import successfully migrated from BentoML to Dynamo SDK.

The import of async_on_shutdown has been correctly moved from BentoML to dynamo.sdk.lib.decorators, maintaining consistency with async_on_start being imported from the same module. The implementation in decorators.py properly sets the __dynamo_shutdown_hook__ attribute, ensuring the decorator functionality is preserved while removing the BentoML dependency.

deploy/helm/deploy.sh (1)

90-90: LGTM! Deployment path correctly updated for Dynamo package structure.

The Helm values file path has been properly updated from the BentoML-specific structure (~/bentoml/bentos/...) to the new Dynamo package structure (~/.dynamo/packages/...). The file name change from bento.yaml to dynamo.yaml is consistent with the BentoML decoupling objective and aligns with the new package management approach.

deploy/sdk/src/dynamo/sdk/tests/test_resources.py (2)

19-19: LGTM! Import successfully migrated from BentoML to Dynamo's service interface.

This change aligns with the PR objective to decouple from BentoML dependencies by replacing the import with Dynamo's own ServiceInterface.


44-48: Enhanced test assertions provide better validation.

The test has been improved by:

  • Adding proper type annotation for dyn_svc
  • Expanding from a single assertion to multiple granular checks
  • Validating specific resource configuration fields (cpu, gpu, memory)

This provides more comprehensive testing of the updated resource configuration model.

deploy/sdk/src/dynamo/sdk/cli/allocator.py (2)

26-26: LGTM! Successfully replaced BentoML service import.

The import has been correctly updated from _bentoml_sdk to use Dynamo's own ServiceInterface from the protocol interface module, consistent with the PR's decoupling objective.


156-156: Type annotation properly updated to match the new service interface.

The parameter type has been correctly changed from Service[Any] to ServiceInterface[Any], maintaining type safety while using the new Dynamo service interface.

deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go (1)

1458-1460: Conditional logic correctly restricts environment argument to Planner components.

The conditional check properly uses the component label to determine when to append the environment argument, restricting it to Planner component deployments as intended. The logic flow is clear and follows the expected pattern.

deploy/sdk/src/dynamo/sdk/lib/decorators.py (3)

26-26: Good addition of type variable for improved typing precision.

The F type variable with proper callable bounds enhances type safety for decorator functions, providing better type inference and IDE support.


95-100: Enhanced type annotation improves decorator typing.

The async_on_start decorator now uses the bounded type variable F instead of the generic t.Callable, providing more precise type information while maintaining the same functionality.


102-106: New async_on_shutdown decorator follows consistent pattern.

The implementation mirrors the async_on_start decorator structure:

  • Uses the same type variable for proper typing
  • Sets the appropriate attribute marker (__dynamo_shutdown_hook__)
  • Returns the original function unchanged

This addition supports the BentoML decoupling effort by providing shutdown lifecycle hooks within Dynamo's own decorator library.

deploy/sdk/src/dynamo/sdk/cli/build.py (2)

141-141: Field name corrected to match interface updates.

The change from resource to resources correctly aligns with the ServiceConfig.resources field definition in the interface module.


595-595: Explicit string conversion ensures subprocess compatibility.

Converting output_path to string prevents potential issues with subprocess.run when dealing with Path objects.

deploy/sdk/src/dynamo/sdk/lib/loader.py (1)

29-29: Consistent migration to ServiceInterface.

All service type references have been consistently updated to use ServiceInterface from the protocol interface module. The changes maintain the same logic while aligning with the new service abstraction architecture.

Also applies to: 38-38, 87-87, 142-142, 181-181, 212-212

deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (2)

62-70: Improved resource configuration with type standardization and validation.

The changes standardize all resource fields (cpu, memory, gpu) to string types, which provides consistency for Kubernetes-style resource specifications. The field validator for gpu ensures backward compatibility by converting integer inputs to strings.

The memory default increase from "100Mi" to "500Mi" provides a more reasonable default allocation.


77-77:

✅ Verification successful

Field renamed for consistency across the codebase.

The rename from resource to resources aligns with the usage in other modules and follows common naming conventions for collections.

Verify that all references to the old resource field have been updated throughout the codebase:


🏁 Script executed:

#!/bin/bash
# Description: Search for any remaining references to the old 'resource' field
# that should be updated to 'resources'

# Search for service.config.resource patterns
rg -A 2 -B 2 "\.config\.resource[^s]" --type py

# Search for resource field access in ServiceConfig contexts
rg -A 2 -B 2 "ServiceConfig.*resource[^s]" --type py

Length of output: 104


🏁 Script executed:

#!/bin/bash
# Re-verify removal of all singular 'resource' field references

# 1. Match .config.resource at end-of-word or end-of-line
rg -E "\.config\.resource(\b|$)" --type py

# 2. Match ServiceConfig.resource at end-of-word or end-of-line
rg -E "ServiceConfig\.resource(\b|$)" --type py

# 3. Catch any .resource usages excluding .resources
rg -E "\.resource\b" --type py | grep -v "\.resources"

Length of output: 1342


🏁 Script executed:

#!/bin/bash
# Corrected searches for any remaining references to the singular 'resource' field

# 1. Search for ".config.resource" at word boundary or end-of-line
rg '\.config\.resource(\b|$)' -t py

# 2. Search for "ServiceConfig.resource" at word boundary or end-of-line
rg 'ServiceConfig\.resource(\b|$)' -t py

# 3. Catch any ".resource" usages excluding ".resources"
rg '\.resource\b' -t py | grep -v '\.resources'

Length of output: 211


✅ All singular .resource usages have been removed

No lingering references to the old resource field were found in attribute contexts. The only .resource match is in an import statement in deploy/sdk/src/dynamo/sdk/cli/allocator.py, which refers to the module name and doesn’t impact the renamed field. Rename is verified and safe to approve.

deploy/sdk/src/dynamo/sdk/cli/serving.py (1)

155-155: Interface simplified by removing polymorphic input support.

The function now exclusively accepts string pipeline identifiers instead of supporting both strings and service instances. This simplification removes BentoML-specific abstractions and makes the interface more predictable.

The parameter renaming from bento_identifier to dynamo_pipeline better reflects the current architecture and is consistently applied throughout the function.

Also applies to: 176-176, 237-237, 255-255, 411-411

@biswapanda
Copy link
Contributor Author

/ok to test 8de9fd0

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 (3)
deploy/sdk/src/dynamo/sdk/__init__.py (1)

19-21: Remove outdated BentoML warning filter and TODO comment.

Since BentoML dependency has been decoupled as part of this PR, the warning filter for BentoML setuptools warnings and its associated TODO comment are no longer needed.

Apply this diff to remove the outdated code:

-# Suppress warning from setuptools caused by bentoml
-# TODO: Remove this line after the bentoml import is removed from this file
-warnings.filterwarnings("ignore", category=UserWarning, message=".*pkg_resources.*")
🧰 Tools
🪛 Pylint (3.3.7)

[warning] 20-20: TODO: Remove this line after the bentoml import is removed from this file

(W0511)

deploy/sdk/src/dynamo/sdk/cli/allocator.py (1)

24-24: Import resolution issue persists (duplicate)

This import error was already identified and detailed guidance provided in a previous review. Please follow the recommendations to fix the module resolution by ensuring proper __init__.py files or configuring the package structure correctly.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 24-24: Unable to import 'dynamo.sdk.core.protocol.interface'

(E0401)

deploy/sdk/src/dynamo/sdk/lib/loader.py (1)

29-29: Same import resolution issue as allocator.py

The dynamo.sdk.core.protocol.interface module cannot be resolved. This is the same issue flagged in allocator.py and needs to be addressed across both files consistently.

Verify that the interface module structure is properly configured:

#!/bin/bash
# Check if interface.py exists and verify package structure
fd -t f "interface.py" deploy/sdk/src/dynamo/sdk/core/protocol/

# Check for __init__.py files in the path
find deploy/sdk/src/dynamo -name "__init__.py" | sort

# Try importing the module in Python
cd deploy/sdk/src && python -c "from dynamo.sdk.core.protocol.interface import ServiceInterface; print('Import successful')" 2>&1 || echo "Import failed"
🧰 Tools
🪛 Pylint (3.3.7)

[error] 29-29: Unable to import 'dynamo.sdk.core.protocol.interface'

(E0401)

🧹 Nitpick comments (3)
deploy/sdk/src/dynamo/sdk/__init__.py (2)

16-16: Consider removing unused warnings import.

If the BentoML warning filter is removed as suggested above, the warnings import on line 16 will become unused and should also be removed.

-import warnings

26-26: Import order and path verification.

The import of decorators from dynamo.sdk.lib.decorators is functionally correct (as verified in previous reviews), but there are two style considerations:

  1. Pylint suggests placing this import at the top of the module for consistency
  2. The static analysis import error appears to be a false positive since the module was previously verified to exist

Consider moving this import closer to the top after the typing import to address the import order convention:

 import warnings
 from typing import Any
+from dynamo.sdk.lib.decorators import async_on_shutdown, async_on_start

 # Suppress warning from setuptools caused by bentoml
 # TODO: Remove this line after the bentoml import is removed from this file
 warnings.filterwarnings("ignore", category=UserWarning, message=".*pkg_resources.*")

 # flake8: noqa: E402
 from dynamo.sdk.core.decorators.endpoint import api, endpoint
 from dynamo.sdk.core.lib import DYNAMO_IMAGE, depends, liveness, readiness, service
-from dynamo.sdk.lib.decorators import async_on_shutdown, async_on_start
🧰 Tools
🪛 Pylint (3.3.7)

[error] 26-26: Unable to import 'dynamo.sdk.lib.decorators'

(E0401)


[convention] 26-26: Import "from dynamo.sdk.lib.decorators import async_on_shutdown, async_on_start" should be placed at the top of the module

(C0413)

deploy/sdk/src/dynamo/sdk/lib/loader.py (1)

87-196: Consider refactoring for reduced complexity (optional)

The _do_import function has high complexity (21 local variables, 21 branches, 63 statements). While this isn't introduced by the current changes, consider breaking this function into smaller, focused helper functions:

  • _handle_file_path_import() for file-based imports
  • _find_root_service() for service discovery logic
  • _navigate_service_attributes() for attribute traversal

This would improve maintainability and testability.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 87-87: Too many local variables (21/15)

(R0914)


[warning] 90-90: Use lazy % formatting in logging functions

(W1203)


[warning] 100-100: Use lazy % formatting in logging functions

(W1203)


[warning] 125-125: Use lazy % formatting in logging functions

(W1203)


[warning] 127-127: Use lazy % formatting in logging functions

(W1203)


[warning] 131-131: Use lazy % formatting in logging functions

(W1203)


[warning] 134-134: Consider explicitly re-raising using 'raise ImportError(f'Failed to import module "{module_name}": {e}') from e'

(W0707)


[warning] 144-144: Use lazy % formatting in logging functions

(W1203)


[warning] 159-159: Use lazy % formatting in logging functions

(W1203)


[warning] 174-174: Use lazy % formatting in logging functions

(W1203)


[warning] 177-177: Use lazy % formatting in logging functions

(W1203)


[warning] 182-182: Use lazy % formatting in logging functions

(W1203)


[warning] 185-185: Use lazy % formatting in logging functions

(W1203)


[warning] 188-188: Consider explicitly re-raising using 'except (AttributeError, KeyError) as exc' and 'raise ValueError(f'Attribute "{attr}" not found in "{module_name}"') from exc'

(W0707)


[warning] 193-193: Use lazy % formatting in logging functions

(W1203)


[refactor] 87-87: Too many branches (21/12)

(R0912)


[refactor] 87-87: Too many statements (63/50)

(R0915)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a6a68d and 8de9fd0.

📒 Files selected for processing (20)
  • container/Dockerfile.sglang (0 hunks)
  • container/Dockerfile.tensorrt_llm (0 hunks)
  • container/Dockerfile.vllm (0 hunks)
  • deploy/helm/deploy.sh (1 hunks)
  • deploy/sdk/src/dynamo/sdk/__init__.py (1 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/allocator.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/bento_util.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/bentos.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/build.py (1 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/cli.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/pipeline.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/serving.py (7 hunks)
  • deploy/sdk/src/dynamo/sdk/core/runner/bentoml.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/decorators.py (2 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/dependency.py (0 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/loader.py (6 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/service.py (0 hunks)
  • examples/tensorrt_llm/common/utils.py (3 hunks)
  • pyproject.toml (1 hunks)
💤 Files with no reviewable changes (11)
  • deploy/sdk/src/dynamo/sdk/cli/cli.py
  • container/Dockerfile.sglang
  • container/Dockerfile.tensorrt_llm
  • deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py
  • container/Dockerfile.vllm
  • deploy/sdk/src/dynamo/sdk/lib/dependency.py
  • deploy/sdk/src/dynamo/sdk/lib/service.py
  • deploy/sdk/src/dynamo/sdk/cli/bento_util.py
  • deploy/sdk/src/dynamo/sdk/core/runner/bentoml.py
  • deploy/sdk/src/dynamo/sdk/cli/pipeline.py
  • deploy/sdk/src/dynamo/sdk/cli/bentos.py
✅ Files skipped from review due to trivial changes (2)
  • deploy/helm/deploy.sh
  • examples/tensorrt_llm/common/utils.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • deploy/sdk/src/dynamo/sdk/cli/build.py
  • pyproject.toml
  • deploy/sdk/src/dynamo/sdk/lib/decorators.py
  • deploy/sdk/src/dynamo/sdk/cli/serving.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
deploy/sdk/src/dynamo/sdk/__init__.py (1)
deploy/sdk/src/dynamo/sdk/lib/decorators.py (2)
  • async_on_shutdown (102-106)
  • async_on_start (95-99)
🪛 Pylint (3.3.7)
deploy/sdk/src/dynamo/sdk/__init__.py

[error] 26-26: Unable to import 'dynamo.sdk.lib.decorators'

(E0401)


[convention] 26-26: Import "from dynamo.sdk.lib.decorators import async_on_shutdown, async_on_start" should be placed at the top of the module

(C0413)

deploy/sdk/src/dynamo/sdk/cli/allocator.py

[error] 24-24: Unable to import 'dynamo.sdk.core.protocol.interface'

(E0401)

deploy/sdk/src/dynamo/sdk/lib/loader.py

[error] 29-29: Unable to import 'dynamo.sdk.core.protocol.interface'

(E0401)


[refactor] 87-87: Too many local variables (21/15)

(R0914)


[refactor] 87-87: Too many branches (21/12)

(R0912)


[refactor] 87-87: Too many statements (63/50)

(R0915)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (2)
deploy/sdk/src/dynamo/sdk/cli/allocator.py (1)

153-153: LGTM: Type annotation correctly updated

The type annotation change from Service[Any] to ServiceInterface[Any] is consistent with the import change and maintains type safety while supporting the BentoML decoupling objective.

deploy/sdk/src/dynamo/sdk/lib/loader.py (1)

38-38: LGTM: Consistent interface adoption

All type annotations and isinstance checks have been correctly updated to use ServiceInterface instead of the previous DynamoService. The changes maintain the same logic flow while supporting the BentoML decoupling objective through proper abstraction.

Also applies to: 87-87, 142-142, 181-181, 212-212

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)
deploy/sdk/src/dynamo/sdk/__init__.py (1)

19-21: Remove outdated BentoML warning suppression

Since BentoML imports have been removed, this warning filter is no longer needed and should be cleaned up.

🧰 Tools
🪛 Pylint (3.3.7)

[warning] 20-20: TODO: Remove this line after the bentoml import is removed from this file

(W0511)

🧹 Nitpick comments (4)
examples/hello_world/hello_world.py (1)

91-93: LGTM: Consistent shutdown hook implementation across services

The @on_shutdown decorators and shutdown methods are correctly implemented across all three services, providing proper lifecycle management.

Consider adding docstrings to the shutdown methods for consistency:

 @on_shutdown
 def shutdown(self):
+    """Clean up backend resources on shutdown."""
     logger.info("Shutting down backend")

Also applies to: 120-122, 165-167

🧰 Tools
🪛 Pylint (3.3.7)

[convention] 92-92: Missing function or method docstring

(C0116)

docs/API/sdk.md (1)

174-174: Minor grammar improvement suggestion

Consider adding a comma for better readability.

-The `@on_shutdown` hook is called when the service is shutdown handles cleanup.
+The `@on_shutdown` hook is called when the service is shutdown, and handles cleanup.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~174-~174: Possible missing comma found.
Context: ...own` hook is called when the service is shutdown handles cleanup. ```python @on_shutdow...

(AI_HYDRA_LEO_MISSING_COMMA)

deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py (2)

314-325: Improve logging formatting and exception specificity.

The exit handler implementation is solid for graceful shutdown, but consider addressing these minor improvements:

Apply this diff to address static analysis warnings:

-                logger.error(f"Error running shutdown hooks: {e}")
+                logger.error("Error running shutdown hooks: %s", e)

The broad exception catching is appropriate here since this is a shutdown scenario where we want to ensure the process can exit even if shutdown hooks fail.

🧰 Tools
🪛 Pylint (3.3.7)

[warning] 321-321: Catching too general exception Exception

(W0718)


[warning] 322-322: Use lazy % formatting in logging functions

(W1203)


330-337: Improve signal handler implementation.

The signal handling logic is correct, but consider these improvements:

Apply this diff to address static analysis warnings:

-    def signal_handler(signum, frame):
-        logger.info(f"Received signal {signum}, initiating graceful shutdown")
+    def signal_handler(signum, _frame):
+        logger.info("Received signal %s, initiating graceful shutdown", signum)

Using _frame indicates the parameter is intentionally unused, and lazy logging formatting is more efficient.

🧰 Tools
🪛 Pylint (3.3.7)

[warning] 331-331: Use lazy % formatting in logging functions

(W1203)


[warning] 330-330: Unused argument 'frame'

(W0613)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8de9fd0 and 81e86d5.

📒 Files selected for processing (7)
  • deploy/sdk/src/dynamo/sdk/__init__.py (1 hunks)
  • deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py (3 hunks)
  • deploy/sdk/src/dynamo/sdk/core/protocol/interface.py (1 hunks)
  • deploy/sdk/src/dynamo/sdk/lib/decorators.py (2 hunks)
  • docs/API/sdk.md (4 hunks)
  • examples/hello_world/hello_world.py (4 hunks)
  • examples/llm/components/frontend.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • deploy/sdk/src/dynamo/sdk/core/protocol/interface.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy/sdk/src/dynamo/sdk/lib/decorators.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
deploy/sdk/src/dynamo/sdk/__init__.py (1)
deploy/sdk/src/dynamo/sdk/lib/decorators.py (2)
  • async_on_start (95-99)
  • on_shutdown (102-106)
🪛 Pylint (3.3.7)
examples/llm/components/frontend.py

[error] 27-27: Unable to import 'dynamo.sdk'

(E0401)


[convention] 27-27: third party import "dynamo.sdk.api" should be placed before first party imports "components.planner_service.Planner", "components.processor.Processor", "components.worker.VllmWorker"

(C0411)

deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py

[warning] 321-321: Catching too general exception Exception

(W0718)


[warning] 322-322: Use lazy % formatting in logging functions

(W1203)


[warning] 331-331: Use lazy % formatting in logging functions

(W1203)


[warning] 330-330: Unused argument 'frame'

(W0613)

deploy/sdk/src/dynamo/sdk/__init__.py

[error] 26-26: Unable to import 'dynamo.sdk.lib.decorators'

(E0401)


[convention] 26-26: Import "from dynamo.sdk.lib.decorators import async_on_start, on_shutdown" should be placed at the top of the module

(C0413)

examples/hello_world/hello_world.py

[convention] 92-92: Missing function or method docstring

(C0116)


[convention] 121-121: Missing function or method docstring

(C0116)


[convention] 166-166: Missing function or method docstring

(C0116)

🪛 LanguageTool
docs/API/sdk.md

[uncategorized] ~174-~174: Possible missing comma found.
Context: ...own` hook is called when the service is shutdown handles cleanup. ```python @on_shutdow...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~473-~473: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... dependency from the Processor and only spin up the Router.

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (9)
examples/llm/components/frontend.py (2)

27-27: LGTM: Import transition from BentoML to native decorator

The import change from async_on_shutdown to on_shutdown correctly implements the decoupling from BentoML dependency as specified in the PR objectives.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 27-27: Unable to import 'dynamo.sdk'

(E0401)


[convention] 27-27: third party import "dynamo.sdk.api" should be placed before first party imports "components.planner_service.Planner", "components.processor.Processor", "components.worker.VllmWorker"

(C0411)


123-137: LGTM: Decorator change aligns with synchronous cleanup logic

The transition from @async_on_shutdown to @on_shutdown is appropriate since the cleanup method contains only synchronous operations (subprocess.run). This change successfully removes the BentoML dependency while maintaining the same functionality.

🧰 Tools
🪛 Pylint (3.3.7)

[convention] 127-127: Line too long (118/100)

(C0301)

deploy/sdk/src/dynamo/sdk/__init__.py (2)

26-26: LGTM: Import transition successfully implemented

The import change to dynamo.sdk.lib.decorators correctly implements the native decorator functionality, removing the BentoML dependency as intended.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 26-26: Unable to import 'dynamo.sdk.lib.decorators'

(E0401)


[convention] 26-26: Import "from dynamo.sdk.lib.decorators import async_on_start, on_shutdown" should be placed at the top of the module

(C0413)


32-32: LGTM: Export list correctly updated

The export of on_shutdown instead of async_on_shutdown is consistent with the decorator transition.

examples/hello_world/hello_world.py (1)

28-28: LGTM: Import added for shutdown lifecycle hook

The import of on_shutdown enables the lifecycle hook functionality for graceful service shutdown.

docs/API/sdk.md (1)

86-91: LGTM: Documentation correctly updated for decorator transition

The documentation accurately reflects the change from @async_on_shutdown to @on_shutdown and shows the synchronous shutdown method signature, which aligns with the implementation changes.

Also applies to: 173-181

deploy/sdk/src/dynamo/sdk/cli/serve_dynamo.py (3)

21-21: LGTM: Standard library imports for shutdown handling.

The imports for atexit and signal are appropriate for implementing the new graceful shutdown mechanism.

Also applies to: 26-26


327-327: LGTM: Proper exit handler registration.

The atexit.register call correctly ensures shutdown hooks run on normal process exit.


360-366: LGTM: Well-implemented synchronous shutdown hooks mechanism.

The run_shutdown_hooks function correctly iterates through class methods and executes those marked with the __dynamo_shutdown_hook__ attribute. This synchronous approach aligns with the broader effort to decouple from BentoML's async shutdown mechanisms.

Copy link
Contributor

@ajcasagrande ajcasagrande left a comment

Choose a reason for hiding this comment

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

code looks good to me, have not tried to run it.

Copy link
Contributor

@nv-anants nv-anants left a comment

Choose a reason for hiding this comment

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

dockerfile and toml changes lgtm

Copy link
Contributor

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

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

TRTLLM changes LGTM

@biswapanda biswapanda merged commit afb8495 into main Jun 4, 2025
14 checks passed
@biswapanda biswapanda deleted the bis/decouple_bento_deps branch June 4, 2025 22:56
This was referenced Jul 16, 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.

7 participants