diff --git a/LICENSE.md b/LICENSE.md index d541ff8..31657ea 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Josh Lay +Copyright (c) 2024 Josh Lay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0b5b56c..7d02ef1 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,39 @@ # amdgpu_stats -A Python module/TUI for AMD GPU statistics. -Tested _only_ on `RX6000` series cards and _(less so)_ with Ryzen CPU iGPUs. - -Please [file an issue](https://git.init3.us/BraveTraveler/amdgpu_stats/issues) -if finding incompatibility! +A Python module/TUI for AMD GPU statistics. Please [file an issue](https://github.com/joshlay/amdgpu_stats/issues) +with feature requests or bug reports! ## Screenshots
Main screen / stats - ![Screenshot of the main stats table](https://git.init3.us/BraveTraveler/amdgpu_stats/raw/branch/master/screens/main.svg "Main screen") + ![Screenshot of the main stats table](https://raw.githubusercontent.com/joshlay/amdgpu_stats/master/screens/main.svg "Main screen")
Usage graphs - ![Screenshot of the 'graphing' scroll bars](https://git.init3.us/BraveTraveler/amdgpu_stats/raw/branch/master/screens/graphs.svg "Graphs") + ![Screenshot of the 'graphing' scroll bars](https://raw.githubusercontent.com/joshlay/amdgpu_stats/master/screens/graphs.svg "Graphs")
Logs - ![Screenshot of the 'Logs' tab pane](https://git.init3.us/BraveTraveler/amdgpu_stats/raw/branch/master/screens/logs.svg "Logs") + ![Screenshot of the 'Logs' tab pane](https://raw.githubusercontent.com/joshlay/amdgpu_stats/master/screens/logs.svg "Logs")
## Installation + ```bash pip install amdgpu-stats ``` -To use the _TUI_, run `amdgpu-stats` in your terminal of choice. For the _module_, see below! + +To use the _TUI_, run `amdgpu-stats` in your terminal of choice. For the _module_, +see below! ## Module Introduction: + ```python In [1]: import amdgpu_stats.utils @@ -47,17 +48,11 @@ Out[4]: '659 MHz' ``` For more information on what the module provides, please see: - - [ReadTheDocs](https://amdgpu-stats.readthedocs.io/en/latest/) - - `help('amdgpu_stats.utils')` in your interpreter - - [The module source](https://git.init3.us/BraveTraveler/amdgpu_stats/src/branch/master/src/amdgpu_stats/utils.py) -Feature requests [are encouraged](https://git.init3.us/BraveTraveler/amdgpu_stats/issues) 😀 +- [ReadTheDocs](https://amdgpu-stats.readthedocs.io/en/latest/) +- `help('amdgpu_stats.utils')` in your interpreter +- [The module source](https://github.com/joshlay/amdgpu_stats/blob/master/src/amdgpu_stats/utils.py) ## Requirements -Only `Linux` is supported. Information is _completely_ sourced from interfaces in `sysfs`. - -It _may_ be necessary to update the `amdgpu.ppfeaturemask` parameter to enable metrics. - -This is assumed present for *control* over the elements being monitored. Untested without. -See [this Arch Wiki entry](https://wiki.archlinux.org/title/AMDGPU#Boot_parameter) for context. +Only `Linux` is supported. Information is _completely_ sourced from `sysfs`. diff --git a/docs/conf.py b/docs/conf.py index c94fee8..ca88343 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,9 +21,9 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = 'amdgpu_stats' -copyright = '2023, Josh Lay' +copyright = '2024, Josh Lay' author = 'Josh Lay' -release = '0.1.6' +release = '0.1.22' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index 4ffce48..7ddfa34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [tool.poetry] name = "amdgpu-stats" -version = "0.1.21" +version = "0.1.22" description = "A module/TUI for AMD GPU statistics" authors = ["Josh Lay "] -repository = "https://git.init3.us/BraveTraveler/amdgpu_stats" +repository = "https://github.com/joshlay/amdgpu_stats" license = "MIT" readme = "README.md" documentation = "https://amdgpu-stats.readthedocs.io/en/latest/" diff --git a/src/amdgpu_stats/tui.py b/src/amdgpu_stats/tui.py index 01f695e..2993761 100644 --- a/src/amdgpu_stats/tui.py +++ b/src/amdgpu_stats/tui.py @@ -174,10 +174,7 @@ def compose(self) -> ComposeResult: yield self.text_log def update_log(self, message: str, show_ts: bool = True) -> None: - """Update the Log widget with a new message. - - Highest Textual version-requiring widget; >=0.32.0 - Should be more performant than the old TextLog widget + """Update the Log widget/pane with a new message. Args: message (str): The message to be added to the logging widget on the 'Logs' tab. @@ -221,10 +218,12 @@ class app(App): # pylint: disable=invalid-name # apply stylesheet; this is watched/dynamically reloaded # can be edited (in installation dir) and seen live + # TODO: use xdg-config-dir, defaulting to the included style if not found CSS_PATH = 'style.css' # set the title - same as the class, but with spaces TITLE = 'AMD GPU Stats' + # set a default subtitle, will change with the active tab SUB_TITLE = f'cards: {list(AMDGPU_CARDS)}' @@ -250,14 +249,28 @@ def compose(self) -> ComposeResult: yield Container(self.stats_widget) yield Footer() + def update_log(self, message: str, show_ts: bool = True) -> None: + """Update the TextLog widget with a new message. + Highest Textual version-requiring widget; >=0.32.0 + Should be more performant than the old TextLog widget + + Args: + message (str): The message to be added to the logging widget on the 'Logs' tab. + show_ts (bool, optional): If True (default), appends a timestamp to the message. + """ + if show_ts: + message = f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {message}" + self.stats_widget.text_log.write_line(message) + @work(exclusive=True) async def action_custom_dark(self) -> None: """An action to toggle dark mode. Wraps 'action_toggle_dark' with our logging""" self.app.dark = not self.app.dark - # inline conditional due to how Textual doesn't pretty notifs. for us like TextLog - message = f"[bold]Dark side: [italic][{'green' if self.app.dark else 'red'}]{self.app.dark}" + # with new log widget... styling doesn't get rendered, disabling. makes notifications look nice + # message = f"[bold]Dark side: [italic][{'green' if self.app.dark else 'red'}]{self.app.dark}" + message = f"Dark side: {self.app.dark}" self.notify(message) self.update_log(message) @@ -284,14 +297,10 @@ async def action_custom_screenshot(self, screen_dir: str = '/tmp') -> None: # take the screenshot, recording the path for logging/notification outpath = self.save_screenshot(path=screen_dir, filename=screen_name) # construct the log/notification message, then show it - message = f"[bold]Path: [/]'[green]{outpath}[/]'" + message = f"Path: '{outpath}'" self.notify(message, title='Screenshot captured', timeout=3.0) self.update_log(message) - def update_log(self, message: str) -> None: - """Update the TextLog widget with a new message.""" - self.stats_widget.text_log.write(message) - def action_custom_tab(self) -> None: """Toggle between the 'Stats' and 'Logs' tabs""" # walk/cycle the tabs