Skip to content

Commit

Permalink
feat: change spinner text on status change and show spinner after ima…
Browse files Browse the repository at this point in the history
…ge build done (#4867)

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored Jul 18, 2024
1 parent ab4250d commit 694a5f2
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/bentoml/_internal/cloud/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,26 +560,37 @@ def tail_image_builder_logs() -> None:
while time.time() - start_time < timeout:
for _ in range(3):
try:
status = self.get_status()
new_status = self.get_status()
break
except TimeoutException:
spinner.update(
"⚠️ Unable to get deployment status, retrying..."
)
if status is None:
else:
spinner.log(
"🚨 [bold red]Unable to contact the server, but the deployment is created. You can check the status on the bentocloud website.[/bold red]"
"🚨 [bold red]Unable to contact the server, but the deployment is created. "
"You can check the status on the bentocloud website.[/bold red]"
)
return
spinner.update(
f'🔄 Waiting for deployment "{self.name}" to be ready. Current status: "{status.status}"'
)
if status.status == DeploymentStatus.ImageBuilding.value:
if tail_thread is None:
tail_thread = Thread(
target=tail_image_builder_logs, daemon=True
)
tail_thread.start()
if (
status is None or status.status != new_status.status
): # on status change
status = new_status
spinner.update(
f'🔄 Waiting for deployment "{self.name}" to be ready. Current status: "{status.status}"'
)
if status.status == DeploymentStatus.ImageBuilding.value:
if tail_thread is None:
tail_thread = Thread(
target=tail_image_builder_logs, daemon=True
)
tail_thread.start()
elif (
tail_thread is not None
): # The status has changed from ImageBuilding to other
stop_tail_event.set()
tail_thread.join()
spinner.start()

if status.status in (
DeploymentStatus.Running.value,
Expand Down

0 comments on commit 694a5f2

Please sign in to comment.