Skip to content

fix(sdk/cli): Correct HuggingFace model copy #5355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/build-with-bentoml/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/mlflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/scale-with-bentocloud/deployment/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 27 additions & 11 deletions src/_bentoml_sdk/models/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,42 @@ 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,
cache_dir=os.getenv("BENTOML_HF_CACHE_DIR"),
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)
destination_path_for_copy: str = os.path.join(
base_path_sys, destination_subdir_name
)
return snapshot_path

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()
Expand Down
2 changes: 1 addition & 1 deletion src/_bentoml_sdk/service/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions src/bentoml_cli/_internal/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion src/bentoml_cli/auth_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 0 additions & 6 deletions src/bentoml_cli/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,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,
Expand Down