def service(
    inner: type[T] | None = None,
    /,
    *,
    image: Image | None = None,
    envs: list[dict[str, str]] | None = None,
    labels: dict[str, str] | None = None,
    **kwargs: Unpack[Config],
) -> t.Any:
    """Mark a class as a BentoML service.

    Example:

        @service(traffic={"timeout": 60})
        class InferenceService:
            @api
            def predict(self, input: str) -> str:
                return input
    """
    config = kwargs

    def decorator(inner: type[T]) -> Service[T]:
        if isinstance(inner, Service):
            raise TypeError("service() decorator can only be applied once")
        return Service(
            config=config,
            inner=inner,
            image=image,
            envs=envs or [],
            labels=labels or {},
        )

    return decorator(inner) if inner is not None else decorator
Mark a class as a BentoML service.

Example:

@service(traffic={"timeout": 60})
class InferenceService:
@api
def predict(self, input: str) -> str:
return input
src/_bentoml_sdk/service/factory.py