diff --git a/src/_bentoml_impl/server/app.py b/src/_bentoml_impl/server/app.py index 696efbe5bb2..338da86faa3 100644 --- a/src/_bentoml_impl/server/app.py +++ b/src/_bentoml_impl/server/app.py @@ -257,9 +257,9 @@ def server_request_hook(span: Span, _scope: dict[str, t.Any]) -> None: middlewares.append(Middleware(middleware_cls, **options)) # CORS middleware if self.enable_access_control: - assert self.access_control_options.get("allow_origins") is not None, ( - "To enable cors, access_control_allow_origin must be set" - ) + assert ( + self.access_control_options.get("allow_origins") is not None + ), "To enable cors, access_control_allow_origin must be set" from starlette.middleware.cors import CORSMiddleware diff --git a/src/_bentoml_impl/server/serving.py b/src/_bentoml_impl/server/serving.py index e4a34573d34..06bf8582e5c 100644 --- a/src/_bentoml_impl/server/serving.py +++ b/src/_bentoml_impl/server/serving.py @@ -194,9 +194,9 @@ def serve_http( if isinstance(bento_identifier, Service): svc = bento_identifier bento_identifier = svc.import_string - assert working_dir is None, ( - "working_dir should not be set when passing a service in process" - ) + assert ( + working_dir is None + ), "working_dir should not be set when passing a service in process" # use cwd bento_path = pathlib.Path(".") else: diff --git a/src/bentoml/__init__.py b/src/bentoml/__init__.py index 3a9ccf52cc3..494a998dd5c 100644 --- a/src/bentoml/__init__.py +++ b/src/bentoml/__init__.py @@ -19,7 +19,7 @@ from ._internal.configuration import BENTOML_VERSION as __version__ -MODEL_ATTRS = { +MODULE_ATTRS = { "Field": "pydantic:Field", # BentoML built-in types "load_config": "._internal.configuration:load_config", @@ -293,10 +293,10 @@ del _LazyLoader, FrameworkImporter def __getattr__(name: str) -> Any: - if name in MODEL_ATTRS: + if name in MODULE_ATTRS: from importlib import import_module - module_name, attr_name = MODEL_ATTRS[name].split(":") + module_name, attr_name = MODULE_ATTRS[name].split(":") module = import_module(module_name, __package__) return getattr(module, attr_name) raise AttributeError(f"module {__name__} has no attribute {name}") diff --git a/src/bentoml/_internal/batch/spark.py b/src/bentoml/_internal/batch/spark.py index ae94fb4fa6c..39b1a45a981 100644 --- a/src/bentoml/_internal/batch/spark.py +++ b/src/bentoml/_internal/batch/spark.py @@ -68,9 +68,9 @@ def process( ) -> t.Generator[RecordBatch, None, None]: svc = _load_bento_spark(bento_tag) - assert api_name in svc.apis, ( - "An error occurred transferring the Bento to the Spark worker." - ) + assert ( + api_name in svc.apis + ), "An error occurred transferring the Bento to the Spark worker." inference_api = svc.apis[api_name] assert inference_api.func is not None, "Inference API function not defined" diff --git a/src/bentoml/_internal/server/grpc_app.py b/src/bentoml/_internal/server/grpc_app.py index 8b852ae9b96..d8c2153fd53 100644 --- a/src/bentoml/_internal/server/grpc_app.py +++ b/src/bentoml/_internal/server/grpc_app.py @@ -240,9 +240,9 @@ def configure_port(self, addr: str): if self.ssl_certfile: client_auth = False ca_cert = None - assert self.ssl_keyfile, ( - "'ssl_keyfile' is required when 'ssl_certfile' is provided." - ) + assert ( + self.ssl_keyfile + ), "'ssl_keyfile' is required when 'ssl_certfile' is provided." if self.ssl_ca_certs is not None: client_auth = True ca_cert = load_from_file(self.ssl_ca_certs) diff --git a/src/bentoml/_internal/server/http_app.py b/src/bentoml/_internal/server/http_app.py index 6cba5cd6e66..9b9449b3626 100644 --- a/src/bentoml/_internal/server/http_app.py +++ b/src/bentoml/_internal/server/http_app.py @@ -209,9 +209,9 @@ def middlewares(self) -> list[Middleware]: middlewares.append(Middleware(middleware_cls, **options)) if self.enable_access_control: - assert self.access_control_options.get("allow_origins") is not None, ( - "To enable cors, access_control_allow_origin must be set" - ) + assert ( + self.access_control_options.get("allow_origins") is not None + ), "To enable cors, access_control_allow_origin must be set" from starlette.middleware.cors import CORSMiddleware diff --git a/src/bentoml/_internal/service/service.py b/src/bentoml/_internal/service/service.py index 5180220ce04..34df13a0aae 100644 --- a/src/bentoml/_internal/service/service.py +++ b/src/bentoml/_internal/service/service.py @@ -217,9 +217,9 @@ def __init__( if runners is not None: runner_names: t.Set[str] = set() for r in runners: - assert isinstance(r, AbstractRunner), ( - f'Service runners list can only contain bentoml.Runner instances, type "{type(r)}" found.' - ) + assert isinstance( + r, AbstractRunner + ), f'Service runners list can only contain bentoml.Runner instances, type "{type(r)}" found.' if r.name in runner_names: raise ValueError( @@ -230,9 +230,9 @@ def __init__( # validate models list contains Model instances if models is not None: for model in models: - assert isinstance(model, Model), ( - f'Service models list can only contain bentoml.Model instances, type "{type(model)}" found.' - ) + assert isinstance( + model, Model + ), f'Service models list can only contain bentoml.Model instances, type "{type(model)}" found.' self.__attrs_init__( # type: ignore name=name,