Skip to content

Commit 2b3e658

Browse files
committed
Vast: ordering the ports
1 parent 4c9aff9 commit 2b3e658

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

sky/provision/vast/utils.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,18 @@ def get_ssh_ports(cluster_name) -> List[int]:
9393

9494
for instance in instances.values():
9595
if instance['name'] in possible_names:
96-
ssh_ports.append(instance['ssh_port'])
96+
ssh_ports.append((instance['name'], instance['ssh_port']))
9797
assert ssh_ports, (
9898
f'Could not find any instances for cluster {cluster_name}.')
9999

100+
# So now we have
101+
# [(name, port) ... ]
102+
#
103+
# We want to put head first and otherwise sort numerically
104+
# and then extract the ports.
105+
ssh_ports = list(
106+
x[1]
107+
for x in sorted(ssh_ports,
108+
key=lambda x: -1
109+
if x[0].endswith('head') else int(x[0].split('-')[-1])))
100110
return ssh_ports

0 commit comments

Comments
 (0)