in azure-slurm/slurmcc/cli.py [0:0]
def _generate_topology(node_mgr: NodeManager, writer: TextIO) -> None:
partitions = partitionlib.fetch_partitions(node_mgr)
nodes_by_pg = {}
for partition in partitions:
for pg, node_list in partition.node_list_by_pg.items():
if pg not in nodes_by_pg:
nodes_by_pg[pg] = []
nodes_by_pg[pg].extend(node_list)
if not nodes_by_pg:
raise AzureSlurmError(
"No nodes found to create topology! Do you need to run create_nodes first?"
)
for pg in sorted(nodes_by_pg.keys(), key=lambda x: x if x is not None else ""):
nodes = nodes_by_pg[pg]
if not nodes:
continue
nodes = sorted(nodes, key=slutil.get_sort_key_func(bool(pg)))
slurm_node_expr = ",".join(nodes) # slutil.to_hostlist(",".join(nodes))
writer.write("SwitchName={} Nodes={}\n".format(pg or "htc", slurm_node_expr))