Skip to content

Commit 343e4e0

Browse files
committed
wip - cluster config consolidation
1 parent 9357373 commit 343e4e0

20 files changed

+1815
-97
lines changed

demo-notebooks/additional-demos/hf_interactive.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"outputs": [],
4141
"source": [
4242
"# Import pieces from codeflare-sdk\n",
43-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication"
43+
"from codeflare_sdk import RayCluster, TokenAuthentication"
4444
]
4545
},
4646
{
@@ -86,21 +86,20 @@
8686
"# Create our cluster and submit\n",
8787
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
8888
"cluster_name= \"hfgputest\"\n",
89-
"cluster = Cluster(ClusterConfiguration(\n",
89+
"cluster = RayCluster(\n",
9090
" name=cluster_name, \n",
9191
" head_memory_requests=6,\n",
9292
" head_memory_limits=8,\n",
93-
" head_extended_resource_requests={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
94-
" worker_extended_resource_requests={'nvidia.com/gpu':1},\n",
93+
" head_accelerators={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
94+
" worker_accelerators={'nvidia.com/gpu':1},\n",
9595
" num_workers=1,\n",
9696
" worker_cpu_requests=8, \n",
9797
" worker_cpu_limits=8, \n",
9898
" worker_memory_requests=16, \n",
9999
" worker_memory_limits=16, \n",
100100
" # image=\"\", # Optional Field \n",
101-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
102101
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
103-
"))"
102+
")"
104103
]
105104
},
106105
{
@@ -204,8 +203,8 @@
204203
"source": [
205204
"from codeflare_sdk import generate_cert\n",
206205
"# Create required TLS cert and export the environment variables to enable TLS\n",
207-
"generate_cert.generate_tls_cert(cluster_name, cluster.config.namespace)\n",
208-
"generate_cert.export_env(cluster_name, cluster.config.namespace)"
206+
"generate_cert.generate_tls_cert(cluster_name, cluster.namespace)\n",
207+
"generate_cert.export_env(cluster_name, cluster.namespace)"
209208
]
210209
},
211210
{

demo-notebooks/additional-demos/local_interactive.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"outputs": [],
1111
"source": [
1212
"# Import pieces from codeflare-sdk\n",
13-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication"
13+
"from codeflare_sdk import RayCluster, TokenAuthentication"
1414
]
1515
},
1616
{
@@ -56,21 +56,20 @@
5656
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
5757
"cluster_name = \"hfgputest-1\"\n",
5858
"\n",
59-
"cluster = Cluster(ClusterConfiguration(\n",
59+
"cluster = RayCluster(\n",
6060
" name=cluster_name,\n",
6161
" head_memory_requests=6,\n",
6262
" head_memory_limits=8,\n",
63-
" head_extended_resource_requests={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
64-
" worker_extended_resource_requests={'nvidia.com/gpu':0},\n",
63+
" head_accelerators={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
64+
" worker_accelerators={'nvidia.com/gpu':0},\n",
6565
" num_workers=1,\n",
6666
" worker_cpu_requests=1,\n",
6767
" worker_cpu_limits=1,\n",
6868
" worker_memory_requests=4,\n",
6969
" worker_memory_limits=6,\n",
7070
" # image=\"\", # Optional Field \n",
71-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
7271
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
73-
"))"
72+
")"
7473
]
7574
},
7675
{
@@ -114,8 +113,8 @@
114113
"source": [
115114
"from codeflare_sdk import generate_cert\n",
116115
"\n",
117-
"generate_cert.generate_tls_cert(cluster_name, cluster.config.namespace)\n",
118-
"generate_cert.export_env(cluster_name, cluster.config.namespace)"
116+
"generate_cert.generate_tls_cert(cluster_name, cluster.namespace)\n",
117+
"generate_cert.export_env(cluster_name, cluster.namespace)"
119118
]
120119
},
121120
{

demo-notebooks/additional-demos/ray_job_client.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"# Import pieces from codeflare-sdk\n",
17-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, RayJobClient"
17+
"from codeflare_sdk import RayCluster, TokenAuthentication, RayJobClient"
1818
]
1919
},
2020
{
@@ -57,12 +57,12 @@
5757
"source": [
5858
"# Create and configure our cluster object\n",
5959
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
60-
"cluster = Cluster(ClusterConfiguration(\n",
60+
"cluster = RayCluster(\n",
6161
" name='jobtest',\n",
6262
" head_memory_requests=6,\n",
6363
" head_memory_limits=8,\n",
64-
" head_extended_resource_requests={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
65-
" worker_extended_resource_requests={'nvidia.com/gpu':0},\n",
64+
" head_accelerators={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
65+
" worker_accelerators={'nvidia.com/gpu':0},\n",
6666
" num_workers=2,\n",
6767
" worker_cpu_requests=1,\n",
6868
" worker_cpu_limits=1,\n",
@@ -71,7 +71,7 @@
7171
" # image=\"\", # Optional Field \n",
7272
" write_to_file=False # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
7373
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
74-
"))"
74+
")"
7575
]
7676
},
7777
{

demo-notebooks/guided-demos/1_cluster_job_client.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"# Import pieces from codeflare-sdk\n",
17-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication"
17+
"from codeflare_sdk import RayCluster, TokenAuthentication"
1818
]
1919
},
2020
{
@@ -57,23 +57,22 @@
5757
"source": [
5858
"# Create and configure our cluster object\n",
5959
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
60-
"cluster = Cluster(ClusterConfiguration(\n",
60+
"cluster = RayCluster(\n",
6161
" name='jobtest',\n",
6262
" head_cpu_requests=1,\n",
6363
" head_cpu_limits=1,\n",
6464
" head_memory_requests=6,\n",
6565
" head_memory_limits=8,\n",
66-
" head_extended_resource_requests={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
67-
" worker_extended_resource_requests={'nvidia.com/gpu':1},\n",
66+
" head_accelerators={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
67+
" worker_accelerators={'nvidia.com/gpu':1},\n",
6868
" num_workers=2,\n",
6969
" worker_cpu_requests='250m',\n",
7070
" worker_cpu_limits=1,\n",
7171
" worker_memory_requests=4,\n",
7272
" worker_memory_limits=6,\n",
7373
" # image=\"\", # Optional Field \n",
74-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
7574
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
76-
"))"
75+
")"
7776
]
7877
},
7978
{
@@ -229,7 +228,7 @@
229228
],
230229
"metadata": {
231230
"kernelspec": {
232-
"display_name": "Python 3",
231+
"display_name": "base",
233232
"language": "python",
234233
"name": "python3"
235234
},
@@ -243,7 +242,7 @@
243242
"name": "python",
244243
"nbconvert_exporter": "python",
245244
"pygments_lexer": "ipython3",
246-
"version": "3.9.18"
245+
"version": "3.12.7"
247246
}
248247
},
249248
"nbformat": 4,

demo-notebooks/guided-demos/2_basic_interactive.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"outputs": [],
1717
"source": [
1818
"# Import pieces from codeflare-sdk\n",
19-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication"
19+
"from codeflare_sdk import RayCluster, TokenAuthentication"
2020
]
2121
},
2222
{
@@ -62,23 +62,22 @@
6262
"# Create and configure our cluster object\n",
6363
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
6464
"cluster_name = \"interactivetest\"\n",
65-
"cluster = Cluster(ClusterConfiguration(\n",
65+
"cluster = RayCluster(\n",
6666
" name=cluster_name,\n",
6767
" head_cpu_requests=1,\n",
6868
" head_cpu_limits=1,\n",
6969
" head_memory_requests=6,\n",
7070
" head_memory_limits=8,\n",
71-
" head_extended_resource_requests={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
72-
" worker_extended_resource_requests={'nvidia.com/gpu':1},\n",
71+
" head_accelerators={'nvidia.com/gpu':1}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
72+
" worker_accelerators={'nvidia.com/gpu':1},\n",
7373
" num_workers=2,\n",
7474
" worker_cpu_requests='250m',\n",
7575
" worker_cpu_limits=1,\n",
7676
" worker_memory_requests=4,\n",
7777
" worker_memory_limits=6,\n",
7878
" # image=\"\", # Optional Field \n",
79-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
8079
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
81-
"))"
80+
")"
8281
]
8382
},
8483
{
@@ -151,8 +150,8 @@
151150
"source": [
152151
"from codeflare_sdk import generate_cert\n",
153152
"# Create required TLS cert and export the environment variables to enable TLS\n",
154-
"generate_cert.generate_tls_cert(cluster_name, cluster.config.namespace)\n",
155-
"generate_cert.export_env(cluster_name, cluster.config.namespace)"
153+
"generate_cert.generate_tls_cert(cluster_name, cluster.namespace)\n",
154+
"generate_cert.export_env(cluster_name, cluster.namespace)"
156155
]
157156
},
158157
{

demo-notebooks/guided-demos/3_widget_example.ipynb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"outputs": [],
2020
"source": [
2121
"# Import pieces from codeflare-sdk\n",
22-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, view_clusters"
22+
"from codeflare_sdk import RayCluster, TokenAuthentication, view_clusters"
2323
]
2424
},
2525
{
@@ -64,23 +64,22 @@
6464
"source": [
6565
"# Create and configure our cluster object\n",
6666
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
67-
"cluster = Cluster(ClusterConfiguration(\n",
67+
"cluster = RayCluster(\n",
6868
" name='widgettest',\n",
6969
" head_cpu_requests='500m',\n",
7070
" head_cpu_limits='500m',\n",
7171
" head_memory_requests=6,\n",
7272
" head_memory_limits=8,\n",
73-
" head_extended_resource_requests={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_extended_resource_requests and worker_extended_resource_requests\n",
74-
" worker_extended_resource_requests={'nvidia.com/gpu':0},\n",
73+
" head_accelerators={'nvidia.com/gpu':0}, # For GPU enabled workloads set the head_accelerators and worker_accelerators\n",
74+
" worker_accelerators={'nvidia.com/gpu':0},\n",
7575
" num_workers=2,\n",
7676
" worker_cpu_requests='250m',\n",
7777
" worker_cpu_limits=1,\n",
7878
" worker_memory_requests=4,\n",
7979
" worker_memory_limits=6,\n",
8080
" # image=\"\", # Optional Field\n",
81-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources\n",
8281
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
83-
"))"
82+
")"
8483
]
8584
},
8685
{

demo-notebooks/guided-demos/4_rayjob_existing_cluster.ipynb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
40-
"from codeflare_sdk import Cluster, ClusterConfiguration, RayJob"
40+
"from codeflare_sdk import RayCluster, RayJob"
4141
]
4242
},
4343
{
@@ -73,21 +73,20 @@
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
76-
"cluster = Cluster(ClusterConfiguration(\n",
76+
"cluster = RayCluster(\n",
7777
" name='rayjob-cluster',\n",
7878
" head_cpu_requests=1,\n",
7979
" head_cpu_limits=1,\n",
8080
" head_memory_requests=6,\n",
8181
" head_memory_limits=8,\n",
82-
" head_extended_resource_requests={'nvidia.com/gpu':1},\n",
83-
" worker_extended_resource_requests={'nvidia.com/gpu':1},\n",
82+
" head_accelerators={'nvidia.com/gpu':1},\n",
83+
" worker_accelerators={'nvidia.com/gpu':1},\n",
8484
" num_workers=2,\n",
8585
" worker_cpu_requests='250m',\n",
8686
" worker_cpu_limits=1,\n",
8787
" worker_memory_requests=4,\n",
8888
" worker_memory_limits=6,\n",
89-
"\n",
90-
"))\n",
89+
")\n",
9190
"\n",
9291
"cluster.apply()"
9392
]

demo-notebooks/guided-demos/5_submit_rayjob_cr.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [
32-
"from codeflare_sdk import RayJob, ManagedClusterConfig"
32+
"from codeflare_sdk import RayJob, RayCluster"
3333
]
3434
},
3535
{
@@ -55,7 +55,7 @@
5555
"id": "5581eca9",
5656
"metadata": {},
5757
"source": [
58-
"Next we'll need to define the ManagedClusterConfig. Kuberay will use this to spin up a short-lived RayCluster that will only exist as long as the job"
58+
"Next we'll need to define the RayCluster configuration. Kuberay will use this to spin up a short-lived RayCluster that will only exist as long as the job"
5959
]
6060
},
6161
{
@@ -65,7 +65,7 @@
6565
"metadata": {},
6666
"outputs": [],
6767
"source": [
68-
"cluster_config = ManagedClusterConfig(\n",
68+
"cluster_config = RayCluster(\n",
6969
" head_memory_requests=6,\n",
7070
" head_memory_limits=8,\n",
7171
" num_workers=2,\n",
@@ -83,7 +83,7 @@
8383
"id": "02a2b32b",
8484
"metadata": {},
8585
"source": [
86-
"Lastly we can pass the ManagedClusterConfig into the RayJob and submit it. You do not need to worry about tearing down the cluster when the job has completed, that is handled for you!"
86+
"Lastly we can pass the RayCluster configuration into the RayJob and submit it. You do not need to worry about tearing down the cluster when the job has completed, that is handled for you!"
8787
]
8888
},
8989
{

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ kubernetes = ">= 27.2.0"
4141
cryptography = "43.0.3"
4242
executing = "1.2.0"
4343
pydantic = ">= 2.10.6"
44+
typing_extensions = ">= 4.12.0"
4445
ipywidgets = "8.1.2"
4546

4647
[[tool.poetry.source]]

src/codeflare_sdk/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
from .ray import (
2-
Cluster,
3-
ClusterConfiguration,
2+
Cluster, # Deprecated, use RayCluster instead
3+
ClusterConfiguration, # Deprecated, use RayCluster instead
4+
RayCluster, # New unified class (recommended) - combines config + operations
5+
RayClusterInfo, # Status info dataclass
46
RayClusterStatus,
57
CodeFlareClusterStatus,
6-
RayCluster,
78
get_cluster,
89
list_all_queued,
910
list_all_clusters,
1011
AWManager,
1112
AppWrapperStatus,
1213
RayJobClient,
1314
RayJob,
14-
ManagedClusterConfig,
15+
ManagedClusterConfig, # Deprecated, use RayCluster instead
1516
)
1617

1718
from .common.widgets import view_clusters

0 commit comments

Comments
 (0)