From f2928093270a03776494d5374395e938163b4663 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 26 Dec 2024 17:59:42 +0800 Subject: [PATCH] fix: use emoji code instead of emoji char Signed-off-by: Frost Ming --- src/bentoml/_internal/cloud/bento.py | 4 +-- src/bentoml/_internal/cloud/deployment.py | 42 +++++++++++++---------- src/bentoml/_internal/cloud/model.py | 4 +-- src/bentoml_cli/cloud.py | 23 ++++++++----- src/bentoml_cli/deployment.py | 4 +-- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/bentoml/_internal/cloud/bento.py b/src/bentoml/_internal/cloud/bento.py index 55822209780..d5d10e2c2ad 100644 --- a/src/bentoml/_internal/cloud/bento.py +++ b/src/bentoml/_internal/cloud/bento.py @@ -252,11 +252,11 @@ def filter_( ) except Exception as e: # pylint: disable=broad-except self.spinner.log( - f'[bold red]🚨 Failed to upload bento "{bento.tag}"' + f'[bold red]:police_car_light: Failed to upload bento "{bento.tag}"' ) raise e self.spinner.log( - f'[bold green]✅ Successfully pushed bento "{bento.tag}"' + f'[bold green]:white_check_mark: Successfully pushed bento "{bento.tag}"' ) return finish_req = FinishUploadSchema( diff --git a/src/bentoml/_internal/cloud/deployment.py b/src/bentoml/_internal/cloud/deployment.py index 6fd9811bc01..873132f23ba 100644 --- a/src/bentoml/_internal/cloud/deployment.py +++ b/src/bentoml/_internal/cloud/deployment.py @@ -345,7 +345,7 @@ def ensure_bento( build_ctx=project_path, bare=bare, _bento_store=_bento_store, reload=reload ) if cli: - rich.print(f"🍱 Built bento [green]{bento_obj.info.tag}[/]") + rich.print(f":bento: Built bento [green]{bento_obj.info.tag}[/]") if push: bento_api.push(bento=bento_obj, bare=bare) return bento_obj @@ -561,7 +561,7 @@ def tail_image_builder_logs() -> None: if pod is None: if time.time() - started_at > timeout: spinner.console.print( - "🚨 [bold red]Time out waiting for image builder pod created[/bold red]" + ":police_car_light: [bold red]Time out waiting for image builder pod created[/bold red]" ) return if stop_tail_event.wait(check_interval): @@ -571,7 +571,7 @@ def tail_image_builder_logs() -> None: break if time.time() - started_at > wait_pod_timeout: spinner.console.print( - "🚨 [bold red]Time out waiting for image builder pod running[/bold red]" + ":police_car_light: [bold red]Time out waiting for image builder pod running[/bold red]" ) return if stop_tail_event.wait(check_interval): @@ -591,7 +591,7 @@ def tail_image_builder_logs() -> None: decoded_str = decoded_bytes.decode("utf-8") if is_first: is_first = False - spinner.update("🚧 Image building...") + spinner.update(":construction: Image building...") spinner.stop() console.print(decoded_str, end="", markup=False, highlight=False) @@ -599,17 +599,21 @@ def tail_image_builder_logs() -> None: try: status: DeploymentState | None = None - spinner.update(f'🔄 Waiting for deployment "{self.name}" to be ready...') + spinner.update( + f':hourglass: Waiting for deployment "{self.name}" to be ready...' + ) while time.time() - start_time < timeout: for _ in range(3): try: new_status = self.get_status() break except TimeoutException: - spinner.update("⚠️ Unable to get deployment status, retrying...") + spinner.update( + ":warning: Unable to get deployment status, retrying..." + ) else: spinner.log( - "🚨 [bold red]Unable to contact the server, but the deployment is created. " + ":police_car_light: [bold red]Unable to contact the server, but the deployment is created. " "You can check the status on the bentocloud website.[/bold red]" ) return 1 @@ -618,7 +622,7 @@ def tail_image_builder_logs() -> None: ): # on status change status = new_status spinner.update( - f'🔄 Waiting for deployment "{self.name}" to be ready. Current status: "{status.status}"' + f':hourglass: Waiting for deployment "{self.name}" to be ready. Current status: "{status.status}"' ) if status.status == DeploymentStatus.ImageBuilding.value: if tail_thread is None: @@ -643,7 +647,7 @@ def tail_image_builder_logs() -> None: ]: spinner.stop() console.print( - f'🚨 [bold red]Deployment "{self.name}" is not ready. Current status: "{status.status}"[/]' + f':police_car_light: [bold red]Deployment "{self.name}" is not ready. Current status: "{status.status}"[/]' ) return 1 if status.status in ( @@ -652,7 +656,7 @@ def tail_image_builder_logs() -> None: ): spinner.stop() console.print( - f'✅ [bold green] Deployment "{self.name}" is ready:[/] {self.admin_console}' + f':white_check_mark: [bold green] Deployment "{self.name}" is ready:[/] {self.admin_console}' ) break @@ -660,7 +664,7 @@ def tail_image_builder_logs() -> None: else: spinner.stop() console.print( - f'🚨 [bold red]Time out waiting for Deployment "{self.name}" ready[/]' + f':police_car_light: [bold red]Time out waiting for Deployment "{self.name}" ready[/]' ) return 1 @@ -730,7 +734,7 @@ def _init_deployment_files( check_interval = 5 start_time = time.time() console = spinner.console - spinner_text = "🔄 Preparing codespace - status: [green]{}[/]" + spinner_text = ":hourglass: Preparing codespace - status: [green]{}[/]" status = self.get_status(False).status while time.time() - start_time < timeout: spinner.update(spinner_text.format(status)) @@ -871,7 +875,7 @@ def is_bento_changed(bento_info: Bento) -> bool: spinner = Spinner(console=console) needs_update = is_bento_changed(bento_info) - spinner.log(f"💻 View Dashboard: {self.admin_console}") + spinner.log(f":laptop_computer: View Dashboard: {self.admin_console}") endpoint_url: str | None = None stop_event = Event() try: @@ -882,10 +886,12 @@ def is_bento_changed(bento_info: Bento) -> bool: while True: stop_event.clear() if needs_update: - console.print("✨ [green bold]Bento change detected[/]") - spinner.update("🔄 Pushing Bento to BentoCloud") + console.print(":sparkles: [green bold]Bento change detected[/]") + spinner.update(":hourglass: Pushing Bento to BentoCloud") bento_api._do_push_bento(bento_info, upload_id, bare=True) # type: ignore - spinner.update("🔄 Updating codespace with new configuration") + spinner.update( + ":hourglass: Updating codespace with new configuration" + ) update_config = DeploymentConfigParameters( bento=str(bento_info.tag), name=self.name, @@ -920,7 +926,7 @@ def is_bento_changed(bento_info: Bento) -> bool: ) except Exception as e: spinner.console.print( - f"🚨 [bold red]Failed to build Bento: {e}[/]" + f":police_car_light: [bold red]Failed to build Bento: {e}[/]" ) else: assert isinstance(bento_info, Bento) @@ -980,7 +986,7 @@ def is_bento_changed(bento_info: Bento) -> bool: DeploymentStatus.Unhealthy.value, ]: console.print( - f'🚨 [bold red]Codespace "{self.name}" aborted. Current status: "{status}"[/]' + f':police_car_light: [bold red]Codespace "{self.name}" aborted. Current status: "{status}"[/]' ) return except KeyboardInterrupt: diff --git a/src/bentoml/_internal/cloud/model.py b/src/bentoml/_internal/cloud/model.py index dac549eca6a..72254205b74 100644 --- a/src/bentoml/_internal/cloud/model.py +++ b/src/bentoml/_internal/cloud/model.py @@ -187,11 +187,11 @@ def io_cb(x: int): ) except Exception as e: # pylint: disable=broad-except self.spinner.log( - f'[bold red]🚨 Failed to upload model "{model.tag}"' + f'[bold red]:police_car_light: Failed to upload model "{model.tag}"' ) raise e self.spinner.log( - f'[bold green]✅ Successfully pushed model "{model.tag}"' + f'[bold green]:white_check_mark: Successfully pushed model "{model.tag}"' ) return finish_req = FinishUploadSchema( diff --git a/src/bentoml_cli/cloud.py b/src/bentoml_cli/cloud.py index a31fd17f698..7bf896eb383 100644 --- a/src/bentoml_cli/cloud.py +++ b/src/bentoml_cli/cloud.py @@ -77,15 +77,19 @@ def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed) default=True, ): if webbrowser.open_new_tab(authURL): - rich.print(f"✅ Opened [blue]{authURL}[/] in your web browser.") + rich.print( + f":white_check_mark: Opened [blue]{authURL}[/] in your web browser." + ) else: rich.print( - f"🚨 Failed to open browser. Try create a new API token at {baseURL} or Open [blue]{authURL}[/] yourself" + f":police_car_light: Failed to open browser. Try create a new API token at {baseURL} or Open [blue]{authURL}[/] yourself" ) else: - rich.print(f"🫱 Open [blue]{authURL}[/] yourself...") + rich.print( + f":backhand_index_pointing_right: Open [blue]{authURL}[/] yourself..." + ) try: - rich.print("🔒 Waiting for authentication...") + rich.print(":hourglass: Waiting for authentication...") code = callback_server.wait_indefinitely_for_code() if code is None: raise ValueError( @@ -93,7 +97,7 @@ def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed) ) api_token = code except Exception: - rich.print("🚨 Error accquiring token from web browser") + rich.print(":police_car_light: Error accquiring token from web browser") return elif choice == "paste": api_token = click.prompt( @@ -123,20 +127,21 @@ def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed) ctx.save() rich.print( - f"✅ Configured BentoCloud credentials (current-context: {ctx.name})" + f":white_check_mark: Configured BentoCloud credentials (current-context: {ctx.name})" ) rich.print( - f"✅ Logged in as [blue]{user.email}[/] at [blue]{org.name}[/] organization" + f":white_check_mark: Logged in as [blue]{user.email}[/] at [blue]{org.name}[/] organization" ) except CloudRESTApiClientError as e: if e.error_code == 401: rich.print( - f"🚨 Error validating token: HTTP 401: Bad credentials ({endpoint}/api-token)", + f":police_car_light: Error validating token: HTTP 401: Bad credentials ({endpoint}/api-token)", file=sys.stderr, ) else: rich.print( - f"🚨 Error validating token: HTTP {e.error_code}", file=sys.stderr + f":police_car_light: Error validating token: HTTP {e.error_code}", + file=sys.stderr, ) diff --git a/src/bentoml_cli/deployment.py b/src/bentoml_cli/deployment.py index abaa739cca5..52e37649541 100644 --- a/src/bentoml_cli/deployment.py +++ b/src/bentoml_cli/deployment.py @@ -893,9 +893,9 @@ def create_deployment( deployment_config_params=config_params ) spinner.log( - f'✅ Created deployment "{deployment.name}" in cluster "{deployment.cluster}"' + f':white_check_mark: Created deployment "{deployment.name}" in cluster "{deployment.cluster}"' ) - spinner.log(f"💻 View Dashboard: {deployment.admin_console}") + spinner.log(f":laptop_computer: View Dashboard: {deployment.admin_console}") if wait: spinner.update( "[bold blue]Waiting for deployment to be ready, you can use --no-wait to skip this process[/]",