@@ -124,6 +124,17 @@ def _get_cloud(cloud: str) -> Optional[clouds.Cloud]:
124124 return clouds .CLOUD_REGISTRY .get (cloud )
125125
126126
127+ def _get_glob_clusters (clusters : List [str ]) -> List [str ]:
128+ """Returns a list of clusters that match the glob pattern."""
129+ glob_clusters = []
130+ for cluster in clusters :
131+ glob_cluster = global_user_state .get_glob_cluster_names (cluster )
132+ if len (glob_cluster ) == 0 :
133+ print (f'Cluster { cluster } not found.' )
134+ glob_clusters .extend (glob_cluster )
135+ return list (set (glob_clusters ))
136+
137+
127138def _interactive_node_cli_command (cli_func ):
128139 """Click command decorator for interactive node commands."""
129140 assert cli_func .__name__ in _INTERACTIVE_NODE_TYPES , cli_func .__name__
@@ -893,6 +904,7 @@ def queue(clusters: Tuple[str], skip_finished: bool, all_users: bool):
893904 code = job_lib .JobLibCodeGen .show_jobs (username , all_jobs )
894905
895906 if clusters :
907+ clusters = _get_glob_clusters (clusters )
896908 handles = [
897909 global_user_state .get_handle_from_cluster_name (c ) for c in clusters
898910 ]
@@ -1216,11 +1228,7 @@ def _filter(name, all_clusters):
12161228 return None
12171229
12181230 # Get GLOB cluster names
1219- glob_clusters = []
1220- for cluster in clusters :
1221- glob_cluster = global_user_state .get_glob_cluster_names (cluster )
1222- glob_clusters .extend (glob_cluster )
1223- clusters = list (set (glob_clusters ))
1231+ clusters = _get_glob_clusters (clusters )
12241232
12251233 all_clusters = global_user_state .get_clusters ()
12261234 for name in clusters :
@@ -1381,13 +1389,7 @@ def _terminate_or_stop_clusters(
13811389
13821390 to_down = []
13831391 if len (names ) > 0 :
1384- glob_names = []
1385- for name in names :
1386- glob_name = global_user_state .get_glob_cluster_names (name )
1387- if len (glob_name ) == 0 :
1388- print (f'Cluster { name } not found.' )
1389- glob_names .extend (glob_name )
1390- names = list (set (glob_names ))
1392+ names = _get_glob_clusters (names )
13911393 for name in names :
13921394 handle = global_user_state .get_handle_from_cluster_name (name )
13931395 to_down .append ({'name' : name , 'handle' : handle })
0 commit comments