From c3e7480ac2fb449abfc92c61f31fc29bb678c226 Mon Sep 17 00:00:00 2001 From: maxusmusti Date: Tue, 21 Mar 2023 17:35:32 -0400 Subject: [PATCH 1/2] Fixed starting/running messaging --- src/codeflare_sdk/cluster/auth.py | 2 +- src/codeflare_sdk/cluster/cluster.py | 2 +- src/codeflare_sdk/utils/pretty_print.py | 6 ++++-- tests/unit_test.py | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/codeflare_sdk/cluster/auth.py b/src/codeflare_sdk/cluster/auth.py index edf38fde2..19f749025 100644 --- a/src/codeflare_sdk/cluster/auth.py +++ b/src/codeflare_sdk/cluster/auth.py @@ -70,7 +70,7 @@ def login(self) -> str: args.append("--insecure-skip-tls-verify") try: response = oc.invoke("login", args) - except OpenShiftPythonException as osp: + except OpenShiftPythonException as osp: # pragma: no cover error_msg = osp.result.err() if "The server uses a certificate signed by unknown authority" in error_msg: return "Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication" diff --git a/src/codeflare_sdk/cluster/cluster.py b/src/codeflare_sdk/cluster/cluster.py index 3f172aa6b..b98eeb54f 100644 --- a/src/codeflare_sdk/cluster/cluster.py +++ b/src/codeflare_sdk/cluster/cluster.py @@ -190,7 +190,7 @@ def status( if status == CodeFlareClusterStatus.UNKNOWN: pretty_print.print_no_resources_found() else: - pretty_print.print_app_wrappers_status([appwrapper]) + pretty_print.print_app_wrappers_status([appwrapper], starting=True) return status, ready diff --git a/src/codeflare_sdk/utils/pretty_print.py b/src/codeflare_sdk/utils/pretty_print.py index 1591658a6..0fd17e610 100644 --- a/src/codeflare_sdk/utils/pretty_print.py +++ b/src/codeflare_sdk/utils/pretty_print.py @@ -32,7 +32,7 @@ def print_no_resources_found(): console.print(Panel("[red]No resources found, have you run cluster.up() yet?")) -def print_app_wrappers_status(app_wrappers: List[AppWrapper]): +def print_app_wrappers_status(app_wrappers: List[AppWrapper], starting: bool = False): if not app_wrappers: print_no_resources_found() return # shortcircuit @@ -48,6 +48,8 @@ def print_app_wrappers_status(app_wrappers: List[AppWrapper]): for app_wrapper in app_wrappers: name = app_wrapper.name status = app_wrapper.status.value + if starting: + status += " (starting)" table.add_row(name, status) table.add_row("") # empty row for spacing @@ -57,7 +59,7 @@ def print_app_wrappers_status(app_wrappers: List[AppWrapper]): def print_cluster_status(cluster: RayCluster): "Pretty prints the status of a passed-in cluster" if not cluster: - print_no_resources_found + print_no_resources_found() return console = Console() diff --git a/tests/unit_test.py b/tests/unit_test.py index c6a0041b0..5b2eebaab 100644 --- a/tests/unit_test.py +++ b/tests/unit_test.py @@ -320,6 +320,19 @@ def test_print_no_resources(capsys): ) +def test_print_no_cluster(capsys): + try: + print_cluster_status(None) + except: + assert 1 == 0 + captured = capsys.readouterr() + assert captured.out == ( + "╭──────────────────────────────────────────────────────────────────────────────╮\n" + "│ No resources found, have you run cluster.up() yet? │\n" + "╰──────────────────────────────────────────────────────────────────────────────╯\n" + ) + + def test_print_appwrappers(capsys): aw1 = AppWrapper( name="awtest1", @@ -1576,3 +1589,7 @@ def test_cmd_line_generation(): ) os.remove("unit-test-cluster.yaml") os.remove("unit-cmd-cluster.yaml") + +def test_cleanup(): + os.remove("test.yaml") + os.remove("raytest2.yaml") From 1d5bba14bc64ef079946b4b6d78de64fb3fc919b Mon Sep 17 00:00:00 2001 From: maxusmusti Date: Tue, 21 Mar 2023 17:58:24 -0400 Subject: [PATCH 2/2] formatting --- tests/unit_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit_test.py b/tests/unit_test.py index 5b2eebaab..950514004 100644 --- a/tests/unit_test.py +++ b/tests/unit_test.py @@ -1590,6 +1590,7 @@ def test_cmd_line_generation(): os.remove("unit-test-cluster.yaml") os.remove("unit-cmd-cluster.yaml") + def test_cleanup(): os.remove("test.yaml") os.remove("raytest2.yaml")