Skip to content

Commit 3d6a367

Browse files
committed
port appwrapper status to v1beta2 names
1 parent 8049b4b commit 3d6a367

File tree

3 files changed

+46
-66
lines changed

3 files changed

+46
-66
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,23 @@ def status(
274274
appwrapper = _app_wrapper_status(self.config.name, self.config.namespace)
275275
if appwrapper:
276276
if appwrapper.status in [
277-
AppWrapperStatus.RUNNING,
278-
AppWrapperStatus.COMPLETED,
279-
AppWrapperStatus.RUNNING_HOLD_COMPLETION,
277+
AppWrapperStatus.RESUMING,
278+
AppWrapperStatus.RESETTING,
280279
]:
281280
ready = False
282281
status = CodeFlareClusterStatus.STARTING
283282
elif appwrapper.status in [
284283
AppWrapperStatus.FAILED,
285-
AppWrapperStatus.DELETED,
286284
]:
287285
ready = False
288286
status = CodeFlareClusterStatus.FAILED # should deleted be separate
289287
return status, ready # exit early, no need to check ray status
290288
elif appwrapper.status in [
291-
AppWrapperStatus.PENDING,
292-
AppWrapperStatus.QUEUEING,
289+
AppWrapperStatus.SUSPENDED,
290+
AppWrapperStatus.SUSPENDING,
293291
]:
294292
ready = False
295-
if appwrapper.status == AppWrapperStatus.PENDING:
293+
if appwrapper.status == AppWrapperStatus.SUSPENDED:
296294
status = CodeFlareClusterStatus.QUEUED
297295
else:
298296
status = CodeFlareClusterStatus.QUEUEING
@@ -567,9 +565,7 @@ def list_all_queued(
567565
in a given namespace.
568566
"""
569567
if appwrapper:
570-
resources = _get_app_wrappers(
571-
namespace, filter=[AppWrapperStatus.RUNNING, AppWrapperStatus.PENDING]
572-
)
568+
resources = _get_app_wrappers(namespace, filter=[AppWrapperStatus.SUSPENDED])
573569
if print_to_console:
574570
pretty_print.print_app_wrappers_status(resources)
575571
else:
@@ -909,18 +905,14 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
909905

910906

911907
def _map_to_app_wrapper(aw) -> AppWrapper:
912-
if "status" in aw and "canrun" in aw["status"]:
908+
if "status" in aw:
913909
return AppWrapper(
914910
name=aw["metadata"]["name"],
915911
status=AppWrapperStatus(aw["status"]["state"].lower()),
916-
can_run=aw["status"]["canrun"],
917-
job_state=aw["status"]["queuejobstate"],
918912
)
919913
return AppWrapper(
920914
name=aw["metadata"]["name"],
921-
status=AppWrapperStatus("queueing"),
922-
can_run=False,
923-
job_state="Still adding to queue",
915+
status=AppWrapperStatus("suspended"),
924916
)
925917

926918

src/codeflare_sdk/cluster/model.py

Lines changed: 7 additions & 8 deletions
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

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -816,34 +816,30 @@ def test_print_no_cluster(capsys):
816816
def test_print_appwrappers(capsys):
817817
aw1 = AppWrapper(
818818
name="awtest1",
819-
status=AppWrapperStatus.PENDING,
820-
can_run=False,
821-
job_state="queue-state",
819+
status=AppWrapperStatus.SUSPENDED,
822820
)
823821
aw2 = AppWrapper(
824822
name="awtest2",
825823
status=AppWrapperStatus.RUNNING,
826-
can_run=False,
827-
job_state="queue-state",
828824
)
829825
try:
830826
print_app_wrappers_status([aw1, aw2])
831827
except:
832828
assert 1 == 0
833829
captured = capsys.readouterr()
834830
assert captured.out == (
835-
"╭───────────────────────╮\n"
836-
"│ 🚀 Cluster Queue │\n"
837-
"│ Status 🚀 │\n"
838-
"│ +---------+---------+ │\n"
839-
"│ | Name | Status | │\n"
840-
"│ +=========+=========+ │\n"
841-
"│ | awtest1 | pending | │\n"
842-
"│ | | | │\n"
843-
"│ | awtest2 | running | │\n"
844-
"│ | | | │\n"
845-
"│ +---------+---------+ │\n"
846-
"╰───────────────────────╯\n"
831+
"╭─────────────────────────\n"
832+
"│ 🚀 Cluster Queue \n"
833+
"│ Status 🚀 \n"
834+
"│ +---------+-----------+ │\n"
835+
"│ | Name | Status | │\n"
836+
"│ +=========+===========+ │\n"
837+
"│ | awtest1 | suspended | │\n"
838+
"│ | | | │\n"
839+
"│ | awtest2 | running | │\n"
840+
"│ | | | │\n"
841+
"│ +---------+-----------+ │\n"
842+
"╰─────────────────────────\n"
847843
)
848844

849845

@@ -2088,7 +2084,7 @@ def get_aw_obj(group, version, namespace, plural):
20882084
"filterignore": True,
20892085
"queuejobstate": "Dispatched",
20902086
"sender": "before manageQueueJob - afterEtcdDispatching",
2091-
"state": "Pending",
2087+
"state": "Suspended",
20922088
"systempriority": 9,
20932089
},
20942090
},
@@ -2408,18 +2404,18 @@ def test_list_queue(mocker, capsys):
24082404
list_all_queued("ns", appwrapper=True)
24092405
captured = capsys.readouterr()
24102406
assert captured.out == (
2411-
"╭──────────────────────────╮\n"
2412-
"│ 🚀 Cluster Queue Status │\n"
2413-
"│ 🚀\n"
2414-
"│ +------------+---------+ │\n"
2415-
"│ | Name | Status | │\n"
2416-
"│ +============+=========+ │\n"
2417-
"│ | quicktest1 | running | │\n"
2418-
"│ | | | │\n"
2419-
"│ | quicktest2 | pending | │\n"
2420-
"│ | | | │\n"
2421-
"│ +------------+---------+ │\n"
2422-
"╰──────────────────────────╯\n"
2407+
"╭────────────────────────────\n"
2408+
"│ 🚀 Cluster Queue Status \n"
2409+
"│ 🚀 \n"
2410+
"│ +------------+-----------+ │\n"
2411+
"│ | Name | Status | │\n"
2412+
"│ +============+===========+ │\n"
2413+
"│ | quicktest1 | running | │\n"
2414+
"│ | | | │\n"
2415+
"│ | quicktest2 | suspended | │\n"
2416+
"│ | | | │\n"
2417+
"│ +------------+-----------+ │\n"
2418+
"╰────────────────────────────\n"
24232419
)
24242420

24252421

@@ -2469,9 +2465,7 @@ def test_list_queue_rayclusters(mocker, capsys):
24692465
def test_cluster_status(mocker):
24702466
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
24712467
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
2472-
fake_aw = AppWrapper(
2473-
"test", AppWrapperStatus.FAILED, can_run=True, job_state="unused"
2474-
)
2468+
fake_aw = AppWrapper("test", AppWrapperStatus.FAILED)
24752469
fake_ray = RayCluster(
24762470
name="test",
24772471
status=RayClusterStatus.UNKNOWN,
@@ -2508,29 +2502,24 @@ def test_cluster_status(mocker):
25082502
assert status == CodeFlareClusterStatus.FAILED
25092503
assert ready == False
25102504

2511-
fake_aw.status = AppWrapperStatus.DELETED
2512-
status, ready = cf.status()
2513-
assert status == CodeFlareClusterStatus.FAILED
2514-
assert ready == False
2515-
2516-
fake_aw.status = AppWrapperStatus.PENDING
2505+
fake_aw.status = AppWrapperStatus.SUSPENDED
25172506
status, ready = cf.status()
25182507
assert status == CodeFlareClusterStatus.QUEUED
25192508
assert ready == False
25202509

2521-
fake_aw.status = AppWrapperStatus.COMPLETED
2510+
fake_aw.status = AppWrapperStatus.RESUMING
25222511
status, ready = cf.status()
25232512
assert status == CodeFlareClusterStatus.STARTING
25242513
assert ready == False
25252514

2526-
fake_aw.status = AppWrapperStatus.RUNNING_HOLD_COMPLETION
2515+
fake_aw.status = AppWrapperStatus.RESETTING
25272516
status, ready = cf.status()
25282517
assert status == CodeFlareClusterStatus.STARTING
25292518
assert ready == False
25302519

25312520
fake_aw.status = AppWrapperStatus.RUNNING
25322521
status, ready = cf.status()
2533-
assert status == CodeFlareClusterStatus.STARTING
2522+
assert status == CodeFlareClusterStatus.UNKNOWN
25342523
assert ready == False
25352524

25362525
mocker.patch(

0 commit comments

Comments
 (0)