Skip to content

Commit

Permalink
CLI - Integrate system info for node (#199)
Browse files Browse the repository at this point in the history
Integrate system info for node, add `sb node info` command.
  • Loading branch information
abuccts committed Sep 16, 2021
1 parent ff48738 commit f91f97b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions superbench/cli/_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def load_command_table(self, args):
g.command('deploy', 'deploy_command_handler')
g.command('exec', 'exec_command_handler')
g.command('run', 'run_command_handler')
with CommandGroup(self, 'node', 'superbench.cli._node_handler#{}') as g:
g.command('info', 'info_command_handler')
return super().load_command_table(args)

def load_arguments(self, command):
Expand Down
19 changes: 19 additions & 0 deletions superbench/cli/_node_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

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

from superbench.tools import SystemInfo


def info_command_handler():
"""Get node hardware info.
Returns:
dict: node info.
"""
try:
info = SystemInfo().get_all()
except Exception as ex:
raise RuntimeError('Failed to get node info.') from ex
return info
4 changes: 4 additions & 0 deletions tests/cli/test_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ def test_sb_run_nonexist_host_file(self):
"""Test sb run, --host-file does not exist, should fail."""
result = self.cmd('sb run --host-file ./nonexist.yaml', expect_failure=True)
self.assertEqual(result.exit_code, 1)

def test_sb_node_info(self):
"""Test sb node info, should fail."""
self.cmd('sb node info', expect_failure=True)

0 comments on commit f91f97b

Please sign in to comment.