@@ -124,6 +124,17 @@ def _get_cloud(cloud: str) -> Optional[clouds.Cloud]:
124
124
return clouds .CLOUD_REGISTRY .get (cloud )
125
125
126
126
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
+
127
138
def _interactive_node_cli_command (cli_func ):
128
139
"""Click command decorator for interactive node commands."""
129
140
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):
893
904
code = job_lib .JobLibCodeGen .show_jobs (username , all_jobs )
894
905
895
906
if clusters :
907
+ clusters = _get_glob_clusters (clusters )
896
908
handles = [
897
909
global_user_state .get_handle_from_cluster_name (c ) for c in clusters
898
910
]
@@ -1216,11 +1228,7 @@ def _filter(name, all_clusters):
1216
1228
return None
1217
1229
1218
1230
# 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 )
1224
1232
1225
1233
all_clusters = global_user_state .get_clusters ()
1226
1234
for name in clusters :
@@ -1381,13 +1389,7 @@ def _terminate_or_stop_clusters(
1381
1389
1382
1390
to_down = []
1383
1391
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 )
1391
1393
for name in names :
1392
1394
handle = global_user_state .get_handle_from_cluster_name (name )
1393
1395
to_down .append ({'name' : name , 'handle' : handle })
0 commit comments