Skip to content

Commit eeb7290

Browse files
authored
Merge pull request #161 from Ricks-Lab/release_prep_24may24
Release prep 24may24
2 parents 5511d2a + 86a921d commit eeb7290

1 file changed

Lines changed: 37 additions & 25 deletions

File tree

GPUmodules/GPUmodule.py

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __delattr__(self, name) -> None:
7373

7474

7575
class GpuItem:
76-
"""An object to store GPU details.
76+
""" An object to store GPU details.
7777
"""
7878
# pylint: disable=attribute-defined-outside-init
7979
# pylint: disable=too-many-instance-attributes
@@ -408,8 +408,7 @@ class GpuItem:
408408
pp_od_clk_voltage_headers = ['OD_SCLK', 'OD_MCLK', 'OD_VDDC_CURVE', 'OD_RANGE', 'OD_VDDGFX_OFFSET']
409409

410410
def __repr__(self) -> str:
411-
"""
412-
Return dictionary representing all parts of the GpuItem object.
411+
""" Return dictionary representing all parts of the GpuItem object.
413412
414413
:return: Dictionary of core GPU parameters.
415414
"""
@@ -419,16 +418,14 @@ def __repr__(self) -> str:
419418
'ppm_modes': self.ppm_modes})
420419

421420
def __str__(self) -> str:
422-
"""
423-
Return simple string representing the GpuItem object.
421+
""" Return simple string representing the GpuItem object.
424422
425423
:return: GPU_item informational string
426424
"""
427425
return 'GPU_Item: uuid={}'.format(self.prm.uuid)
428426

429427
def __init__(self, item_id: str):
430-
"""
431-
Initialize GpuItem object.
428+
""" Initialize GpuItem object.
432429
433430
:param item_id: UUID of the new item.
434431
"""
@@ -536,9 +533,8 @@ def __init__(self, item_id: str):
536533

537534
@classmethod
538535
def finalize_fan_option(cls) -> None:
539-
"""
540-
Finalize class variables of gpu parameters based on command line options. This must be
541-
done after setting of env. Doing it at the instantiation of a GpuItem assures that.
536+
""" Finalize class variables of gpu parameters based on command line options. This must be
537+
done after setting of env. Doing it at the instantiation of a GpuItem assures that.
542538
"""
543539
if cls._finalized: return
544540
cls._finalized = True
@@ -565,8 +561,7 @@ def finalize_fan_option(cls) -> None:
565561

566562
@classmethod
567563
def is_apu(cls, name: str) -> bool:
568-
"""
569-
Check if given GPU name is an APU.
564+
""" Check if given GPU name is an APU.
570565
571566
:param name: Target GPU name
572567
:return: True if name matches APU name
@@ -579,8 +574,7 @@ def is_apu(cls, name: str) -> bool:
579574

580575
@classmethod
581576
def get_button_label(cls, name: str) -> str:
582-
"""
583-
Return button label for given parameter name.
577+
""" Return button label for given parameter name.
584578
585579
:param name: Parameter name
586580
:return: Button label
@@ -695,8 +689,7 @@ def fit_display_name(name: str, length: int = GUT_CONST.mon_field_width) -> str:
695689
return fit_name
696690

697691
def param_is_active(self, parameter_name: str) -> bool:
698-
"""
699-
Return True if given parameter is not skipped and not disabled.
692+
""" Return True if given parameter is not skipped and not disabled.
700693
701694
:param parameter_name:
702695
:return:
@@ -706,8 +699,7 @@ def param_is_active(self, parameter_name: str) -> bool:
706699
return True
707700

708701
def disable_param_read(self, parameter_name: Union[Tuple[str, ...], str, None]) -> None:
709-
"""
710-
Disable further reading of the specified parameter.
702+
""" Disable further reading of the specified parameter.
711703
712704
:param parameter_name: A single parameter name to be disabled.
713705
:return:
@@ -924,8 +916,7 @@ def is_valid_power_cap(self, power_cap: int) -> bool:
924916
return False
925917

926918
def is_valid_fan_pwm(self, pwm_value: int) -> bool:
927-
"""
928-
Check if a given fan_pwm value is valid.
919+
""" Check if a given fan_pwm value is valid.
929920
930921
:param pwm_value: Target fan_pwm value to be tested.
931922
:return: True if valid
@@ -1096,8 +1087,7 @@ def get_current_ppm_mode(self) -> Union[None, List[Union[int, str]]]:
10961087
return [int(ppm_item[0]), ppm_item[1]]
10971088

10981089
def read_raw_sensors(self) -> None:
1099-
"""
1100-
Read all possible device driver files and populate self's raw dictionary.
1090+
""" Read all possible device driver files and populate self's raw dictionary.
11011091
"""
11021092
for (sensor_type, path) in {'DEVICE': self.prm.card_path, 'HWMON': self.prm.hwmon_path}.items():
11031093
if path and os.path.isdir(path):
@@ -1153,6 +1143,12 @@ def read_gpu_pp_features(self, return_data: bool = False) -> Optional[str]:
11531143
if not self.prm.pp_features:
11541144
if re.search(GUT_CONST.PATTERNS[PK.AMD_FEATURES], line_str):
11551145
self.prm.pp_features = re.sub(GUT_CONST.PATTERNS[PK.AMD_FEATURES], '', line_str)
1146+
except PermissionError as except_err:
1147+
LOGGER.debug('Error: Can not read ppfeatures driver file %s, error: [%s]', self.prm.pcie_id,
1148+
except_err)
1149+
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
1150+
self.disable_param_read(parameter_file)
1151+
return None
11561152
except OSError as except_err:
11571153
LOGGER.debug('Error: system support issue for %s, error: [%s]', self.prm.pcie_id, except_err)
11581154
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
@@ -1193,8 +1189,13 @@ def read_gpu_ppm_table(self, return_data: bool = False) -> Optional[str]:
11931189
LOGGER.debug('Valid ppm line: %s', linestr)
11941190
self.ppm_modes[line_items[0]] = line_items[1:]
11951191
self.ppm_modes['-1'] = ['AUTO', 'Auto']
1192+
except PermissionError as except_err:
1193+
LOGGER.debug('Error: Can not read pstate driver file %s, error: [%s]', self.prm.pcie_id, except_err)
1194+
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
1195+
self.disable_param_read(parameter_file)
1196+
return None
11961197
except OSError as except_err:
1197-
LOGGER.debug('Error: system support issue for %s, error: [%s]', self.prm.pcie_id, except_err)
1198+
LOGGER.debug('Error: System support issue for %s, error: [%s]', self.prm.pcie_id, except_err)
11981199
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
11991200
self.disable_param_read(parameter_file)
12001201
return None
@@ -1315,6 +1316,11 @@ def read_gpu_pstates(self) -> None:
13151316
else:
13161317
GUT_CONST.process_message('Error: Invalid CURVE entry: {}'.format(file_path))
13171318

1319+
except PermissionError as except_err:
1320+
LOGGER.debug('Error: Can not read pstate driver file %s, error: [%s]', self.prm.pcie_id, except_err)
1321+
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
1322+
self.disable_param_read(parameter_file)
1323+
return None
13181324
except OSError as except_err:
13191325
LOGGER.debug('Error: system support issue for %s error: [%s]', self.prm.pcie_id, except_err)
13201326
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
@@ -1450,8 +1456,14 @@ def read_gpu_sensor_generic(self, parameter: str, vendor: GpuVendor = GpuVendor.
14501456
values.append(sensor_label_file.readline().strip())
14511457
else:
14521458
values.append(os.path.basename(sensor_file))
1453-
except OSError as err:
1454-
LOGGER.debug('Exception [%s]: Can not read HW file: %s', err, file_path)
1459+
except PermissionError as except_err:
1460+
LOGGER.debug('Error: Can not read GPU [%s] driver file [%s], error: [%s]',
1461+
self.prm.pcie_id, target_sensor, except_err)
1462+
print('Error: System support issue for GPU [{}]'.format(self.prm.pcie_id))
1463+
self.disable_param_read(parameter)
1464+
return None
1465+
except OSError as except_err:
1466+
LOGGER.debug('Exception [%s]: Can not read HW file: %s', except_err, file_path)
14551467
self.disable_param_read(parameter)
14561468
return False
14571469
else:

0 commit comments

Comments
 (0)