Skip to content

Commit 252b494

Browse files
committed
port appwrapper status to v1beta2 names
1 parent 3928c34 commit 252b494

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:
@@ -897,18 +893,14 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
897893

898894

899895
def _map_to_app_wrapper(aw) -> AppWrapper:
900-
if "status" in aw and "canrun" in aw["status"]:
896+
if "status" in aw:
901897
return AppWrapper(
902898
name=aw["metadata"]["name"],
903899
status=AppWrapperStatus(aw["status"]["state"].lower()),
904-
can_run=aw["status"]["canrun"],
905-
job_state=aw["status"]["queuejobstate"],
906900
)
907901
return AppWrapper(
908902
name=aw["metadata"]["name"],
909-
status=AppWrapperStatus("queueing"),
910-
can_run=False,
911-
job_state="Still adding to queue",
903+
status=AppWrapperStatus("suspended"),
912904
)
913905

914906

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
@@ -790,34 +790,30 @@ def test_print_no_cluster(capsys):
790790
def test_print_appwrappers(capsys):
791791
aw1 = AppWrapper(
792792
name="awtest1",
793-
status=AppWrapperStatus.PENDING,
794-
can_run=False,
795-
job_state="queue-state",
793+
status=AppWrapperStatus.SUSPENDED,
796794
)
797795
aw2 = AppWrapper(
798796
name="awtest2",
799797
status=AppWrapperStatus.RUNNING,
800-
can_run=False,
801-
job_state="queue-state",
802798
)
803799
try:
804800
print_app_wrappers_status([aw1, aw2])
805801
except:
806802
assert 1 == 0
807803
captured = capsys.readouterr()
808804
assert captured.out == (
809-
"╭───────────────────────╮\n"
810-
"│ 🚀 Cluster Queue │\n"
811-
"│ Status 🚀 │\n"
812-
"│ +---------+---------+ │\n"
813-
"│ | Name | Status | │\n"
814-
"│ +=========+=========+ │\n"
815-
"│ | awtest1 | pending | │\n"
816-
"│ | | | │\n"
817-
"│ | awtest2 | running | │\n"
818-
"│ | | | │\n"
819-
"│ +---------+---------+ │\n"
820-
"╰───────────────────────╯\n"
805+
"╭─────────────────────────\n"
806+
"│ 🚀 Cluster Queue \n"
807+
"│ Status 🚀 \n"
808+
"│ +---------+-----------+ │\n"
809+
"│ | Name | Status | │\n"
810+
"│ +=========+===========+ │\n"
811+
"│ | awtest1 | suspended | │\n"
812+
"│ | | | │\n"
813+
"│ | awtest2 | running | │\n"
814+
"│ | | | │\n"
815+
"│ +---------+-----------+ │\n"
816+
"╰─────────────────────────\n"
821817
)
822818

823819

@@ -2062,7 +2058,7 @@ def get_aw_obj(group, version, namespace, plural):
20622058
"filterignore": True,
20632059
"queuejobstate": "Dispatched",
20642060
"sender": "before manageQueueJob - afterEtcdDispatching",
2065-
"state": "Pending",
2061+
"state": "Suspended",
20662062
"systempriority": 9,
20672063
},
20682064
},
@@ -2382,18 +2378,18 @@ def test_list_queue(mocker, capsys):
23822378
list_all_queued("ns", appwrapper=True)
23832379
captured = capsys.readouterr()
23842380
assert captured.out == (
2385-
"╭──────────────────────────╮\n"
2386-
"│ 🚀 Cluster Queue Status │\n"
2387-
"│ 🚀\n"
2388-
"│ +------------+---------+ │\n"
2389-
"│ | Name | Status | │\n"
2390-
"│ +============+=========+ │\n"
2391-
"│ | quicktest1 | running | │\n"
2392-
"│ | | | │\n"
2393-
"│ | quicktest2 | pending | │\n"
2394-
"│ | | | │\n"
2395-
"│ +------------+---------+ │\n"
2396-
"╰──────────────────────────╯\n"
2381+
"╭────────────────────────────\n"
2382+
"│ 🚀 Cluster Queue Status \n"
2383+
"│ 🚀 \n"
2384+
"│ +------------+-----------+ │\n"
2385+
"│ | Name | Status | │\n"
2386+
"│ +============+===========+ │\n"
2387+
"│ | quicktest1 | running | │\n"
2388+
"│ | | | │\n"
2389+
"│ | quicktest2 | suspended | │\n"
2390+
"│ | | | │\n"
2391+
"│ +------------+-----------+ │\n"
2392+
"╰────────────────────────────\n"
23972393
)
23982394

23992395

@@ -2443,9 +2439,7 @@ def test_list_queue_rayclusters(mocker, capsys):
24432439
def test_cluster_status(mocker):
24442440
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
24452441
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
2446-
fake_aw = AppWrapper(
2447-
"test", AppWrapperStatus.FAILED, can_run=True, job_state="unused"
2448-
)
2442+
fake_aw = AppWrapper("test", AppWrapperStatus.FAILED)
24492443
fake_ray = RayCluster(
24502444
name="test",
24512445
status=RayClusterStatus.UNKNOWN,
@@ -2482,29 +2476,24 @@ def test_cluster_status(mocker):
24822476
assert status == CodeFlareClusterStatus.FAILED
24832477
assert ready == False
24842478

2485-
fake_aw.status = AppWrapperStatus.DELETED
2486-
status, ready = cf.status()
2487-
assert status == CodeFlareClusterStatus.FAILED
2488-
assert ready == False
2489-
2490-
fake_aw.status = AppWrapperStatus.PENDING
2479+
fake_aw.status = AppWrapperStatus.SUSPENDED
24912480
status, ready = cf.status()
24922481
assert status == CodeFlareClusterStatus.QUEUED
24932482
assert ready == False
24942483

2495-
fake_aw.status = AppWrapperStatus.COMPLETED
2484+
fake_aw.status = AppWrapperStatus.RESUMING
24962485
status, ready = cf.status()
24972486
assert status == CodeFlareClusterStatus.STARTING
24982487
assert ready == False
24992488

2500-
fake_aw.status = AppWrapperStatus.RUNNING_HOLD_COMPLETION
2489+
fake_aw.status = AppWrapperStatus.RESETTING
25012490
status, ready = cf.status()
25022491
assert status == CodeFlareClusterStatus.STARTING
25032492
assert ready == False
25042493

25052494
fake_aw.status = AppWrapperStatus.RUNNING
25062495
status, ready = cf.status()
2507-
assert status == CodeFlareClusterStatus.STARTING
2496+
assert status == CodeFlareClusterStatus.UNKNOWN
25082497
assert ready == False
25092498

25102499
mocker.patch(

0 commit comments

Comments
 (0)