Skip to content

refactor: move legacy APIs to a separate module #5381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

frostming
Copy link
Collaborator

@frostming frostming commented Jun 6, 2025

Signed-off-by: Frost Ming me@frostming.com

What does this PR address?

We plan to export the new service type in the top-level namespace, which conflict with the legacy service with the same name. Therefore, as a preliminary step, this PR moves all deprecated APIs to a new module bentoml.legacy while keeping the references in bentoml for a while.

Any references to bentoml.<legacy_api> will emit a deprecation warning to let users migrate ASAP.

Signed-off-by: Frost Ming <me@frostming.com>
@frostming frostming requested a review from a team as a code owner June 6, 2025 03:33
@frostming frostming requested review from jianshen92 and removed request for a team June 6, 2025 03:33
Copy link

github-actions bot commented Jun 6, 2025

Code Coverage

Package Statements
bentoml 54.40% (9825 / 18060)
Summary 54.40% (9825 / 18060)

@frostming frostming requested review from aarnphm and Copilot June 7, 2025 09:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors deprecated APIs by moving them to a dedicated bentoml.legacy module, allowing the new service type to be exported in the top-level namespace without conflicts.

  • Legacy API classes and functions now inherit from bentoml.legacy.Runnable in multiple framework integrations.
  • Top-level lazy loading and attribute access (in init.py) are updated to handle legacy references and emit deprecation warnings.
  • Documentation snippets and SDK factory imports have been updated accordingly.

Reviewed Changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/bentoml/_internal/frameworks/* Updated get_runnable functions and associated runnable classes to reference bentoml.legacy.Runnable.
src/bentoml/init.py Modified lazy loading and getattr to delegate legacy API attributes and warn users of deprecation.
docs/README.md Revised documentation snippet to align with the new public API changes.
src/_bentoml_sdk/service/factory.py Adjusted Runner import to use bentoml.legacy.Runner.
src/_bentoml_impl/frameworks/* Updated legacy-related get_runnable and runnable classes to use bentoml.legacy.Runnable.
Comments suppressed due to low confidence (2)

src/bentoml/init.py:301

  • Ensure that the bentoml.legacy module defines all to support this dynamic attribute lookup; otherwise, accessing legacy APIs via the top-level module may raise an AttributeError.
elif name in legacy.__all__:

docs/README.md:216

  • [nitpick] Verify that updating the documentation from 'bentoml.Service' to 'bentoml.Bento' correctly reflects the new intended public API and aligns with the overall legacy refactoring.
.. autoclass:: bentoml.Bento

@frostming frostming merged commit 17a160c into main Jun 9, 2025
94 of 96 checks passed
@frostming frostming deleted the refactor/legacy-namespace branch June 9, 2025 00:59
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