Skip to content

Commit f14dc93

Browse files
committed
port appwrapper status to v1beta2 names
1 parent cf9e7f5 commit f14dc93

File tree

3 files changed

+46
-66
lines changed

3 files changed

+46
-66
lines changed

src/codeflare_sdk/cluster/cluster.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -272,25 +272,23 @@ def status(
272272
appwrapper = _app_wrapper_status(self.config.name, self.config.namespace)
273273
if appwrapper:
274274
if appwrapper.status in [
275-
AppWrapperStatus.RUNNING,
276-
AppWrapperStatus.COMPLETED,
277-
AppWrapperStatus.RUNNING_HOLD_COMPLETION,
275+
AppWrapperStatus.RESUMING,
276+
AppWrapperStatus.RESETTING,
278277
]:
279278
ready = False
280279
status = CodeFlareClusterStatus.STARTING
281280
elif appwrapper.status in [
282281
AppWrapperStatus.FAILED,
283-
AppWrapperStatus.DELETED,
284282
]:
285283
ready = False
286284
status = CodeFlareClusterStatus.FAILED # should deleted be separate
287285
return status, ready # exit early, no need to check ray status
288286
elif appwrapper.status in [
289-
AppWrapperStatus.PENDING,
290-
AppWrapperStatus.QUEUEING,
287+
AppWrapperStatus.SUSPENDED,
288+
AppWrapperStatus.SUSPENDING,
291289
]:
292290
ready = False
293-
if appwrapper.status == AppWrapperStatus.PENDING:
291+
if appwrapper.status == AppWrapperStatus.SUSPENDED:
294292
status = CodeFlareClusterStatus.QUEUED
295293
else:
296294
status = CodeFlareClusterStatus.QUEUEING
@@ -562,9 +560,7 @@ def list_all_queued(
562560
in a given namespace.
563561
"""
564562
if appwrapper:
565-
resources = _get_app_wrappers(
566-
namespace, filter=[AppWrapperStatus.RUNNING, AppWrapperStatus.PENDING]
567-
)
563+
resources = _get_app_wrappers(namespace, filter=[AppWrapperStatus.SUSPENDED])
568564
if print_to_console:
569565
pretty_print.print_app_wrappers_status(resources)
570566
else:
@@ -892,18 +888,14 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
892888

893889

894890
def _map_to_app_wrapper(aw) -> AppWrapper:
895-
if "status" in aw and "canrun" in aw["status"]:
891+
if "status" in aw:
896892
return AppWrapper(
897893
name=aw["metadata"]["name"],
898894
status=AppWrapperStatus(aw["status"]["state"].lower()),
899-
can_run=aw["status"]["canrun"],
900-
job_state=aw["status"]["queuejobstate"],
901895
)
902896
return AppWrapper(
903897
name=aw["metadata"]["name"],
904-
status=AppWrapperStatus("queueing"),
905-
can_run=False,
906-
job_state="Still adding to queue",
898+
status=AppWrapperStatus("suspended"),
907899
)
908900

909901

src/codeflare_sdk/cluster/model.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ class RayClusterStatus(Enum):
3737

3838
class AppWrapperStatus(Enum):
3939
"""
40-
Defines the possible reportable states of an AppWrapper.
40+
Defines the possible reportable phases of an AppWrapper.
4141
"""
4242

43-
QUEUEING = "queueing"
44-
PENDING = "pending"
43+
SUSPENDED = "suspended"
44+
RESUMING = "resuming"
4545
RUNNING = "running"
46+
RESETTING = "resetting"
47+
SUSPENDING = "suspending"
48+
SUCCEEDED = "succeeded"
4649
FAILED = "failed"
47-
DELETED = "deleted"
48-
COMPLETED = "completed"
49-
RUNNING_HOLD_COMPLETION = "runningholdcompletion"
50+
TERMINATING = "terminating"
5051

5152

5253
class CodeFlareClusterStatus(Enum):
@@ -91,5 +92,3 @@ class AppWrapper:
9192

9293
name: str
9394
status: AppWrapperStatus
94-
can_run: bool
95-
job_state: str

tests/unit_test.py

+31-42
Original file line numberDiff line numberDiff line change
@@ -787,34 +787,30 @@ def test_print_no_cluster(capsys):
787787
def test_print_appwrappers(capsys):
788788
aw1 = AppWrapper(
789789
name="awtest1",
790-
status=AppWrapperStatus.PENDING,
791-
can_run=False,
792-
job_state="queue-state",
790+
status=AppWrapperStatus.SUSPENDED,
793791
)
794792
aw2 = AppWrapper(
795793
name="awtest2",
796794
status=AppWrapperStatus.RUNNING,
797-
can_run=False,
798-
job_state="queue-state",
799795
)
800796
try:
801797
print_app_wrappers_status([aw1, aw2])
802798
except:
803799
assert 1 == 0
804800
captured = capsys.readouterr()
805801
assert captured.out == (
806-
"╭───────────────────────╮\n"
807-
"│ 🚀 Cluster Queue │\n"
808-
"│ Status 🚀 │\n"
809-
"│ +---------+---------+ │\n"
810-
"│ | Name | Status | │\n"
811-
"│ +=========+=========+ │\n"
812-
"│ | awtest1 | pending | │\n"
813-
"│ | | | │\n"
814-
"│ | awtest2 | running | │\n"
815-
"│ | | | │\n"
816-
"│ +---------+---------+ │\n"
817-
"╰───────────────────────╯\n"
802+
"╭─────────────────────────\n"
803+
"│ 🚀 Cluster Queue \n"
804+
"│ Status 🚀 \n"
805+
"│ +---------+-----------+ │\n"
806+
"│ | Name | Status | │\n"
807+
"│ +=========+===========+ │\n"
808+
"│ | awtest1 | suspended | │\n"
809+
"│ | | | │\n"
810+
"│ | awtest2 | running | │\n"
811+
"│ | | | │\n"
812+
"│ +---------+-----------+ │\n"
813+
"╰─────────────────────────\n"
818814
)
819815

820816

@@ -2058,7 +2054,7 @@ def get_aw_obj(group, version, namespace, plural):
20582054
"filterignore": True,
20592055
"queuejobstate": "Dispatched",
20602056
"sender": "before manageQueueJob - afterEtcdDispatching",
2061-
"state": "Pending",
2057+
"state": "Suspended",
20622058
"systempriority": 9,
20632059
},
20642060
},
@@ -2348,18 +2344,18 @@ def test_list_queue(mocker, capsys):
23482344
list_all_queued("ns", appwrapper=True)
23492345
captured = capsys.readouterr()
23502346
assert captured.out == (
2351-
"╭──────────────────────────╮\n"
2352-
"│ 🚀 Cluster Queue Status │\n"
2353-
"│ 🚀\n"
2354-
"│ +------------+---------+ │\n"
2355-
"│ | Name | Status | │\n"
2356-
"│ +============+=========+ │\n"
2357-
"│ | quicktest1 | running | │\n"
2358-
"│ | | | │\n"
2359-
"│ | quicktest2 | pending | │\n"
2360-
"│ | | | │\n"
2361-
"│ +------------+---------+ │\n"
2362-
"╰──────────────────────────╯\n"
2347+
"╭────────────────────────────\n"
2348+
"│ 🚀 Cluster Queue Status \n"
2349+
"│ 🚀 \n"
2350+
"│ +------------+-----------+ │\n"
2351+
"│ | Name | Status | │\n"
2352+
"│ +============+===========+ │\n"
2353+
"│ | quicktest1 | running | │\n"
2354+
"│ | | | │\n"
2355+
"│ | quicktest2 | suspended | │\n"
2356+
"│ | | | │\n"
2357+
"│ +------------+-----------+ │\n"
2358+
"╰────────────────────────────\n"
23632359
)
23642360

23652361

@@ -2409,9 +2405,7 @@ def test_list_queue_rayclusters(mocker, capsys):
24092405
def test_cluster_status(mocker):
24102406
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
24112407
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
2412-
fake_aw = AppWrapper(
2413-
"test", AppWrapperStatus.FAILED, can_run=True, job_state="unused"
2414-
)
2408+
fake_aw = AppWrapper("test", AppWrapperStatus.FAILED)
24152409
fake_ray = RayCluster(
24162410
name="test",
24172411
status=RayClusterStatus.UNKNOWN,
@@ -2448,29 +2442,24 @@ def test_cluster_status(mocker):
24482442
assert status == CodeFlareClusterStatus.FAILED
24492443
assert ready == False
24502444

2451-
fake_aw.status = AppWrapperStatus.DELETED
2452-
status, ready = cf.status()
2453-
assert status == CodeFlareClusterStatus.FAILED
2454-
assert ready == False
2455-
2456-
fake_aw.status = AppWrapperStatus.PENDING
2445+
fake_aw.status = AppWrapperStatus.SUSPENDED
24572446
status, ready = cf.status()
24582447
assert status == CodeFlareClusterStatus.QUEUED
24592448
assert ready == False
24602449

2461-
fake_aw.status = AppWrapperStatus.COMPLETED
2450+
fake_aw.status = AppWrapperStatus.RESUMING
24622451
status, ready = cf.status()
24632452
assert status == CodeFlareClusterStatus.STARTING
24642453
assert ready == False
24652454

2466-
fake_aw.status = AppWrapperStatus.RUNNING_HOLD_COMPLETION
2455+
fake_aw.status = AppWrapperStatus.RESETTING
24672456
status, ready = cf.status()
24682457
assert status == CodeFlareClusterStatus.STARTING
24692458
assert ready == False
24702459

24712460
fake_aw.status = AppWrapperStatus.RUNNING
24722461
status, ready = cf.status()
2473-
assert status == CodeFlareClusterStatus.STARTING
2462+
assert status == CodeFlareClusterStatus.UNKNOWN
24742463
assert ready == False
24752464

24762465
mocker.patch(

0 commit comments

Comments
 (0)