2525import time
2626from typing import Dict
2727from enum import Enum
28- import inspect
2928from amdsmi_helpers import AMDSMIHelpers
30- import amdsmi_cli_exceptions
3129
3230class AMDSMILogger ():
3331 def __init__ (self , format = 'human_readable' , destination = 'stdout' , helpers = None ) -> None :
@@ -92,10 +90,10 @@ def clear_multiple_devices_output(self):
9290 self .multiple_device_output .clear ()
9391
9492
95- def cper_exit_message (self ):
96- """ Store the cper exit message
93+ def get_cper_exit_message (self ):
94+ """ Get the cper exit message
9795 params:
98- message (str) - message to store
96+ None
9997 return:
10098 cper_exit_message (bool) - True if cper exit message is set
10199 """
@@ -239,9 +237,10 @@ def _convert_json_to_tabular(self, json_object: Dict[str, any], dynamic=False):
239237 string_process_value = str (process_value )
240238 if process_key == "name" :
241239 # Truncate name if too long
242- process_name = string_process_value .split ('/' )[- 1 ][:17 ]
243- if process_name == "" :
240+ if string_process_value == "" or string_process_value == "N/A" :
244241 process_name = "N/A"
242+ else :
243+ process_name = string_process_value .split ('/' )[- 1 ][:17 ]
245244 table_values += process_name .rjust (17 )
246245 elif process_key == "pid" :
247246 table_values += string_process_value .rjust (9 )
@@ -459,7 +458,7 @@ def _store_core_output_amdsmi(self, core_id, argument, data):
459458 else :
460459 self .output [argument ] = data
461460 else :
462- raise amdsmi_cli_exceptions ( self , "Invalid output format given, only json, csv, and human_readable supported " )
461+ raise ValueError ( "Invalid output format: expected json, csv, or human_readable" )
463462
464463
465464 def _store_cpu_output_amdsmi (self , cpu_id , argument , data ):
@@ -481,7 +480,7 @@ def _store_cpu_output_amdsmi(self, cpu_id, argument, data):
481480 else :
482481 self .output [argument ] = data
483482 else :
484- raise amdsmi_cli_exceptions ( self , "Invalid output format given, only json, csv, and human_readable supported " )
483+ raise ValueError ( "Invalid output format: expected json, csv, or human_readable" )
485484
486485
487486 def _store_output_amdsmi (self , gpu_id , argument , data ):
@@ -503,7 +502,7 @@ def _store_output_amdsmi(self, gpu_id, argument, data):
503502 else :
504503 self .output [argument ] = data
505504 else :
506- raise amdsmi_cli_exceptions ( self , "Invalid output format given, only json, csv, and human_readable supported " )
505+ raise ValueError ( "Invalid output format: expected json, csv, or human_readable" )
507506
508507
509508 def store_multiple_device_output (self ):
@@ -1024,11 +1023,24 @@ def print_default_output(self, output: Dict):
10241023 amdgpu_version = "N/A" .ljust (8 )
10251024 else :
10261025 amdgpu_version = str (driver_version ['driver_version' ])[:8 ].ljust (8 )
1026+ fw_pldm_version = str (output ['version_info' ]['fw pldm version' ])
1027+ vbios_version = str (output ['version_info' ]['vbios version' ])
10271028
10281029 # print GPU info
10291030 print (default_line_1 )
10301031 print ("| AMD-SMI {0:20s} amdgpu version: {1:8s} ROCm version: {2:8s} |" .format (amd_smi_version .ljust (20 ), amdgpu_version , rocm_version ))
1031- print ("| Platform: {0:20.20s} {1:46s}|" .format (str (self .helpers .os_info ()), "" ))
1032+
1033+ # adjust format depending on whether vbios or fw pldm version is present
1034+ if vbios_version != "N/A" and fw_pldm_version != "N/A" :
1035+ print ("| VBIOS version: {0:22s} {1:12s} FW PLDM: {2:15s}|" .format (vbios_version , "" , fw_pldm_version ))
1036+ elif vbios_version != "N/A" and fw_pldm_version == "N/A" :
1037+ print ("| VBIOS version: {0:22s} {1:37s} |" .format (vbios_version , "" ))
1038+ elif fw_pldm_version != "N/A" and vbios_version == "N/A" :
1039+ print ("| FW PLDM: {0:15s} {1:50s} |" .format (fw_pldm_version , "" ))
1040+ else :
1041+ pass # Both VBIOS and FW PLDM versions are "N/A" so skip this line
1042+
1043+ print ("| Platform: {0:25.25s} {1:41s}|" .format (str (self .helpers .os_info ()), "" ))
10321044 print (default_line_2 )
10331045 print ("| BDF GPU-Name | Mem-Uti Temp UEC Power-Usage |" )
10341046 print ("| GPU HIP-ID OAM-ID Partition-Mode | GFX-Uti Fan Mem-Usage |" )
0 commit comments