Skip to content

Commit a916ae3

Browse files
add cluster up and cluster down functionality (#5)
1 parent 18b91f7 commit a916ae3

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ def __init__(self, config: ClusterConfiguration):
1010
self.config = config
1111

1212
# creates a new cluser with the provided or default spec
13-
def up(self):
14-
pass
15-
16-
def down(self, name):
17-
# FIXME on what the exact details should be
18-
# 1. delete the appwrapper and that should delete the cluster
19-
# FIXME on what the exact details should be
20-
# 1. delete the appwrapper and that should delete the cluster
21-
pass
22-
13+
def up(self, namespace='default'):
14+
with oc.project(namespace):
15+
oc.invoke("apply", ["-f",
16+
"https://raw.githubusercontent.com/IBM/multi-cluster-app-dispatcher/quota-management/doc/usage/examples/kuberay/config/aw-raycluster.yaml"])
17+
18+
def down(self, name, namespace='default'):
19+
with oc.project(namespace):
20+
oc.invoke("delete",["AppWrapper", self.config.name])
21+
2322
def status(self, print_to_console=True):
2423
cluster = _ray_cluster_status(self.config.name)
2524
if cluster:

tests/test_clusters.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
from codeflare_sdk.cluster.cluster import list_all_clusters, _app_wrapper_status
22
from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration
3+
import time
4+
5+
def test_cluster_up():
6+
cluster = Cluster(ClusterConfiguration(name='raycluster-autoscaler'))
7+
cluster.up()
8+
time.sleep(15)
39

4-
#for now these tests assume that the cluster was already created
510
def test_list_clusters():
611
clusters = list_all_clusters()
712

@@ -11,4 +16,8 @@ def test_cluster_status():
1116

1217
def test_app_wrapper_status():
1318
print(_app_wrapper_status('raycluster-autoscaler'))
14-
19+
20+
def test_cluster_down():
21+
cluster = Cluster(ClusterConfiguration(name='raycluster-autoscaler'))
22+
cluster.down(name='raycluster-autoscaler')
23+

0 commit comments

Comments
 (0)