Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Heuristic:Bentoml BentoML Warning Deprecated Legacy Service

From Leeroopedia
Knowledge Sources
Domains Deprecation, Migration
Last Updated 2026-02-13 00:00 GMT

Overview

Deprecation warning: the legacy bentoml.legacy.Service class is deprecated in favor of the @bentoml.service() decorator.

Description

The Service class in src/bentoml/_internal/service/service.py is decorated with @deprecated("bentoml.legacy.Service", suggestion="Please upgrade to @bentoml.service()."). This class was the original BentoML service definition mechanism using class inheritance and @api method decorators in the v1.x pattern. It has been superseded by the new decorator-based service definition in BentoML v2.x.

Usage

Be aware of this deprecation when encountering bentoml.legacy.Service or Service(name=..., runners=[...]) patterns in existing codebases. All new services should use the @bentoml.service() decorator pattern.

The Insight (Rule of Thumb)

  • Action: Replace class MyService(bentoml.legacy.Service) with @bentoml.service() decorator on a class.
  • Value: The new decorator pattern provides better composability, dependency injection via bentoml.depends(), and native async support.
  • Trade-off: Migration requires restructuring service classes to use the new decorator pattern and replacing Runner-based model inference with direct model loading.

Reasoning

The legacy Service class coupled service definition, runner management, and API declaration into a single class hierarchy. The new v2.x architecture decouples these concerns: @bentoml.service() for service identity, @bentoml.api() for endpoint declaration, and bentoml.depends() for composition. This enables more flexible multi-model architectures.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment