1313import os
1414
1515from verda import VerdaClient
16- from verda .constants import Locations
16+ from verda .constants import Actions , Locations
1717
1818# Get credentials from environment variables
1919CLIENT_ID = os .environ .get ('VERDA_CLIENT_ID' )
@@ -30,20 +30,21 @@ def create_cluster_example():
3030
3131 # Create a cluster with 3 nodes
3232 cluster = verda .clusters .create (
33- name = 'my-compute-cluster' ,
34- instance_type = '8V100.48V' ,
35- node_count = 3 ,
36- image = 'ubuntu-24.04-cuda-12.8-open-docker' ,
33+ hostname = 'my-compute-cluster' ,
34+ cluster_type = '16H200' ,
35+ image = 'ubuntu-22.04-cuda-12.4-cluster' ,
3736 description = 'Example compute cluster for distributed training' ,
3837 ssh_key_ids = ssh_keys ,
3938 location = Locations .FIN_03 ,
39+ shared_volume_name = 'my-shared-volume' ,
40+ shared_volume_size = 30000 ,
4041 )
4142
4243 print (f'Created cluster: { cluster .id } ' )
43- print (f'Cluster name : { cluster .name } ' )
44+ print (f'Cluster hostname : { cluster .hostname } ' )
4445 print (f'Cluster status: { cluster .status } ' )
45- print (f'Number of nodes : { cluster .node_count } ' )
46- print (f'Instance type : { cluster .instance_type } ' )
46+ print (f'Cluster cluster_type : { cluster .cluster_type } ' )
47+ print (f'Cluster worker_nodes : { cluster .worker_nodes } ' )
4748 print (f'Location: { cluster .location } ' )
4849
4950 return cluster
@@ -56,7 +57,9 @@ def list_clusters_example():
5657
5758 print (f'\n Found { len (clusters )} cluster(s):' )
5859 for cluster in clusters :
59- print (f' - { cluster .name } ({ cluster .id } ): { cluster .status } - { cluster .node_count } nodes' )
60+ print (
61+ f' - { cluster .hostname } ({ cluster .id } ): { cluster .status } - { len (cluster .worker_nodes )} nodes'
62+ )
6063
6164 # Get clusters with specific status
6265 running_clusters = verda .clusters .get (status = verda .constants .cluster_status .RUNNING )
@@ -71,45 +74,13 @@ def get_cluster_by_id_example(cluster_id: str):
7174
7275 print ('\n Cluster details:' )
7376 print (f' ID: { cluster .id } ' )
74- print (f' Name: { cluster .name } ' )
77+ print (f' Name: { cluster .hostname } ' )
7578 print (f' Description: { cluster .description } ' )
7679 print (f' Status: { cluster .status } ' )
77- print (f' Instance type: { cluster .instance_type } ' )
78- print (f' Node count: { cluster .node_count } ' )
80+ print (f' Cluster type: { cluster .cluster_type } ' )
7981 print (f' Created at: { cluster .created_at } ' )
80- if cluster .master_ip :
81- print (f' Master IP: { cluster .master_ip } ' )
82- if cluster .endpoint :
83- print (f' Endpoint: { cluster .endpoint } ' )
84-
85- return cluster
86-
87-
88- def get_cluster_nodes_example (cluster_id : str ):
89- """Get all nodes in a cluster."""
90- nodes = verda .clusters .get_nodes (cluster_id )
91-
92- print (f'\n Cluster has { len (nodes )} node(s):' )
93- for i , node in enumerate (nodes , 1 ):
94- print (f'\n Node { i } :' )
95- print (f' ID: { node .id } ' )
96- print (f' Hostname: { node .hostname } ' )
97- print (f' Status: { node .status } ' )
98- print (f' IP: { node .ip } ' )
99- print (f' Instance type: { node .instance_type } ' )
100-
101- return nodes
102-
103-
104- def scale_cluster_example (cluster_id : str , new_node_count : int ):
105- """Scale a cluster to a new number of nodes."""
106- print (f'\n Scaling cluster { cluster_id } to { new_node_count } nodes...' )
107-
108- cluster = verda .clusters .scale (cluster_id , new_node_count )
109-
110- print ('Cluster scaled successfully' )
111- print (f'Current node count: { cluster .node_count } ' )
112- print (f'Cluster status: { cluster .status } ' )
82+ print (f' Public IP: { cluster .ip } ' )
83+ print (f' Worker nodes: { len (cluster .worker_nodes )} ' )
11384
11485 return cluster
11586
@@ -118,7 +89,7 @@ def delete_cluster_example(cluster_id: str):
11889 """Delete a cluster."""
11990 print (f'\n Deleting cluster { cluster_id } ...' )
12091
121- verda .clusters .delete (cluster_id )
92+ verda .clusters .action (cluster_id , Actions . DELETE )
12293
12394 print ('Cluster deleted successfully' )
12495
@@ -140,14 +111,6 @@ def main():
140111 print ('\n 3. Getting cluster details...' )
141112 get_cluster_by_id_example (cluster_id )
142113
143- # Get cluster nodes
144- print ('\n 4. Getting cluster nodes...' )
145- get_cluster_nodes_example (cluster_id )
146-
147- # Scale the cluster
148- print ('\n 5. Scaling the cluster...' )
149- scale_cluster_example (cluster_id , 5 )
150-
151114 # Delete the cluster
152115 print ('\n 6. Deleting the cluster...' )
153116 delete_cluster_example (cluster_id )
0 commit comments