From 78e57e0a400b09de43dbf845bc67855b65099bbf Mon Sep 17 00:00:00 2001 From: Frost Ming <me@frostming.com> Date: Tue, 24 Sep 2024 11:25:35 +0800 Subject: [PATCH 1/4] fix: compare bento manifest Signed-off-by: Frost Ming <me@frostming.com> --- src/bentoml/_internal/cloud/deployment.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bentoml/_internal/cloud/deployment.py b/src/bentoml/_internal/cloud/deployment.py index 8b414d223ea..22cbad00250 100644 --- a/src/bentoml/_internal/cloud/deployment.py +++ b/src/bentoml/_internal/cloud/deployment.py @@ -822,7 +822,9 @@ def watch_filter(change: watchfiles.Change, path: str) -> bool: if ( target is None or target.bento is None - or target.bento.manifest != bento_info.get_manifest() + or not _is_bento_manifest_equal( + target.bento.manifest, bento_info.get_manifest() + ) ): console.print("✨ [green bold]Bento change detected[/]") spinner.update("🔄 Pushing Bento to BentoCloud") @@ -864,7 +866,9 @@ def watch_filter(change: watchfiles.Change, path: str) -> bool: if ( target is None or target.bento is None - or target.bento.manifest != bento_info.get_manifest() + or not _is_bento_manifest_equal( + target.bento.manifest, bento_info.get_manifest() + ) ): # stop log tail and reset the deployment break @@ -1373,3 +1377,14 @@ def _build_requirements_txt(bento_dir: str, config: BentoBuildConfig) -> bytes: bentoml_requirement = f"-e ./{EDITABLE_BENTOML_DIR}" content += f"{bentoml_requirement}\n".encode("utf8") return content + + +def _is_bento_manifest_equal( + source: BentoManifestSchema, target: BentoManifestSchema +) -> bool: + source_data = bentoml_cattr.structure(source, BentoManifestSchema) + target_data = bentoml_cattr.structure(target, BentoManifestSchema) + + config_merger.merge(source_data, target_data) + new_source = bentoml_cattr.unstructure(source_data, BentoManifestSchema) + return new_source == source From 290da0ec9bedfba647f9a31596c4d64fd004b6ac Mon Sep 17 00:00:00 2001 From: Frost Ming <me@frostming.com> Date: Tue, 24 Sep 2024 11:28:12 +0800 Subject: [PATCH 2/4] fix: hide develop command Signed-off-by: Frost Ming <me@frostming.com> --- src/bentoml_cli/deployment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bentoml_cli/deployment.py b/src/bentoml_cli/deployment.py index 916058003b4..b565636c63e 100644 --- a/src/bentoml_cli/deployment.py +++ b/src/bentoml_cli/deployment.py @@ -218,7 +218,8 @@ def decorate(f: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]: return decorate -@click.command(name="develop") +# FIXME: remove hidden flag when ready for GA +@click.command(name="develop", hidden=True) @click.argument( "bento_dir", type=click.Path(exists=True, file_okay=False, dir_okay=True, readable=True), From 7cbdda57b413b57179c97d78ca0cb7ec0e2df3a8 Mon Sep 17 00:00:00 2001 From: Frost Ming <me@frostming.com> Date: Tue, 24 Sep 2024 12:08:22 +0800 Subject: [PATCH 3/4] fix Signed-off-by: Frost Ming <me@frostming.com> --- src/_bentoml_sdk/service/dependency.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/_bentoml_sdk/service/dependency.py b/src/_bentoml_sdk/service/dependency.py index 6b9bc0743bd..242d2a111a0 100644 --- a/src/_bentoml_sdk/service/dependency.py +++ b/src/_bentoml_sdk/service/dependency.py @@ -7,7 +7,6 @@ from simple_di import Provide from simple_di import inject -from bentoml._internal.cloud.client import RestApiClient from bentoml._internal.configuration.containers import BentoMLContainer from bentoml.exceptions import BentoMLException @@ -49,7 +48,6 @@ def get( runner_mapping: dict[str, str] = Provide[ BentoMLContainer.remote_runner_mapping ], - client: RestApiClient = Provide[BentoMLContainer.rest_api_client], ) -> T | RemoteProxy[t.Any]: from _bentoml_impl.client.proxy import RemoteProxy @@ -57,6 +55,7 @@ def get( if self.deployment and self.url: raise BentoMLException("Cannot specify both deployment and url") if self.deployment: + client = BentoMLContainer.rest_api_client.get() deployment = client.v2.get_deployment(self.deployment, self.cluster) try: self.url = deployment.urls[0] From af09a585559b9b6bf42c11a9d96715d032978272 Mon Sep 17 00:00:00 2001 From: Frost Ming <me@frostming.com> Date: Tue, 24 Sep 2024 14:51:17 +0800 Subject: [PATCH 4/4] fix: gain commit hash for huggingface model Signed-off-by: Frost Ming <me@frostming.com> --- src/_bentoml_sdk/models/huggingface.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/_bentoml_sdk/models/huggingface.py b/src/_bentoml_sdk/models/huggingface.py index 7e21734d19a..54c77142d24 100644 --- a/src/_bentoml_sdk/models/huggingface.py +++ b/src/_bentoml_sdk/models/huggingface.py @@ -40,14 +40,9 @@ class HuggingFaceModel(Model[str]): @cached_property def commit_hash(self) -> str: - from huggingface_hub import get_hf_file_metadata - from huggingface_hub import hf_hub_url + from huggingface_hub import model_info - url = hf_hub_url( - self.model_id, CONFIG_FILE, revision=self.revision, endpoint=self.endpoint - ) - metadata = get_hf_file_metadata(url) - return metadata.commit_hash or self.revision + return model_info(self.model_id, revision=self.revision).sha or self.revision def resolve(self, base_path: t.Union[PathType, FS, None] = None) -> str: from huggingface_hub import snapshot_download