From 00c14326393f6fe92c9c7643e370f54289a25246 Mon Sep 17 00:00:00 2001 From: Chris McKenzie Date: Fri, 22 Nov 2024 12:28:45 -0800 Subject: [PATCH] Vast: ordering the ports --- sky/provision/vast/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sky/provision/vast/utils.py b/sky/provision/vast/utils.py index 5c627b108037..b0b1423da0c6 100644 --- a/sky/provision/vast/utils.py +++ b/sky/provision/vast/utils.py @@ -93,8 +93,18 @@ def get_ssh_ports(cluster_name) -> List[int]: for instance in instances.values(): if instance['name'] in possible_names: - ssh_ports.append(instance['ssh_port']) + ssh_ports.append((instance['name'], instance['ssh_port'])) assert ssh_ports, ( f'Could not find any instances for cluster {cluster_name}.') + # So now we have + # [(name, port) ... ] + # + # We want to put head first and otherwise sort numerically + # and then extract the ports. + ssh_ports = list( + x[1] + for x in sorted(ssh_ports, + key=lambda x: -1 + if x[0].endswith('head') else int(x[0].split('-')[-1]))) return ssh_ports