Skip to content

Commit

Permalink
ci: auto fixes from pre-commit.ci
Browse files Browse the repository at this point in the history
For more information, see https://pre-commit.ci

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
pre-commit-ci[bot] authored and frostming committed Jan 14, 2025
1 parent 6dedf49 commit 7246018
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/_bentoml_impl/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/_bentoml_impl/server/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}")
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/batch/spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/server/grpc_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/server/http_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/bentoml/_internal/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit 7246018

Please sign in to comment.