_node_handler.py 786 Bytes
Newer Older
1
2
3
4
5
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""SuperBench CLI node subgroup command handler."""

6
7
8
from pathlib import Path
import json

9
from superbench.tools import SystemInfo
10
from superbench.common.utils import create_sb_output_dir
11
12


13
def info_command_handler(output_dir=None):
14
15
    """Get node hardware info.

16
17
18
    Args:
        output_dir (str): Output directory.

19
20
21
22
23
    Returns:
        dict: node info.
    """
    try:
        info = SystemInfo().get_all()
24
25
26
27
        output_dir = create_sb_output_dir(output_dir)
        output_dir_path = Path(output_dir)
        with open(output_dir_path / 'sys_info.json', 'w') as f:
            json.dump(info, f)
28
29
30
    except Exception as ex:
        raise RuntimeError('Failed to get node info.') from ex
    return info