From 74475885524eaf51cc768bb05a9a1551d78dc692 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Mon, 24 Apr 2023 22:05:09 -0500 Subject: [PATCH] touch up linting after shuffling --- src/amdgpu_stats/interface.py | 43 +++++++++++++++++++++++++++-------- src/amdgpu_stats/utils.py | 11 +++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/amdgpu_stats/interface.py b/src/amdgpu_stats/interface.py index b9f6823..13601cc 100644 --- a/src/amdgpu_stats/interface.py +++ b/src/amdgpu_stats/interface.py @@ -1,4 +1,19 @@ -from .utils import CARD, SRC_FILES, TEMP_FILES, format_frequency, read_stat +""" +interface.py + +This module provides the TUI aspect of 'amdgpu-stats' + +Classes: + - GPUStats: the object for the _Application_, instantiated at runtime + - GPUStatsWidget: the primary container for the three stat widgets: + - MiscDisplay + - ClockDisplay + - PowerDisplay + - LogScreen: Second screen with the logging widget, header, and footer + +Functions: + - tui: Renders the TUI using the classes above +""" import sys from textual.binding import Binding @@ -8,6 +23,8 @@ from textual.reactive import reactive from textual.screen import Screen from textual.widgets import Header, Footer, Static, TextLog, Label +from .utils import CARD, SRC_FILES, TEMP_FILES, format_frequency, read_stat + class LogScreen(Screen): """Creates a screen for the logging widget""" @@ -209,10 +226,14 @@ class ClockDisplay(Static): """Called when the clocks attribute changes - Updates label values - Casting inputs to string to avoid type problems w/ int/None""" - self.query_one("#clk_core_val", Static).update(f"{core_vals['sclk']}") - self.query_one("#util_pct", Static).update(f"{core_vals['util_pct']}%") - self.query_one("#clk_voltage_val", Static).update(f"{core_vals['voltage']}V") - self.query_one("#clk_memory_val", Static).update(f"{core_vals['mclk']}") + self.query_one("#clk_core_val", + Static).update(f"{core_vals['sclk']}") + self.query_one("#util_pct", + Static).update(f"{core_vals['util_pct']}%") + self.query_one("#clk_voltage_val", + Static).update(f"{core_vals['voltage']}V") + self.query_one("#clk_memory_val", + Static).update(f"{core_vals['mclk']}") class PowerDisplay(Static): @@ -261,10 +282,14 @@ class PowerDisplay(Static): """Called when the micro_watts attributes change. - Updates label values - Casting inputs to string to avoid type problems w/ int/None""" - self.query_one("#pwr_avg_val", Static).update(f"{micro_watts['average']}W") - self.query_one("#pwr_lim_val", Static).update(f"{micro_watts['limit']}W") - self.query_one("#pwr_def_val", Static).update(f"{micro_watts['default']}W") - self.query_one("#pwr_cap_val", Static).update(f"{micro_watts['capability']}W") + self.query_one("#pwr_avg_val", + Static).update(f"{micro_watts['average']}W") + self.query_one("#pwr_lim_val", + Static).update(f"{micro_watts['limit']}W") + self.query_one("#pwr_def_val", + Static).update(f"{micro_watts['default']}W") + self.query_one("#pwr_cap_val", + Static).update(f"{micro_watts['capability']}W") def tui() -> None: diff --git a/src/amdgpu_stats/utils.py b/src/amdgpu_stats/utils.py index f66efb8..788a5fc 100644 --- a/src/amdgpu_stats/utils.py +++ b/src/amdgpu_stats/utils.py @@ -1,3 +1,14 @@ +""" +utils.py + +This module contains utility functions/variables used throughout 'amdgpu-stats' + +Variables: + - CARD: the identifier for the discovered AMD GPU, ie: `card0` / `card1` + - hwmon_dir: the `hwmon` interface (dir) that provides stats for this card + - SRC_FILES: dictionary of the known stats from the items in `hwmon_dir` + - TEMP_FILES: dictionary of the *discovered* temperature nodes / stat files +""" from os import path import glob from typing import Tuple, Optional