Skip to content

Commit af9d664

Browse files
authored
fix: use the same spinner for bento and model apis (#5161)
Signed-off-by: Frost Ming <[email protected]>
1 parent 0838750 commit af9d664

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/bentoml/_internal/cloud/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from bentoml._internal.cloud.client import RestApiClient
66

7+
from .base import Spinner
78
from .bento import BentoAPI
89
from .config import DEFAULT_ENDPOINT
910
from .config import CloudClientConfig
@@ -50,8 +51,9 @@ def __init__(
5051
endpoint = ctx.endpoint
5152

5253
client = RestApiClient(endpoint, api_key, timeout)
53-
bento = BentoAPI(client)
54-
model = ModelAPI(client)
54+
spinner = Spinner()
55+
bento = BentoAPI(client, spinner=spinner)
56+
model = ModelAPI(client, spinner=spinner)
5557
deployment = DeploymentAPI(client)
5658
secret = SecretAPI(client)
5759

src/bentoml/_internal/cloud/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def __init__(self, console: Console | None = None) -> None:
119119
)
120120
self._spinner_task_id: t.Optional[TaskID] = None
121121
self._live = Live(self, console=self.console)
122+
self._start_count = 0
122123

123124
@contextmanager
124125
def spin(self, text: str) -> t.Generator[TaskID, None, None]:
@@ -150,10 +151,14 @@ def __rich_console__(
150151

151152
def start(self) -> None:
152153
"""Start live updating."""
154+
self._start_count += 1
153155
self._live.start()
154156

155157
def stop(self) -> None:
156158
"""Stop live updating."""
159+
self._start_count -= 1
160+
if self._start_count > 0:
161+
return
157162
if self._spinner_task_id is not None:
158163
self._spinner_progress.remove_task(self._spinner_task_id)
159164
self._spinner_task_id = None

0 commit comments

Comments
 (0)