mirror of
https://github.com/XuehaiPan/nvitop.git
synced 2026-05-15 06:06:12 -06:00
refactor(tui): rename nvitop.gui -> nvitop.tui
This commit is contained in:
parent
37b95d859e
commit
1d0a690521
30 changed files with 97 additions and 97 deletions
4
.flake8
4
.flake8
|
|
@ -23,9 +23,9 @@ per-file-ignores =
|
|||
__init__.py: F401
|
||||
nvitop/api/host.py: F401
|
||||
nvitop/api/libnvml.py: F401
|
||||
# SIM113: use enumarate
|
||||
# SIM113: use enumerate
|
||||
# false positive
|
||||
nvitop/gui/screens/main/process.py: SIM113
|
||||
nvitop/tui/screens/main/process.py: SIM113
|
||||
exclude =
|
||||
.git,
|
||||
.vscode,
|
||||
|
|
|
|||
|
|
@ -1461,7 +1461,7 @@ nvitop (GPL-3.0)
|
|||
├── select.py (Apache-2.0)
|
||||
├── __main__.py (GPL-3.0)
|
||||
├── cli.py (GPL-3.0)
|
||||
└── gui (GPL-3.0)
|
||||
└── tui (GPL-3.0)
|
||||
├── COPYING (GPL-3.0)
|
||||
└── * (GPL-3.0)
|
||||
```
|
||||
|
|
@ -1482,13 +1482,13 @@ from nvitop import Device, ResourceMetricCollector
|
|||
|
||||
The public APIs from `nvitop` are released under the **Apache License, Version 2.0 (Apache-2.0)**. The original license files can be found at [LICENSE](https://github.com/XuehaiPan/nvitop/blob/HEAD/LICENSE), [nvitop/api/LICENSE](https://github.com/XuehaiPan/nvitop/blob/HEAD/nvitop/api/LICENSE), and [nvitop/callbacks/LICENSE](https://github.com/XuehaiPan/nvitop/blob/HEAD/nvitop/callbacks/LICENSE).
|
||||
|
||||
The CLI of `nvitop` is released under the **GNU General Public License, Version 3 (GPL-3.0)**. The original license files can be found at [COPYING](https://github.com/XuehaiPan/nvitop/blob/HEAD/COPYING) and [nvitop/gui/COPYING](https://github.com/XuehaiPan/nvitop/blob/HEAD/nvitop/gui/COPYING). If you dynamically load the source code of `nvitop`'s CLI or GUI:
|
||||
The CLI of `nvitop` is released under the **GNU General Public License, Version 3 (GPL-3.0)**. The original license files can be found at [COPYING](https://github.com/XuehaiPan/nvitop/blob/HEAD/COPYING) and [nvitop/tui/COPYING](https://github.com/XuehaiPan/nvitop/blob/HEAD/nvitop/tui/COPYING). If you dynamically load the source code of `nvitop`'s CLI or TUI:
|
||||
|
||||
```python
|
||||
from nvitop import cli
|
||||
from nvitop import gui
|
||||
from nvitop import tui
|
||||
import nvitop.cli
|
||||
import nvitop.gui
|
||||
import nvitop.tui
|
||||
```
|
||||
|
||||
your source code should also be released under the GPL-3.0 License.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import sys
|
|||
import textwrap
|
||||
|
||||
from nvitop.api import HostProcess, libnvml
|
||||
from nvitop.gui import UI, USERNAME, Device, colored, libcurses, set_color, setlocale_utf8
|
||||
from nvitop.tui import TUI, USERNAME, Device, colored, libcurses, set_color, setlocale_utf8
|
||||
from nvitop.version import __version__
|
||||
|
||||
|
||||
|
|
@ -345,11 +345,11 @@ def main() -> int:
|
|||
pids = set(args.pid)
|
||||
filters.append(lambda process: process.pid in pids)
|
||||
|
||||
ui = None
|
||||
tui = None
|
||||
if hasattr(args, 'monitor') and len(devices) > 0:
|
||||
try:
|
||||
with libcurses(colorful=args.colorful, light_theme=args.light) as win:
|
||||
ui = UI(
|
||||
tui = TUI(
|
||||
devices,
|
||||
filters,
|
||||
ascii=args.ascii,
|
||||
|
|
@ -357,14 +357,14 @@ def main() -> int:
|
|||
interval=args.interval,
|
||||
win=win,
|
||||
)
|
||||
ui.loop()
|
||||
tui.loop()
|
||||
except curses.error as ex:
|
||||
if ui is not None:
|
||||
if tui is not None:
|
||||
raise
|
||||
messages.append(f'ERROR: Failed to initialize `curses` ({ex})')
|
||||
|
||||
if ui is None:
|
||||
ui = UI(devices, filters, ascii=args.ascii)
|
||||
if tui is None:
|
||||
tui = TUI(devices, filters, ascii=args.ascii)
|
||||
if not sys.stdout.isatty():
|
||||
parent = HostProcess().parent()
|
||||
if parent is not None:
|
||||
|
|
@ -379,8 +379,8 @@ def main() -> int:
|
|||
'Please try `nvitop -m` directly.',
|
||||
)
|
||||
|
||||
ui.print()
|
||||
ui.destroy()
|
||||
tui.print()
|
||||
tui.destroy()
|
||||
|
||||
if len(libnvml.UNKNOWN_FUNCTIONS) > 0:
|
||||
unknown_function_messages = [
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
# This file is part of nvitop, the interactive NVIDIA-GPU process viewer.
|
||||
# License: GNU GPL version 3.
|
||||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from nvitop.gui.library.device import NA, Device
|
||||
from nvitop.gui.library.displayable import Displayable, DisplayableContainer
|
||||
from nvitop.gui.library.history import BufferedHistoryGraph, HistoryGraph
|
||||
from nvitop.gui.library.keybinding import (
|
||||
ALT_KEY,
|
||||
ANYKEY,
|
||||
PASSIVE_ACTION,
|
||||
QUANT_KEY,
|
||||
SPECIAL_KEYS,
|
||||
KeyBuffer,
|
||||
KeyMaps,
|
||||
normalize_keybinding,
|
||||
)
|
||||
from nvitop.gui.library.libcurses import libcurses, setlocale_utf8
|
||||
from nvitop.gui.library.messagebox import MessageBox, send_signal
|
||||
from nvitop.gui.library.mouse import MouseEvent
|
||||
from nvitop.gui.library.process import (
|
||||
GiB,
|
||||
GpuProcess,
|
||||
HostProcess,
|
||||
Snapshot,
|
||||
bytes2human,
|
||||
host,
|
||||
timedelta2human,
|
||||
)
|
||||
from nvitop.gui.library.selection import Selection
|
||||
from nvitop.gui.library.utils import (
|
||||
HOSTNAME,
|
||||
LARGE_INTEGER,
|
||||
SUPERUSER,
|
||||
USERCONTEXT,
|
||||
USERNAME,
|
||||
colored,
|
||||
cut_string,
|
||||
make_bar,
|
||||
set_color,
|
||||
ttl_cache,
|
||||
)
|
||||
from nvitop.gui.library.widestring import WideString, wcslen
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# This file is part of nvitop, the interactive NVIDIA-GPU process viewer.
|
||||
# License: GNU GPL version 3.
|
||||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from nvitop.gui.screens.environ import EnvironScreen
|
||||
from nvitop.gui.screens.help import HelpScreen
|
||||
from nvitop.gui.screens.main import BreakLoop, MainScreen
|
||||
from nvitop.gui.screens.metrics import ProcessMetricsScreen
|
||||
from nvitop.gui.screens.treeview import TreeViewScreen
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
SUPERUSER,
|
||||
USERNAME,
|
||||
Device,
|
||||
|
|
@ -12,4 +12,4 @@ from nvitop.gui.library import (
|
|||
set_color,
|
||||
setlocale_utf8,
|
||||
)
|
||||
from nvitop.gui.ui import UI
|
||||
from nvitop.tui.tui import TUI
|
||||
44
nvitop/tui/library/__init__.py
Normal file
44
nvitop/tui/library/__init__.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# This file is part of nvitop, the interactive NVIDIA-GPU process viewer.
|
||||
# License: GNU GPL version 3.
|
||||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from nvitop.tui.library.device import NA, Device
|
||||
from nvitop.tui.library.displayable import Displayable, DisplayableContainer
|
||||
from nvitop.tui.library.history import BufferedHistoryGraph, HistoryGraph
|
||||
from nvitop.tui.library.keybinding import (
|
||||
ALT_KEY,
|
||||
ANYKEY,
|
||||
PASSIVE_ACTION,
|
||||
QUANT_KEY,
|
||||
SPECIAL_KEYS,
|
||||
KeyBuffer,
|
||||
KeyMaps,
|
||||
normalize_keybinding,
|
||||
)
|
||||
from nvitop.tui.library.libcurses import libcurses, setlocale_utf8
|
||||
from nvitop.tui.library.messagebox import MessageBox, send_signal
|
||||
from nvitop.tui.library.mouse import MouseEvent
|
||||
from nvitop.tui.library.process import (
|
||||
GiB,
|
||||
GpuProcess,
|
||||
HostProcess,
|
||||
Snapshot,
|
||||
bytes2human,
|
||||
host,
|
||||
timedelta2human,
|
||||
)
|
||||
from nvitop.tui.library.selection import Selection
|
||||
from nvitop.tui.library.utils import (
|
||||
HOSTNAME,
|
||||
LARGE_INTEGER,
|
||||
SUPERUSER,
|
||||
USERCONTEXT,
|
||||
USERNAME,
|
||||
colored,
|
||||
cut_string,
|
||||
make_bar,
|
||||
set_color,
|
||||
ttl_cache,
|
||||
)
|
||||
from nvitop.tui.library.widestring import WideString, wcslen
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
from nvitop.api import NA, libnvml, ttl_cache, utilization2string
|
||||
from nvitop.api import MigDevice as MigDeviceBase
|
||||
from nvitop.api import PhysicalDevice as DeviceBase
|
||||
from nvitop.gui.library.process import GpuProcess
|
||||
from nvitop.tui.library.process import GpuProcess
|
||||
|
||||
|
||||
__all__ = ['Device', 'NA']
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# pylint: disable=missing-module-docstring,missing-function-docstring
|
||||
|
||||
from nvitop.gui.library.libcurses import CursesShortcuts
|
||||
from nvitop.tui.library.libcurses import CursesShortcuts
|
||||
|
||||
|
||||
class Displayable(CursesShortcuts): # pylint: disable=too-many-instance-attributes
|
||||
|
|
@ -10,7 +10,7 @@ import locale
|
|||
import os
|
||||
import signal
|
||||
|
||||
from nvitop.gui.library.history import GRAPH_SYMBOLS
|
||||
from nvitop.tui.library.history import GRAPH_SYMBOLS
|
||||
|
||||
|
||||
LIGHT_THEME = False
|
||||
|
|
@ -10,11 +10,11 @@ import threading
|
|||
import time
|
||||
from functools import partial
|
||||
|
||||
from nvitop.gui.library.displayable import Displayable
|
||||
from nvitop.gui.library.keybinding import normalize_keybinding
|
||||
from nvitop.gui.library.process import host
|
||||
from nvitop.gui.library.utils import cut_string
|
||||
from nvitop.gui.library.widestring import WideString
|
||||
from nvitop.tui.library.displayable import Displayable
|
||||
from nvitop.tui.library.keybinding import normalize_keybinding
|
||||
from nvitop.tui.library.process import host
|
||||
from nvitop.tui.library.utils import cut_string
|
||||
from nvitop.tui.library.widestring import WideString
|
||||
|
||||
|
||||
DIGITS = set(string.digits)
|
||||
|
|
@ -8,7 +8,7 @@ import time
|
|||
from weakref import WeakValueDictionary
|
||||
|
||||
from nvitop.api import NA, Snapshot, host
|
||||
from nvitop.gui.library.utils import LARGE_INTEGER, SUPERUSER, USERNAME
|
||||
from nvitop.tui.library.utils import LARGE_INTEGER, SUPERUSER, USERNAME
|
||||
|
||||
|
||||
class Selection: # pylint: disable=too-many-instance-attributes
|
||||
|
|
@ -8,7 +8,7 @@ import math
|
|||
import os
|
||||
|
||||
from nvitop.api import NA, colored, host, set_color, ttl_cache
|
||||
from nvitop.gui.library.widestring import WideString
|
||||
from nvitop.tui.library.widestring import WideString
|
||||
|
||||
|
||||
__all__ = [
|
||||
10
nvitop/tui/screens/__init__.py
Normal file
10
nvitop/tui/screens/__init__.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# This file is part of nvitop, the interactive NVIDIA-GPU process viewer.
|
||||
# License: GNU GPL version 3.
|
||||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from nvitop.tui.screens.environ import EnvironScreen
|
||||
from nvitop.tui.screens.help import HelpScreen
|
||||
from nvitop.tui.screens.main import BreakLoop, MainScreen
|
||||
from nvitop.tui.screens.metrics import ProcessMetricsScreen
|
||||
from nvitop.tui.screens.treeview import TreeViewScreen
|
||||
|
|
@ -7,7 +7,7 @@ from collections import OrderedDict
|
|||
from functools import partial
|
||||
from itertools import islice
|
||||
|
||||
from nvitop.gui.library import Displayable, GpuProcess, HostProcess, WideString, host
|
||||
from nvitop.tui.library import Displayable, GpuProcess, HostProcess, WideString, host
|
||||
|
||||
|
||||
class EnvironScreen(Displayable): # pylint: disable=too-many-instance-attributes
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring
|
||||
|
||||
from nvitop.gui.library import Device, Displayable, MouseEvent
|
||||
from nvitop.tui.library import Device, Displayable, MouseEvent
|
||||
from nvitop.version import __version__
|
||||
|
||||
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
import threading
|
||||
from functools import partial
|
||||
|
||||
from nvitop.gui.library import LARGE_INTEGER, DisplayableContainer, MouseEvent, send_signal
|
||||
from nvitop.gui.screens.main.device import DevicePanel
|
||||
from nvitop.gui.screens.main.host import HostPanel
|
||||
from nvitop.gui.screens.main.process import ProcessPanel
|
||||
from nvitop.tui.library import LARGE_INTEGER, DisplayableContainer, MouseEvent, send_signal
|
||||
from nvitop.tui.screens.main.device import DevicePanel
|
||||
from nvitop.tui.screens.main.host import HostPanel
|
||||
from nvitop.tui.screens.main.process import ProcessPanel
|
||||
|
||||
|
||||
class BreakLoop(Exception): # noqa: N818
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
import threading
|
||||
import time
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
NA,
|
||||
Device,
|
||||
Displayable,
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
import threading
|
||||
import time
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
NA,
|
||||
BufferedHistoryGraph,
|
||||
Device,
|
||||
|
|
@ -11,7 +11,7 @@ import time
|
|||
from operator import attrgetter, xor
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
HOSTNAME,
|
||||
LARGE_INTEGER,
|
||||
SUPERUSER,
|
||||
|
|
@ -9,7 +9,7 @@ import threading
|
|||
import time
|
||||
from collections import OrderedDict
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
HOSTNAME,
|
||||
NA,
|
||||
SUPERUSER,
|
||||
|
|
@ -9,7 +9,7 @@ from collections import deque
|
|||
from functools import partial
|
||||
from itertools import islice
|
||||
|
||||
from nvitop.gui.library import (
|
||||
from nvitop.tui.library import (
|
||||
NA,
|
||||
SUPERUSER,
|
||||
USERNAME,
|
||||
|
|
@ -7,8 +7,8 @@ import curses
|
|||
import shutil
|
||||
import time
|
||||
|
||||
from nvitop.gui.library import ALT_KEY, DisplayableContainer, KeyBuffer, KeyMaps, MouseEvent
|
||||
from nvitop.gui.screens import (
|
||||
from nvitop.tui.library import ALT_KEY, DisplayableContainer, KeyBuffer, KeyMaps, MouseEvent
|
||||
from nvitop.tui.screens import (
|
||||
BreakLoop,
|
||||
EnvironScreen,
|
||||
HelpScreen,
|
||||
|
|
@ -18,7 +18,7 @@ from nvitop.gui.screens import (
|
|||
)
|
||||
|
||||
|
||||
class UI(DisplayableContainer): # pylint: disable=too-many-instance-attributes
|
||||
class TUI(DisplayableContainer): # pylint: disable=too-many-instance-attributes
|
||||
# pylint: disable-next=too-many-arguments
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -97,7 +97,7 @@ warn_unused_configs = true
|
|||
warn_unused_ignores = true
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = ['nvitop.callbacks.*', 'nvitop.gui.*']
|
||||
module = ['nvitop.callbacks.*', 'nvitop.tui.*']
|
||||
ignore_errors = true
|
||||
|
||||
[tool.pylint]
|
||||
|
|
@ -190,7 +190,7 @@ ignore = [
|
|||
"D", # pydocstyle
|
||||
"ANN", # flake8-annotations
|
||||
]
|
||||
"nvitop/gui/**/*.py" = [
|
||||
"nvitop/tui/**/*.py" = [
|
||||
"D", # pydocstyle
|
||||
"ANN", # flake8-annotations
|
||||
"RUF012", # mutable-class-default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue