Skip to content

Commit 8f58d3e

Browse files
authored
Fixed starting/running messaging (#76)
* Fixed starting/running messaging * formatting
1 parent 2348361 commit 8f58d3e

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

src/codeflare_sdk/cluster/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def login(self) -> str:
7070
args.append("--insecure-skip-tls-verify")
7171
try:
7272
response = oc.invoke("login", args)
73-
except OpenShiftPythonException as osp:
73+
except OpenShiftPythonException as osp: # pragma: no cover
7474
error_msg = osp.result.err()
7575
if "The server uses a certificate signed by unknown authority" in error_msg:
7676
return "Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication"

src/codeflare_sdk/cluster/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def status(
190190
if status == CodeFlareClusterStatus.UNKNOWN:
191191
pretty_print.print_no_resources_found()
192192
else:
193-
pretty_print.print_app_wrappers_status([appwrapper])
193+
pretty_print.print_app_wrappers_status([appwrapper], starting=True)
194194

195195
return status, ready
196196

src/codeflare_sdk/utils/pretty_print.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def print_no_resources_found():
3232
console.print(Panel("[red]No resources found, have you run cluster.up() yet?"))
3333

3434

35-
def print_app_wrappers_status(app_wrappers: List[AppWrapper]):
35+
def print_app_wrappers_status(app_wrappers: List[AppWrapper], starting: bool = False):
3636
if not app_wrappers:
3737
print_no_resources_found()
3838
return # shortcircuit
@@ -48,6 +48,8 @@ def print_app_wrappers_status(app_wrappers: List[AppWrapper]):
4848
for app_wrapper in app_wrappers:
4949
name = app_wrapper.name
5050
status = app_wrapper.status.value
51+
if starting:
52+
status += " (starting)"
5153
table.add_row(name, status)
5254
table.add_row("") # empty row for spacing
5355

@@ -57,7 +59,7 @@ def print_app_wrappers_status(app_wrappers: List[AppWrapper]):
5759
def print_cluster_status(cluster: RayCluster):
5860
"Pretty prints the status of a passed-in cluster"
5961
if not cluster:
60-
print_no_resources_found
62+
print_no_resources_found()
6163
return
6264

6365
console = Console()

tests/unit_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ def test_print_no_resources(capsys):
320320
)
321321

322322

323+
def test_print_no_cluster(capsys):
324+
try:
325+
print_cluster_status(None)
326+
except:
327+
assert 1 == 0
328+
captured = capsys.readouterr()
329+
assert captured.out == (
330+
"╭──────────────────────────────────────────────────────────────────────────────╮\n"
331+
"│ No resources found, have you run cluster.up() yet? │\n"
332+
"╰──────────────────────────────────────────────────────────────────────────────╯\n"
333+
)
334+
335+
323336
def test_print_appwrappers(capsys):
324337
aw1 = AppWrapper(
325338
name="awtest1",
@@ -1576,3 +1589,8 @@ def test_cmd_line_generation():
15761589
)
15771590
os.remove("unit-test-cluster.yaml")
15781591
os.remove("unit-cmd-cluster.yaml")
1592+
1593+
1594+
def test_cleanup():
1595+
os.remove("test.yaml")
1596+
os.remove("raytest2.yaml")

0 commit comments

Comments
 (0)