From 1148aa5fbbc0a47b912e920a27d08e556f435fe0 Mon Sep 17 00:00:00 2001 From: Brayden Zhong Date: Tue, 13 May 2025 17:02:39 -0400 Subject: [PATCH 1/3] fix for dup click decorator --- docs/source/build-with-bentoml/services.rst | 2 +- docs/source/examples/mlflow.rst | 2 +- docs/source/scale-with-bentocloud/deployment/index.rst | 2 +- src/_bentoml_sdk/service/factory.py | 2 +- src/bentoml_cli/_internal/start.py | 8 ++++---- src/bentoml_cli/auth_server.py | 2 +- src/bentoml_cli/deployment.py | 6 ------ 7 files changed, 9 insertions(+), 15 deletions(-) diff --git a/docs/source/build-with-bentoml/services.rst b/docs/source/build-with-bentoml/services.rst index 263758f90d8..4bc0bdeb718 100644 --- a/docs/source/build-with-bentoml/services.rst +++ b/docs/source/build-with-bentoml/services.rst @@ -210,7 +210,7 @@ The asynchronous API implementation is more efficient because when an asynchrono .. warning:: - Avoid implementating blocking logic within asynchronous APIs, since such operations can block the IO event loop, preventing health check endpoints like ``/readyz`` from functioning properly. + Avoid implementing blocking logic within asynchronous APIs, since such operations can block the IO event loop, preventing health check endpoints like ``/readyz`` from functioning properly. Convert synchronous to asynchronous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/source/examples/mlflow.rst b/docs/source/examples/mlflow.rst index 300449c81ef..be67782f99c 100644 --- a/docs/source/examples/mlflow.rst +++ b/docs/source/examples/mlflow.rst @@ -78,7 +78,7 @@ After training, use the ``bentoml.mlflow.import_model`` API to save the model to import bentoml # model_uri can be any URI that refers to an MLflow model - # Use local path for demostration + # Use local path for demonstration bentoml.mlflow.import_model("iris", model_uri) To verify that the model has been successfully saved, run: diff --git a/docs/source/scale-with-bentocloud/deployment/index.rst b/docs/source/scale-with-bentocloud/deployment/index.rst index ecdd38c4682..ebc66857cb5 100644 --- a/docs/source/scale-with-bentocloud/deployment/index.rst +++ b/docs/source/scale-with-bentocloud/deployment/index.rst @@ -2,7 +2,7 @@ Deployment ========== -Read how-to guides to create and mangage your Deployments on BentoCloud. +Read how-to guides to create and manage your Deployments on BentoCloud. .. grid:: 1 2 2 2 :gutter: 3 diff --git a/src/_bentoml_sdk/service/factory.py b/src/_bentoml_sdk/service/factory.py index 44dade6cb48..b50b84e6bb0 100644 --- a/src/_bentoml_sdk/service/factory.py +++ b/src/_bentoml_sdk/service/factory.py @@ -558,7 +558,7 @@ def __init__(self) -> None: if isinstance(gpus, str): gpus = int(gpus) if runner.workers_per_resource > 1: - config["workers"] = {} + config["workers"] = [] workers_per_resource = int(runner.workers_per_resource) if isinstance(gpus, int): gpus = list(range(gpus)) diff --git a/src/bentoml_cli/_internal/start.py b/src/bentoml_cli/_internal/start.py index 300c0158443..ae3babfa65e 100644 --- a/src/bentoml_cli/_internal/start.py +++ b/src/bentoml_cli/_internal/start.py @@ -44,13 +44,13 @@ def cli(): type=click.STRING, envvar="BENTOML_SERVE_RUNNER_MAP", help="[Deprecated] use --depends instead. " - "JSON string of runners map. For backword compatibility for yatai < 1.0.0", + "JSON string of runners map. For backward compatibility for yatai < 1.0.0", ) @click.option( "--bind", type=click.STRING, help="[Deprecated] use --host and --port instead." - "Bind address for the server. For backword compatibility for yatai < 1.0.0", + "Bind address for the server. For backward compatibility for yatai < 1.0.0", required=False, ) @click.option( @@ -399,7 +399,7 @@ def start_grpc_server( # type: ignore (unused warning) "--bind", type=click.STRING, help="[Deprecated] use --host and --port instead." - "Bind address for the server. For backword compatibility for yatai < 1.0.0", + "Bind address for the server. For backward compatibility for yatai < 1.0.0", required=False, ) @click.option( @@ -449,7 +449,7 @@ def start_runner_server( # type: ignore (unused warning) timeout: int | None, ) -> None: """ - Start Runner server standalone. Deprecate in 1.2.0 + Start Runner server standalone. Deprecated in 1.2.0 """ if working_dir is None: if os.path.isdir(os.path.expanduser(bento)): diff --git a/src/bentoml_cli/auth_server.py b/src/bentoml_cli/auth_server.py index 0058633f9a8..a741f159b4a 100644 --- a/src/bentoml_cli/auth_server.py +++ b/src/bentoml_cli/auth_server.py @@ -84,7 +84,7 @@ def callback_url(self) -> str: def wait_indefinitely_for_code(self) -> Optional[str]: """ - Wait indefinitely for ther server to callback from token provider. + Wait indefinitely for the server to callback from the token provider. """ while self._code is None: self.handle_request() diff --git a/src/bentoml_cli/deployment.py b/src/bentoml_cli/deployment.py index b76a3019615..c7ce280a909 100644 --- a/src/bentoml_cli/deployment.py +++ b/src/bentoml_cli/deployment.py @@ -501,12 +501,6 @@ def update( # type: ignore help="Configuration file path", default=None, ) -@click.option( - "-f", - "--config-file", - help="Configuration file path, mututally exclusive with other config options", - default=None, -) @click.option( "--config-dict", type=click.STRING, From f245c7a0ee075c5c0ab17d4c931780935ca7ce05 Mon Sep 17 00:00:00 2001 From: Brayden Zhong Date: Tue, 13 May 2025 21:03:20 -0400 Subject: [PATCH 2/3] fix: huggingface model path --- src/_bentoml_sdk/models/huggingface.py | 41 +++++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/_bentoml_sdk/models/huggingface.py b/src/_bentoml_sdk/models/huggingface.py index ddacdea3ac9..3c38b27ffcf 100644 --- a/src/_bentoml_sdk/models/huggingface.py +++ b/src/_bentoml_sdk/models/huggingface.py @@ -64,9 +64,13 @@ def resolve(self, base_path: t.Union[PathType, FS, None] = None) -> str: from huggingface_hub import snapshot_download if isinstance(base_path, FS): - base_path = base_path.getsyspath("/") + base_path_sys = base_path.getsyspath("/") + elif base_path is not None: + base_path_sys = str(base_path) + else: + base_path_sys = None - snapshot_path = snapshot_download( + snapshot_path_in_cache: str = snapshot_download( self.model_id, revision=self.revision, endpoint=self.endpoint, @@ -74,16 +78,31 @@ def resolve(self, base_path: t.Union[PathType, FS, None] = None) -> str: allow_patterns=self.include, ignore_patterns=self.exclude, ) - if base_path is not None: - model_path = os.path.dirname(os.path.dirname(snapshot_path)) - os.makedirs(base_path, exist_ok=True) - shutil.copytree( - model_path, - os.path.join(base_path, os.path.basename(model_path)), - symlinks=True, - dirs_exist_ok=True, + + if base_path_sys is not None: + os.makedirs(base_path_sys, exist_ok=True) + + destination_subdir_name: str = os.path.basename( + snapshot_path_in_cache ) - return snapshot_path + destination_path_for_copy: str = os.path.join( + base_path_sys, destination_subdir_name + ) + + if ( + os.path.abspath(snapshot_path_in_cache) + != os.path.abspath(destination_path_for_copy) + ): + if os.path.exists(destination_path_for_copy): + shutil.rmtree(destination_path_for_copy) + shutil.copytree( + snapshot_path_in_cache, + destination_path_for_copy, + symlinks=True, + dirs_exist_ok=False, + ) + + return snapshot_path_in_cache def to_info(self, alias: str | None = None) -> BentoModelInfo: model_id = self.model_id.lower() From 6c41745884018bdb60cde50e730edceda3374054 Mon Sep 17 00:00:00 2001 From: Brayden Zhong Date: Tue, 13 May 2025 21:09:53 -0400 Subject: [PATCH 3/3] fix: huggingface model path --- src/_bentoml_sdk/models/huggingface.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/_bentoml_sdk/models/huggingface.py b/src/_bentoml_sdk/models/huggingface.py index 3c38b27ffcf..ead428d33f0 100644 --- a/src/_bentoml_sdk/models/huggingface.py +++ b/src/_bentoml_sdk/models/huggingface.py @@ -82,16 +82,13 @@ def resolve(self, base_path: t.Union[PathType, FS, None] = None) -> str: if base_path_sys is not None: os.makedirs(base_path_sys, exist_ok=True) - destination_subdir_name: str = os.path.basename( - snapshot_path_in_cache - ) + destination_subdir_name: str = os.path.basename(snapshot_path_in_cache) destination_path_for_copy: str = os.path.join( base_path_sys, destination_subdir_name ) - if ( - os.path.abspath(snapshot_path_in_cache) - != os.path.abspath(destination_path_for_copy) + if os.path.abspath(snapshot_path_in_cache) != os.path.abspath( + destination_path_for_copy ): if os.path.exists(destination_path_for_copy): shutil.rmtree(destination_path_for_copy)