[PR #25] [MERGED] refactor(core/libnvml): use module-based approach rather than singleton #125

Closed
opened 2026-05-05 03:26:21 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/XuehaiPan/nvitop/pull/25
Author: @XuehaiPan
Created: 7/16/2022
Status: Merged
Merged: 7/17/2022
Merged by: @XuehaiPan

Base: mainHead: libnvml


📝 Commits (5)

  • 630324e refactor(core/libnvml): rename nvml to libnvml
  • b08fb42 chore(core/host): delete imported references
  • 327866a refactor(core/libnvml): use module-based approach rather than singleton
  • 20bf3fe docs(core/libnvml): add docs for NVML constants
  • 93e426a docs(core/version): update docstring for PYNVML_VERSION_CANDIDATES

📊 Changes

11 files changed (+470 additions, -355 deletions)

View changed files

📝 docs/source/apis/core/libnvml.rst (+0 -1)
📝 nvitop/callbacks/keras.py (+4 -4)
📝 nvitop/callbacks/pytorch_lightning.py (+4 -4)
📝 nvitop/cli.py (+6 -6)
📝 nvitop/core/__init__.py (+3 -3)
📝 nvitop/core/device.py (+90 -90)
📝 nvitop/core/host.py (+3 -0)
📝 nvitop/core/libnvml.py (+353 -240)
📝 nvitop/core/process.py (+2 -3)
📝 nvitop/gui/library/device.py (+3 -3)
📝 nvitop/version.py (+2 -1)

📄 Description

Issue Type

  • Refactor

Runtime Environment

  • Operating system and version: Ubuntu 20.04 LTS
  • Terminal emulator and version: GNOME Terminal 3.36.2
  • Python version: 3.9.13
  • NVML version (driver version): 470.129.06
  • nvitop version or commit: main@6bf151
  • python-ml-py version: 11.450.51
  • Locale: en_US.UTF-8

Description

Use a module-based approach rather than a singleton class. Previously, we use a singleton class libnvml and the singleton nvml to support the context manager (with statement). Now, the mechanism is replaced by a custom module type.

Motivation and Context

Simplify module hierarchy. Make the IDE happy and let sphinx generate more documents from autoapi.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/XuehaiPan/nvitop/pull/25 **Author:** [@XuehaiPan](https://github.com/XuehaiPan) **Created:** 7/16/2022 **Status:** ✅ Merged **Merged:** 7/17/2022 **Merged by:** [@XuehaiPan](https://github.com/XuehaiPan) **Base:** `main` ← **Head:** `libnvml` --- ### 📝 Commits (5) - [`630324e`](https://github.com/XuehaiPan/nvitop/commit/630324ece7dc5039208d5483145821612577e49c) refactor(core/libnvml): rename `nvml` to `libnvml` - [`b08fb42`](https://github.com/XuehaiPan/nvitop/commit/b08fb42f954c7520819c69faa3feefdfd455aa75) chore(core/host): delete imported references - [`327866a`](https://github.com/XuehaiPan/nvitop/commit/327866a50d37f5a4d1b1367dc4d66b531c380d1d) refactor(core/libnvml): use module-based approach rather than singleton - [`20bf3fe`](https://github.com/XuehaiPan/nvitop/commit/20bf3fe96e32e8067490a054a532cd5d4ead1072) docs(core/libnvml): add docs for NVML constants - [`93e426a`](https://github.com/XuehaiPan/nvitop/commit/93e426a8138798af584382e4c2a5888908f0a2b8) docs(core/version): update docstring for `PYNVML_VERSION_CANDIDATES` ### 📊 Changes **11 files changed** (+470 additions, -355 deletions) <details> <summary>View changed files</summary> 📝 `docs/source/apis/core/libnvml.rst` (+0 -1) 📝 `nvitop/callbacks/keras.py` (+4 -4) 📝 `nvitop/callbacks/pytorch_lightning.py` (+4 -4) 📝 `nvitop/cli.py` (+6 -6) 📝 `nvitop/core/__init__.py` (+3 -3) 📝 `nvitop/core/device.py` (+90 -90) 📝 `nvitop/core/host.py` (+3 -0) 📝 `nvitop/core/libnvml.py` (+353 -240) 📝 `nvitop/core/process.py` (+2 -3) 📝 `nvitop/gui/library/device.py` (+3 -3) 📝 `nvitop/version.py` (+2 -1) </details> ### 📄 Description #### Issue Type <!-- Pick relevant types and delete the rest --> - Refactor #### Runtime Environment <!-- Details of your runtime environment --> - Operating system and version: Ubuntu 20.04 LTS - Terminal emulator and version: GNOME Terminal 3.36.2 - Python version: `3.9.13` - NVML version (driver version): `470.129.06` - `nvitop` version or commit: `main@6bf151` - `python-ml-py` version: `11.450.51` - Locale: `en_US.UTF-8` #### Description <!-- Describe the changes in detail --> Use a module-based approach rather than a singleton class. Previously, we use a singleton class `libnvml` and the singleton `nvml` to support the context manager (`with` statement). Now, the mechanism is replaced by a custom module type. #### Motivation and Context <!-- Why are these changes required? --> <!-- What problems do these changes solve? --> <!-- Link to relevant issues --> Simplify module hierarchy. Make the IDE happy and let sphinx generate more documents from `autoapi`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 03:26:21 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/nvitop#125
No description provided.