Added Version Header to all Help Sections

Signed-off-by: gabrpham_amdeng <Gabriel.Pham@amd.com>
这个提交包含在:
gabrpham_amdeng 编写, Arif, Maisam 于 2025-08-21 17:17:16 -05:00 提交
1 父节点 4ac1c7e453
当前提交 5aae1a31fa
1 个文件已更改
+27 -23
+27 -23
查看文件
@@ -49,7 +49,8 @@ class AMDSMIParserHelpFormatter(argparse.HelpFormatter):
# Custom Help Formatter for not duplicating the metavar in the subparsers # Custom Help Formatter for not duplicating the metavar in the subparsers
class AMDSMISubparserHelpFormatter(argparse.RawTextHelpFormatter): class AMDSMISubparserHelpFormatter(argparse.RawTextHelpFormatter):
def __init__(self, prog): def __init__(self, prog):
super().__init__(prog, max_help_position=80, width=90) super().__init__(prog, indent_increment=2, max_help_position=24, width=90)
self._action_max_length = 20
def _format_action_invocation(self, action): def _format_action_invocation(self, action):
if not action.option_strings or action.nargs == 0: if not action.option_strings or action.nargs == 0:
@@ -96,19 +97,20 @@ class AMDSMIParser(argparse.ArgumentParser):
self.vf_choices = ['3', '2', '1'] self.vf_choices = ['3', '2', '1']
version_string = f"Version: {__version__}" self.version_string = f"Version: {__version__}"
platform_string = f"Platform: {self.helpers.os_info()}" self.platform_string = f"Platform: {self.helpers.os_info()}"
rocm_version = self.helpers.get_rocm_version() self.rocm_version = self.helpers.get_rocm_version()
rocm_version_string = f"ROCm version: {rocm_version}" self.rocm_version_string = f"ROCm version: {self.rocm_version}"
program_name = 'amd-smi' self.program_name = 'amd-smi'
self.description = f"AMD System Management Interface | {self.version_string} | {self.rocm_version_string} | {self.platform_string}"
# Adjust argument parser options # Adjust argument parser options
super().__init__( super().__init__(
formatter_class= lambda prog: AMDSMIParserHelpFormatter(prog), formatter_class= lambda prog: AMDSMIParserHelpFormatter(prog),
description=f"AMD System Management Interface | {version_string} | {rocm_version_string} | {platform_string}", description=self.description,
epilog="For detailed help on specific commands: amd-smi [command] -h", epilog="For detailed help on specific commands: amd-smi [command] -h",
add_help=True, add_help=True,
prog=program_name) prog=self.program_name)
# Setup subparsers # Setup subparsers
self.subparsers = self.add_subparsers( self.subparsers = self.add_subparsers(
@@ -710,9 +712,10 @@ class AMDSMIParser(argparse.ArgumentParser):
def _add_version_parser(self, subparsers: argparse._SubParsersAction, func): def _add_version_parser(self, subparsers: argparse._SubParsersAction, func):
# Subparser help text # Subparser help text
version_help = "Display version information" version_help = "Display version information"
description = self.description
# Create version subparser # Create version subparser
version_parser = subparsers.add_parser('version', help=version_help, description=None) version_parser = subparsers.add_parser('version', help=version_help, description=description)
version_parser._optionals.title = None version_parser._optionals.title = None
version_parser.formatter_class=lambda prog: AMDSMISubparserHelpFormatter(prog) version_parser.formatter_class=lambda prog: AMDSMISubparserHelpFormatter(prog)
version_parser.set_defaults(func=func) version_parser.set_defaults(func=func)
@@ -737,7 +740,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
list_help = "List GPU information" list_help = "List GPU information"
list_optionals_title = "List Arguments" list_optionals_title = "List Arguments"
list_subcommand_help = "Lists all detected devices on the system.\ list_subcommand_help = f"{self.description}\n\nLists all detected devices on the system.\
\nLists the BDF, UUID, KFD_ID, NODE_ID, and Partition ID for each GPU and/or CPUs.\ \nLists the BDF, UUID, KFD_ID, NODE_ID, and Partition ID for each GPU and/or CPUs.\
\nIn virtualization environments, it can also list VFs associated to each\ \nIn virtualization environments, it can also list VFs associated to each\
\nGPU with some basic information for each VF." \nGPU with some basic information for each VF."
@@ -761,7 +764,7 @@ class AMDSMIParser(argparse.ArgumentParser):
def _add_static_parser(self, subparsers: argparse._SubParsersAction, func): def _add_static_parser(self, subparsers: argparse._SubParsersAction, func):
# Subparser help text # Subparser help text
static_help = "Gets static information about the specified GPU" static_help = "Gets static information about the specified GPU"
static_subcommand_help = "If no GPU is specified, returns static information for all GPUs on the system.\ static_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns static information for all GPUs on the system.\
\nIf no static argument is provided, all static information will be displayed." \nIf no static argument is provided, all static information will be displayed."
static_optionals_title = "Static Arguments" static_optionals_title = "Static Arguments"
@@ -853,7 +856,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
firmware_help = "Gets firmware information about the specified GPU" firmware_help = "Gets firmware information about the specified GPU"
firmware_subcommand_help = "If no GPU is specified, return firmware information for all GPUs on the system." firmware_subcommand_help = f"{self.description}\n\nIf no GPU is specified, return firmware information for all GPUs on the system."
firmware_optionals_title = "Firmware Arguments" firmware_optionals_title = "Firmware Arguments"
# Optional arguments help text # Optional arguments help text
@@ -890,7 +893,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
bad_pages_help = "Gets bad page information about the specified GPU" bad_pages_help = "Gets bad page information about the specified GPU"
bad_pages_subcommand_help = "If no GPU is specified, return bad page information for all GPUs on the system." bad_pages_subcommand_help = f"{self.description}\n\nIf no GPU is specified, return bad page information for all GPUs on the system."
bad_pages_optionals_title = "Bad Pages Arguments" bad_pages_optionals_title = "Bad Pages Arguments"
# Optional arguments help text # Optional arguments help text
@@ -917,7 +920,7 @@ class AMDSMIParser(argparse.ArgumentParser):
def _add_metric_parser(self, subparsers: argparse._SubParsersAction, func): def _add_metric_parser(self, subparsers: argparse._SubParsersAction, func):
# Subparser help text # Subparser help text
metric_help = "Gets metric/performance information about the specified GPU" metric_help = "Gets metric/performance information about the specified GPU"
metric_subcommand_help = "If no GPU is specified, returns metric information for all GPUs on the system.\ metric_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns metric information for all GPUs on the system.\
\nIf no metric argument is provided, all metric information will be displayed." \nIf no metric argument is provided, all metric information will be displayed."
metric_optionals_title = "Metric arguments" metric_optionals_title = "Metric arguments"
@@ -1077,7 +1080,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
process_help = "Lists general process information running on the specified GPU" process_help = "Lists general process information running on the specified GPU"
process_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\ process_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns information for all GPUs on the system.\
\nIf no process argument is provided, all process information will be displayed." \nIf no process argument is provided, all process information will be displayed."
process_optionals_title = "Process arguments" process_optionals_title = "Process arguments"
@@ -1115,7 +1118,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
profile_help = "Displays information about all profiles and current profile" profile_help = "Displays information about all profiles and current profile"
profile_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system." profile_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns information for all GPUs on the system."
profile_optionals_title = "Profile Arguments" profile_optionals_title = "Profile Arguments"
# Create profile subparser # Create profile subparser
@@ -1136,7 +1139,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
event_help = "Displays event information for the given GPU" event_help = "Displays event information for the given GPU"
event_subcommand_help = "If no GPU is specified, returns event information for all GPUs on the system." event_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns event information for all GPUs on the system."
event_optionals_title = "Event Arguments" event_optionals_title = "Event Arguments"
# Create event subparser # Create event subparser
@@ -1157,7 +1160,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
topology_help = "Displays topology information of the devices" topology_help = "Displays topology information of the devices"
topology_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\ topology_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns information for all GPUs on the system.\
\nIf no topology argument is provided, all topology information will be displayed." \nIf no topology argument is provided, all topology information will be displayed."
topology_optionals_title = "Topology arguments" topology_optionals_title = "Topology arguments"
@@ -1201,7 +1204,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
set_value_help = "Set options for devices" set_value_help = "Set options for devices"
set_value_subcommand_help = "If no GPU is specified, will select all GPUs on the system.\ set_value_subcommand_help = f"{self.description}\n\nIf no GPU is specified, will select all GPUs on the system.\
\nA set argument must be provided; Multiple set arguments are accepted.\ \nA set argument must be provided; Multiple set arguments are accepted.\
\nRequires 'sudo' privileges." \nRequires 'sudo' privileges."
set_value_optionals_title = "Set Arguments" set_value_optionals_title = "Set Arguments"
@@ -1315,7 +1318,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
reset_help = "Reset options for devices" reset_help = "Reset options for devices"
reset_subcommand_help = "If no GPU is specified, will select all GPUs on the system.\ reset_subcommand_help = f"{self.description}\n\nIf no GPU is specified, will select all GPUs on the system.\
\nA reset argument must be provided; Multiple reset arguments are accepted.\ \nA reset argument must be provided; Multiple reset arguments are accepted.\
\nRequires 'sudo' privileges." \nRequires 'sudo' privileges."
reset_optionals_title = "Reset Arguments" reset_optionals_title = "Reset Arguments"
@@ -1371,7 +1374,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
monitor_help = "Monitor metrics for target devices" monitor_help = "Monitor metrics for target devices"
monitor_subcommand_help = "Monitor a target device for the specified arguments.\ monitor_subcommand_help = f"{self.description}\n\nMonitor a target device for the specified arguments.\
\nIf no arguments are provided, all arguments will be enabled.\ \nIf no arguments are provided, all arguments will be enabled.\
\nUse the watch arguments to run continuously." \nUse the watch arguments to run continuously."
monitor_optionals_title = "Monitor Arguments" monitor_optionals_title = "Monitor Arguments"
@@ -1422,7 +1425,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
xgmi_help = "Displays xgmi information of the devices" xgmi_help = "Displays xgmi information of the devices"
xgmi_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\ xgmi_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns information for all GPUs on the system.\
\nIf no xgmi argument is provided, all xgmi information will be displayed." \nIf no xgmi argument is provided, all xgmi information will be displayed."
xgmi_optionals_title = "XGMI arguments" xgmi_optionals_title = "XGMI arguments"
@@ -1452,7 +1455,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
partition_help = "Displays partition information of the devices" partition_help = "Displays partition information of the devices"
partition_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\ partition_subcommand_help = f"{self.description}\n\nIf no GPU is specified, returns information for all GPUs on the system.\
\nIf no partition argument is provided, all partition information will be displayed." \nIf no partition argument is provided, all partition information will be displayed."
partition_optionals_title = "Partition arguments" partition_optionals_title = "Partition arguments"
@@ -1489,6 +1492,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text # Subparser help text
ras_help = "Retrieve RAS (CPER) entries from the driver" ras_help = "Retrieve RAS (CPER) entries from the driver"
ras_description = ( ras_description = (
f"{self.description}\n\n"
"Retrieve and decode RAS (CPER) entries from the kernel driver.\n" "Retrieve and decode RAS (CPER) entries from the kernel driver.\n"
"Supports filtering by severity, exporting to different formats, and continuous monitoring.\n" "Supports filtering by severity, exporting to different formats, and continuous monitoring.\n"
"This command accepts options only; no positional arguments are required." "This command accepts options only; no positional arguments are required."