diff --git a/bentoml/_internal/configuration/v1/__init__.py b/bentoml/_internal/configuration/v1/__init__.py index 5b76663e2b4..f06f630395f 100644 --- a/bentoml/_internal/configuration/v1/__init__.py +++ b/bentoml/_internal/configuration/v1/__init__.py @@ -4,6 +4,7 @@ import schema as s +from ....exceptions import BentoMLConfigException from ..helpers import ensure_range from ..helpers import flatten_dict from ..helpers import rename_fields @@ -134,6 +135,13 @@ def migrate_to_v2(*, override_config: dict[str, t.Any]): + try: + SCHEMA.validate(override_config) + except s.SchemaError as e: + raise BentoMLConfigException( + f"Invalid configuration file was given:\n{e}" + ) from None + # We will use a flattened config to make it easier to migrate, # Then we will convert it back to a nested config. flatten = dict(flatten_dict(override_config)) diff --git a/bentoml/start.py b/bentoml/start.py index 03d083b7c86..b02ee550528 100644 --- a/bentoml/start.py +++ b/bentoml/start.py @@ -3,7 +3,6 @@ import os import sys import json -import math import typing as t import logging import contextlib @@ -122,7 +121,7 @@ def start_http_server( port: int = Provide[BentoMLContainer.api_server_config.port], host: str = Provide[BentoMLContainer.api_server_config.host], backlog: int = Provide[BentoMLContainer.api_server_config.backlog], - api_workers: int | None = None, + api_workers: int = Provide[BentoMLContainer.api_server_workers], ssl_certfile: str | None = Provide[BentoMLContainer.api_server_config.ssl.certfile], ssl_keyfile: str | None = Provide[BentoMLContainer.api_server_config.ssl.keyfile], ssl_keyfile_password: str @@ -140,7 +139,6 @@ def start_http_server( from .serve import construct_ssl_args from .serve import PROMETHEUS_MESSAGE from .serve import ensure_prometheus_dir - from ._internal.resource import CpuResource from ._internal.utils.circus import create_standalone_arbiter from ._internal.utils.analytics import track_serve @@ -200,7 +198,7 @@ def start_http_server( ), ], working_dir=working_dir, - numprocesses=api_workers or math.ceil(CpuResource.from_system()), + numprocesses=api_workers, ) ) if BentoMLContainer.api_server_config.metrics.enabled.get(): @@ -235,7 +233,7 @@ def start_grpc_server( port: int = Provide[BentoMLContainer.grpc.port], host: str = Provide[BentoMLContainer.grpc.host], backlog: int = Provide[BentoMLContainer.api_server_config.backlog], - api_workers: int | None = None, + api_workers: int = Provide[BentoMLContainer.api_server_workers], reflection: bool = Provide[BentoMLContainer.grpc.reflection.enabled], max_concurrent_streams: int | None = Provide[BentoMLContainer.grpc.max_concurrent_streams], @@ -247,7 +245,6 @@ def start_grpc_server( from .serve import ensure_prometheus_dir from .serve import PROMETHEUS_SERVER_NAME from ._internal.utils import reserve_free_port - from ._internal.resource import CpuResource from ._internal.utils.circus import create_standalone_arbiter from ._internal.utils.analytics import track_serve @@ -304,7 +301,7 @@ def start_grpc_server( args=args, use_sockets=False, working_dir=working_dir, - numprocesses=api_workers or math.ceil(CpuResource.from_system()), + numprocesses=api_workers, ) ) diff --git a/pyproject.toml b/pyproject.toml index 8a938ffc292..09c108b8896 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -379,7 +379,7 @@ exclude = [ "bazel-*", ] analysis.useLibraryCodeForTypes = true -analysis.stubPath = "./typings/" +analysis.stubPath = "typings/" strictListInference = true strictDictionaryInference = true strictSetInference = true