[SWDEV-537852] Update help and error text (#518)
Improved amd-smi help and error messages.
Updated to show subcommand name in help text.
---------
Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
[ROCm/amdsmi commit: 6f7b397998]
Цей коміт міститься в:
зафіксовано
GitHub
джерело
65a9397928
коміт
46deb667e3
@@ -104,7 +104,7 @@ class AmdSmiInvalidCommandException(AmdSmiException):
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Command '{self.command}' is invalid. Run '--help' for more info."
|
||||
common_message = f"Command '{self.command}' is invalid. Run 'amd-smi -h' for more info."
|
||||
|
||||
if message:
|
||||
common_message = message
|
||||
@@ -116,13 +116,14 @@ class AmdSmiInvalidCommandException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiInvalidParameterException(AmdSmiException):
|
||||
def __init__(self, command, outputformat: str):
|
||||
def __init__(self, command, arg, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -2
|
||||
self.command = command
|
||||
self.arg = arg
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Parameter '{self.command}' is invalid. Run '--help' for more info."
|
||||
common_message = f"Parameter '{self.arg}' is invalid. Run 'amd-smi {self.command} -h' for more info."
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
@@ -179,7 +180,7 @@ class AmdSmiInvalidParameterValueException(AmdSmiException):
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Value '{self.command}' is not of valid type or format. Run '--help' for more info."
|
||||
common_message = f"Value '{self.command}' is not of valid type or format. Run 'amd-smi -h' for more info."
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
@@ -239,7 +240,7 @@ class AmdSmiRequiredCommandException(AmdSmiException):
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Command '{self.command}' requires a target argument. Run '--help' for more info."
|
||||
common_message = f"Command '{self.command}' requires a target argument. Run 'amd-smi {self.command} -h' for more info."
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
@@ -254,7 +255,7 @@ class AmdSmiInvalidSubcommandException(AmdSmiException):
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"AMD-SMI Command '{self.command}' is invalid. Must receive valid AMD-SMI Command first. Run '--help' for more info."
|
||||
common_message = f"AMD-SMI Command '{self.command}' is invalid. Must receive valid AMD-SMI Command first. Run 'amd-smi -h' for more info."
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
|
||||
@@ -1045,7 +1045,7 @@ class AMDSMICommands():
|
||||
else:
|
||||
clk_type_conversion = "N/A"
|
||||
output_format = self.helpers.get_output_format()
|
||||
raise AmdSmiInvalidParameterException(clk_type, output_format) # clk type given is bad
|
||||
raise AmdSmiInvalidParameterException('static', clk_type, output_format) # clk type given is bad
|
||||
|
||||
try:
|
||||
frequencies = amdsmi_interface.amdsmi_get_clk_freq(args.gpu, clk_type_conversion)
|
||||
|
||||
@@ -106,6 +106,7 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
super().__init__(
|
||||
formatter_class= lambda prog: AMDSMIParserHelpFormatter(prog),
|
||||
description=f"AMD System Management Interface | {version_string} | {rocm_version_string} | {platform_string}",
|
||||
epilog="For detailed help on specific commands: amd-smi [command] -h",
|
||||
add_help=True,
|
||||
prog=program_name)
|
||||
|
||||
@@ -238,9 +239,9 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
|
||||
# Check if the sclk and mclk parameters are valid
|
||||
if clk_type not in valid_clk_types:
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(clk_type, output_format)
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(sys.argv[1], clk_type, output_format)
|
||||
if lim_type not in valid_lim_types:
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(lim_type, output_format)
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(sys.argv[1], lim_type, output_format)
|
||||
|
||||
# Check if the val is a valid integer value
|
||||
if not val.isdigit():
|
||||
@@ -267,7 +268,7 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
|
||||
# Check if the sclk and mclk parameters are valid
|
||||
if clk_type not in valid_clk_types:
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(clk_type, output_format)
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(sys.argv[1], clk_type, output_format)
|
||||
|
||||
perf_levels = []
|
||||
# Check if every item in perf level is valid
|
||||
@@ -1536,6 +1537,6 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
elif "unrecognized arguments: " in message:
|
||||
l = len("unrecognized arguments: ")
|
||||
message = message[l:]
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(message, outputformat)
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(sys.argv[1], message, outputformat)
|
||||
else:
|
||||
print(message)
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача