def _restructure_output()

in src/hyperpod_cli/commands/cluster.py [0:0]


def _restructure_output(summary_list, namespaces):
    if not namespaces:
        return

    for node_summary in summary_list:
        node_summary["Namespaces"] = {}
        for ns in namespaces:
            available_accelerators = node_summary[ns + AVAILABLE_ACCELERATOR_DEVICES_KEY]
            total_accelerators = node_summary[ns + TOTAL_ACCELERATOR_DEVICES_KEY]
            quota_accelerator_info = {
                AVAILABLE_ACCELERATOR_DEVICES_KEY: available_accelerators,
                TOTAL_ACCELERATOR_DEVICES_KEY: total_accelerators,
            }
            node_summary["Namespaces"][ns] = quota_accelerator_info
            node_summary.pop(ns + AVAILABLE_ACCELERATOR_DEVICES_KEY, None)
            node_summary.pop(ns + TOTAL_ACCELERATOR_DEVICES_KEY, None)