Skip to content

Commit b9fd5fa

Browse files
committed
port appwrapper status to v1beta2 names
1 parent a31ed66 commit b9fd5fa

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
@@ -564,9 +562,7 @@ def list_all_queued(
564562
in a given namespace.
565563
"""
566564
if appwrapper:
567-
resources = _get_app_wrappers(
568-
namespace, filter=[AppWrapperStatus.RUNNING, AppWrapperStatus.PENDING]
569-
)
565+
resources = _get_app_wrappers(namespace, filter=[AppWrapperStatus.SUSPENDED])
570566
if print_to_console:
571567
pretty_print.print_app_wrappers_status(resources)
572568
else:
@@ -894,18 +890,14 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
894890

895891

896892
def _map_to_app_wrapper(aw) -> AppWrapper:
897-
if "status" in aw and "canrun" in aw["status"]:
893+
if "status" in aw:
898894
return AppWrapper(
899895
name=aw["metadata"]["name"],
900896
status=AppWrapperStatus(aw["status"]["state"].lower()),
901-
can_run=aw["status"]["canrun"],
902-
job_state=aw["status"]["queuejobstate"],
903897
)
904898
return AppWrapper(
905899
name=aw["metadata"]["name"],
906-
status=AppWrapperStatus("queueing"),
907-
can_run=False,
908-
job_state="Still adding to queue",
900+
status=AppWrapperStatus("suspended"),
909901
)
910902

911903

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

@@ -2061,7 +2057,7 @@ def get_aw_obj(group, version, namespace, plural):
20612057
"filterignore": True,
20622058
"queuejobstate": "Dispatched",
20632059
"sender": "before manageQueueJob - afterEtcdDispatching",
2064-
"state": "Pending",
2060+
"state": "Suspended",
20652061
"systempriority": 9,
20662062
},
20672063
},
@@ -2351,18 +2347,18 @@ def test_list_queue(mocker, capsys):
23512347
list_all_queued("ns", appwrapper=True)
23522348
captured = capsys.readouterr()
23532349
assert captured.out == (
2354-
"╭──────────────────────────╮\n"
2355-
"│ 🚀 Cluster Queue Status │\n"
2356-
"│ 🚀\n"
2357-
"│ +------------+---------+ │\n"
2358-
"│ | Name | Status | │\n"
2359-
"│ +============+=========+ │\n"
2360-
"│ | quicktest1 | running | │\n"
2361-
"│ | | | │\n"
2362-
"│ | quicktest2 | pending | │\n"
2363-
"│ | | | │\n"
2364-
"│ +------------+---------+ │\n"
2365-
"╰──────────────────────────╯\n"
2350+
"╭────────────────────────────\n"
2351+
"│ 🚀 Cluster Queue Status \n"
2352+
"│ 🚀 \n"
2353+
"│ +------------+-----------+ │\n"
2354+
"│ | Name | Status | │\n"
2355+
"│ +============+===========+ │\n"
2356+
"│ | quicktest1 | running | │\n"
2357+
"│ | | | │\n"
2358+
"│ | quicktest2 | suspended | │\n"
2359+
"│ | | | │\n"
2360+
"│ +------------+-----------+ │\n"
2361+
"╰────────────────────────────\n"
23662362
)
23672363

23682364

@@ -2412,9 +2408,7 @@ def test_list_queue_rayclusters(mocker, capsys):
24122408
def test_cluster_status(mocker):
24132409
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
24142410
mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
2415-
fake_aw = AppWrapper(
2416-
"test", AppWrapperStatus.FAILED, can_run=True, job_state="unused"
2417-
)
2411+
fake_aw = AppWrapper("test", AppWrapperStatus.FAILED)
24182412
fake_ray = RayCluster(
24192413
name="test",
24202414
status=RayClusterStatus.UNKNOWN,
@@ -2451,29 +2445,24 @@ def test_cluster_status(mocker):
24512445
assert status == CodeFlareClusterStatus.FAILED
24522446
assert ready == False
24532447

2454-
fake_aw.status = AppWrapperStatus.DELETED
2455-
status, ready = cf.status()
2456-
assert status == CodeFlareClusterStatus.FAILED
2457-
assert ready == False
2458-
2459-
fake_aw.status = AppWrapperStatus.PENDING
2448+
fake_aw.status = AppWrapperStatus.SUSPENDED
24602449
status, ready = cf.status()
24612450
assert status == CodeFlareClusterStatus.QUEUED
24622451
assert ready == False
24632452

2464-
fake_aw.status = AppWrapperStatus.COMPLETED
2453+
fake_aw.status = AppWrapperStatus.RESUMING
24652454
status, ready = cf.status()
24662455
assert status == CodeFlareClusterStatus.STARTING
24672456
assert ready == False
24682457

2469-
fake_aw.status = AppWrapperStatus.RUNNING_HOLD_COMPLETION
2458+
fake_aw.status = AppWrapperStatus.RESETTING
24702459
status, ready = cf.status()
24712460
assert status == CodeFlareClusterStatus.STARTING
24722461
assert ready == False
24732462

24742463
fake_aw.status = AppWrapperStatus.RUNNING
24752464
status, ready = cf.status()
2476-
assert status == CodeFlareClusterStatus.STARTING
2465+
assert status == CodeFlareClusterStatus.UNKNOWN
24772466
assert ready == False
24782467

24792468
mocker.patch(

0 commit comments

Comments
 (0)