Skip to content

Commit

Permalink
fix: on_deployment failed to run for serve_grpc (#4963)
Browse files Browse the repository at this point in the history
* fix: dev version

Signed-off-by: Frost Ming <[email protected]>

* fix: on_deployment hook failed on serve_grpc

Signed-off-by: Frost Ming <[email protected]>

* fix: clean bentoml version

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Sep 10, 2024
1 parent a6f5f93 commit 67fdd30
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ git_describe_command = [
"--long",
"--first-parent",
]
version_scheme = "post-release"
fallback_version = "0.0.0"
[tool.hatch.metadata]
allow-direct-references = true
Expand Down
2 changes: 1 addition & 1 deletion src/bentoml/_internal/bento/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def write_to_bento(
args.extend(pip_args)
f.write(
self._jinja_environment.get_template("install.sh.j2").render(
bentoml_version=clean_bentoml_version(BENTOML_VERSION),
bentoml_version=clean_bentoml_version(),
pip_args=shlex.join(args),
)
)
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def expand_env_var(env_var: str) -> str:
env_var = interpolated


def clean_bentoml_version(bentoml_version: str) -> str:
post_version = ".".join(bentoml_version.split(".")[:3])
@lru_cache(maxsize=1)
def clean_bentoml_version() -> str:
try:
version = Version(post_version)
version = Version(BENTOML_VERSION).base_version
return str(version)
except ValueError:
raise BentoMLException("Errors while parsing BentoML version.") from None
Expand Down
4 changes: 1 addition & 3 deletions src/bentoml/serving.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import asyncio
import contextlib
import json
import logging
Expand Down Expand Up @@ -683,8 +682,7 @@ def serve_grpc_production(

close_child_stdin: bool = False if development_mode else True

loop = asyncio.get_event_loop()
loop.run_until_complete(on_service_deployment(svc))
on_service_deployment(svc)

with contextlib.ExitStack() as port_stack:
api_port = port_stack.enter_context(
Expand Down
3 changes: 1 addition & 2 deletions src/bentoml/testing/pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pytest import MonkeyPatch

import bentoml
from bentoml._internal.configuration import BENTOML_VERSION
from bentoml._internal.configuration import clean_bentoml_version
from bentoml._internal.configuration.containers import BentoMLContainer
from bentoml._internal.models import ModelContext
Expand Down Expand Up @@ -46,7 +45,7 @@

@pytest.mark.tryfirst
def pytest_report_header(config: Config) -> list[str]:
return [f"bentoml: version={clean_bentoml_version(BENTOML_VERSION)}"]
return [f"bentoml: version={clean_bentoml_version()}"]


@pytest.hookimpl
Expand Down

0 comments on commit 67fdd30

Please sign in to comment.