diff --git a/aws_pcluster_slurm_spawner/aws_pcluster_slurm_spawner.py b/aws_pcluster_slurm_spawner/aws_pcluster_slurm_spawner.py index ddf6694..20691eb 100644 --- a/aws_pcluster_slurm_spawner/aws_pcluster_slurm_spawner.py +++ b/aws_pcluster_slurm_spawner/aws_pcluster_slurm_spawner.py @@ -283,18 +283,19 @@ def profiles_list(self) -> List[Any]: }, ] gpu_found = False - for group_record in self.sinfo.dataframe.to_dict("records"): + df = self.sinfo.dataframe.sort_values(by=["mem", "cpu", "queue"]) + for group_record in df.to_dict("records"): # for group_record in self.sinfo.dataframe.to_dict('records'): sinfo_name = group_record["sinfo_name"] instance_type = group_record["ec2_instance_type"] - mem = group_record["mem"] - cpu = group_record["vcpu"] + mem = str(group_record["mem"]) + cpu = str(group_record["vcpu"]) if len(group_record["gpus"]): profiles[1]["profile_options"]["instance_types"]["choices"][ sinfo_name ] = dict( - display_name=f"{instance_type} - {cpu} CPU, {mem} GB", + display_name=f"{instance_type:10s} | {cpu:5s} CPU, {mem:6s} GB", pclusterslurmspawner_override=group_record, ) else: @@ -302,7 +303,7 @@ def profiles_list(self) -> List[Any]: profiles[0]["profile_options"]["instance_types"]["choices"][ sinfo_name ] = dict( - display_name=f"{instance_type} - {cpu} CPU, {mem} GB", + display_name=f"{instance_type:10s} | {cpu:5s} CPU | {mem:6s} GB", pclusterslurmspawner_override=group_record, ) if not gpu_found: