Skip to content

Commit

Permalink
ci: pre-commit autoupdate [skip ci] (#4630)
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Apr 2, 2024
1 parent 2066a18 commit 1dbfb4f
Show file tree
Hide file tree
Showing 42 changed files with 173 additions and 277 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
exclude: '(.*\.(css|js|svg))|(.*/(snippets|grpc|proto)/.*)$'
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.2.0'
rev: 'v0.3.4'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
Expand All @@ -19,11 +19,11 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pdm-project/pdm
rev: 2.13.0
rev: 2.13.2
hooks:
- id: pdm-lock-check
- repo: https://github.com/bufbuild/buf
rev: v1.29.0
rev: v1.30.0
hooks:
- id: buf-format
args: [--config=src/bentoml/grpc/buf.yaml, src/bentoml/grpc]
Expand Down
6 changes: 2 additions & 4 deletions src/_bentoml_impl/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,12 @@ def _call(
kwargs: dict[str, t.Any],
*,
headers: t.Mapping[str, str] | None = None,
) -> t.Any:
...
) -> t.Any: ...

@abstractmethod
def _get_stream(
self, endpoint: ClientEndpoint, args: t.Any, kwargs: t.Any
) -> t.Any:
...
) -> t.Any: ...


class SyncHTTPClient(HTTPClient[httpx.Client]):
Expand Down
12 changes: 4 additions & 8 deletions src/_bentoml_impl/serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,16 @@ class Serde(abc.ABC):
media_type: str

@abc.abstractmethod
def serialize_model(self, model: IODescriptor) -> Payload:
...
def serialize_model(self, model: IODescriptor) -> Payload: ...

@abc.abstractmethod
def deserialize_model(self, payload: Payload, cls: type[T]) -> T:
...
def deserialize_model(self, payload: Payload, cls: type[T]) -> T: ...

@abc.abstractmethod
def serialize(self, obj: t.Any, schema: dict[str, t.Any]) -> Payload:
...
def serialize(self, obj: t.Any, schema: dict[str, t.Any]) -> Payload: ...

@abc.abstractmethod
def deserialize(self, payload: Payload, schema: dict[str, t.Any]) -> t.Any:
...
def deserialize(self, payload: Payload, schema: dict[str, t.Any]) -> t.Any: ...

async def parse_request(self, request: Request, cls: type[T]) -> T:
"""Parse a input model from HTTP request"""
Expand Down
8 changes: 4 additions & 4 deletions src/_bentoml_impl/server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
_bentoml_impl.server
~~~~~~~~~~~~~~~~~~~~
_bentoml_impl.server
~~~~~~~~~~~~~~~~~~~~
A reference implementation of serving a BentoML service.
This will be eventually migrated to Rust.
A reference implementation of serving a BentoML service.
This will be eventually migrated to Rust.
"""

from .serving import serve_http
Expand Down
6 changes: 2 additions & 4 deletions src/_bentoml_sdk/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def on_deployment(func: t.Callable[P, R] | staticmethod[P, R]) -> staticmethod[P


@t.overload
def api(func: t.Callable[t.Concatenate[t.Any, P], R]) -> APIMethod[P, R]:
...
def api(func: t.Callable[t.Concatenate[t.Any, P], R]) -> APIMethod[P, R]: ...


@t.overload
Expand All @@ -49,8 +48,7 @@ def api(
batch_dim: int | tuple[int, int] = ...,
max_batch_size: int = ...,
max_latency_ms: int = ...,
) -> t.Callable[[t.Callable[t.Concatenate[t.Any, P], R]], APIMethod[P, R]]:
...
) -> t.Callable[[t.Callable[t.Concatenate[t.Any, P], R]], APIMethod[P, R]]: ...


def api(
Expand Down
6 changes: 2 additions & 4 deletions src/_bentoml_sdk/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ def __attrs_post_init__(self) -> None:
self.output_spec.media_type = DEFAULT_STREAM_MEDIA_TYPE

@t.overload
def __get__(self: T, instance: None, owner: type) -> T:
...
def __get__(self: T, instance: None, owner: type) -> T: ...

@t.overload
def __get__(self, instance: object, owner: type) -> t.Callable[P, R]:
...
def __get__(self, instance: object, owner: type) -> t.Callable[P, R]: ...

def __get__(self: T, instance: t.Any, owner: type) -> t.Callable[P, R] | T:
from pydantic.fields import FieldInfo
Expand Down
3 changes: 2 additions & 1 deletion src/_bentoml_sdk/service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

class TrafficSchema(TypedDict, total=False):
timeout: Posfloat
max_concurrency: Posint # concurrent request will be rejected if it exceeds this limit
# concurrent request will be rejected if it exceeds this limit
max_concurrency: Posint
concurrency: Posint # capabilty of handling concurrent request
external_queue: bool # bentocloud only, if set to true, bentocloud will use external queue to handle request

Expand Down
6 changes: 2 additions & 4 deletions src/_bentoml_sdk/service/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ def get(
return _dependent_cache[key]

@t.overload
def __get__(self, instance: None, owner: t.Any) -> Dependency[T]:
...
def __get__(self, instance: None, owner: t.Any) -> Dependency[T]: ...

@t.overload
def __get__(self, instance: t.Any, owner: t.Any) -> T:
...
def __get__(self, instance: t.Any, owner: t.Any) -> T: ...

def __get__(self, instance: t.Any, owner: t.Any) -> Dependency[T] | T:
if instance is None:
Expand Down
9 changes: 3 additions & 6 deletions src/_bentoml_sdk/service/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
R = t.TypeVar("R")

class _ServiceDecorator(t.Protocol):
def __call__(self, inner: type[T]) -> Service[T]:
...
def __call__(self, inner: type[T]) -> Service[T]: ...


def with_config(
Expand Down Expand Up @@ -328,13 +327,11 @@ def serve_http(


@t.overload
def service(inner: type[T], /) -> Service[T]:
...
def service(inner: type[T], /) -> Service[T]: ...


@t.overload
def service(inner: None = ..., /, **kwargs: Unpack[Config]) -> _ServiceDecorator:
...
def service(inner: None = ..., /, **kwargs: Unpack[Config]) -> _ServiceDecorator: ...


def service(inner: type[T] | None = None, /, **kwargs: Unpack[Config]) -> t.Any:
Expand Down
3 changes: 1 addition & 2 deletions src/bentoml/_internal/bento/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,7 @@ def __init__(
python: PythonOptions | dict[str, t.Any] | None = ...,
conda: CondaOptions | dict[str, t.Any] | None = ...,
models: list[ModelSpec | str | dict[str, t.Any]] | None = ...,
) -> None:
...
) -> None: ...

def __attrs_post_init__(self) -> None:
use_conda = not self.conda.is_empty()
Expand Down
29 changes: 11 additions & 18 deletions src/bentoml/_internal/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,17 @@ async def async_wait_until_server_ready(

@t.overload
@staticmethod
def from_url(server_url: str, *, kind: None | t.Literal["auto"] = ...) -> Client:
...
def from_url(
server_url: str, *, kind: None | t.Literal["auto"] = ...
) -> Client: ...

@t.overload
@staticmethod
def from_url(server_url: str, *, kind: t.Literal["http"] = ...) -> HTTPClient:
...
def from_url(server_url: str, *, kind: t.Literal["http"] = ...) -> HTTPClient: ...

@t.overload
@staticmethod
def from_url(server_url: str, *, kind: t.Literal["grpc"] = ...) -> GrpcClient:
...
def from_url(server_url: str, *, kind: t.Literal["grpc"] = ...) -> GrpcClient: ...

@staticmethod
def from_url(
Expand Down Expand Up @@ -205,22 +204,19 @@ async def wait_until_server_ready(
@classmethod
async def from_url(
cls, server_url: str, *, kind: None | t.Literal["auto"] = ...
) -> AsyncGrpcClient | AsyncHTTPClient:
...
) -> AsyncGrpcClient | AsyncHTTPClient: ...

@t.overload
@classmethod
async def from_url(
cls, server_url: str, *, kind: t.Literal["http"] = ...
) -> AsyncHTTPClient:
...
) -> AsyncHTTPClient: ...

@t.overload
@classmethod
async def from_url(
cls, server_url: str, *, kind: t.Literal["grpc"] = ...
) -> AsyncGrpcClient:
...
) -> AsyncGrpcClient: ...

@classmethod
async def from_url(
Expand Down Expand Up @@ -326,22 +322,19 @@ def wait_until_server_ready(
@classmethod
def from_url(
cls, server_url: str, *, kind: None | t.Literal["auto"] = ...
) -> SyncGrpcClient | SyncHTTPClient:
...
) -> SyncGrpcClient | SyncHTTPClient: ...

@t.overload
@classmethod
def from_url(
cls, server_url: str, *, kind: t.Literal["http"] = ...
) -> SyncHTTPClient:
...
) -> SyncHTTPClient: ...

@t.overload
@classmethod
def from_url(
cls, server_url: str, *, kind: t.Literal["grpc"] = ...
) -> SyncGrpcClient:
...
) -> SyncGrpcClient: ...

@classmethod
def from_url(
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/cloud/schemas/modelschemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ class DeploymentTargetConfig:
default=None
)
deployment_strategy: t.Optional[str] = attr.field(default=None) # Specific
bento_deployment_overrides: t.Optional[
ApiServerBentoDeploymentOverrides
] = attr.field(default=None)
bento_deployment_overrides: t.Optional[ApiServerBentoDeploymentOverrides] = (
attr.field(default=None)
)
bento_request_overrides: t.Optional[BentoRequestOverrides] = attr.field(
default=None
) # Put into image builder
Expand Down
28 changes: 10 additions & 18 deletions src/bentoml/_internal/container/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ class DefaultBackendImpl(types.ModuleType):
ENV: dict[str, str] | None
BUILDKIT_SUPPORT: bool

def find_binary(self) -> str | None:
...
def find_binary(self) -> str | None: ...

def construct_build_args(
self,
**kwargs: t.Any, # pylint: disable=unused-argument
) -> Arguments:
...
) -> Arguments: ...

def health(self) -> bool:
...
def health(self) -> bool: ...

DefaultBuilder: t.TypeAlias = t.Literal[
"docker", "podman", "buildah", "buildx", "nerdctl", "buildctl"
Expand Down Expand Up @@ -153,11 +150,10 @@ def construct_containerfile(
dockerfile_path = "env/docker/Dockerfile"
instruction: list[str] = []

with fs.open_fs("temp://") as temp_fs, open(
bento.path_of("bento.yaml"), "rb"
) as bento_yaml:
with fs.open_fs("temp://") as temp_fs:
tempdir = temp_fs.getsyspath("/")
options = BentoInfo.from_yaml_file(bento_yaml)
with open(bento.path_of("bento.yaml"), "rb") as bento_yaml:
options = BentoInfo.from_yaml_file(bento_yaml)
# tmpdir is our new build context.
fs.mirror.mirror(bento._fs, temp_fs, copy_if_newer=True)

Expand Down Expand Up @@ -304,13 +300,11 @@ def register_backend(


@t.overload
def health(backend: DefaultBuilder) -> bool:
...
def health(backend: DefaultBuilder) -> bool: ...


@t.overload
def health(backend: str) -> bool:
...
def health(backend: str) -> bool: ...


def health(backend: str) -> bool:
Expand All @@ -332,13 +326,11 @@ def health(backend: str) -> bool:


@t.overload
def get_backend(backend: DefaultBuilder) -> OCIBuilder:
...
def get_backend(backend: DefaultBuilder) -> OCIBuilder: ...


@t.overload
def get_backend(backend: str) -> OCIBuilder:
...
def get_backend(backend: str) -> OCIBuilder: ...


def get_backend(backend: str) -> OCIBuilder:
Expand Down
12 changes: 6 additions & 6 deletions src/bentoml/_internal/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def mutablecopy(self) -> Metadata:

class ServiceContext:
def __init__(self) -> None:
self._request_var: contextvars.ContextVar[
starlette.requests.Request
] = contextvars.ContextVar("request")
self._response_var: contextvars.ContextVar[
ServiceContext.ResponseContext
] = contextvars.ContextVar("response")
self._request_var: contextvars.ContextVar[starlette.requests.Request] = (
contextvars.ContextVar("request")
)
self._response_var: contextvars.ContextVar[ServiceContext.ResponseContext] = (
contextvars.ContextVar("response")
)
# A dictionary for storing global state shared by the process
self.state: dict[str, t.Any] = {}

Expand Down
3 changes: 1 addition & 2 deletions src/bentoml/_internal/external_typing/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from starlette.types import Send as ASGISend

class AsgiMiddleware(t.Protocol):
def __call__(self, app: ASGIApp, **options: t.Any) -> ASGIApp:
...
def __call__(self, app: ASGIApp, **options: t.Any) -> ASGIApp: ...

__all__ = [
"AsgiMiddleware",
Expand Down

0 comments on commit 1dbfb4f

Please sign in to comment.