style: update pylint magic comments

Signed-off-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
This commit is contained in:
Xuehai Pan 2022-07-24 21:55:33 +08:00
parent 587e2042eb
commit 7cb90e5de7
10 changed files with 27 additions and 22 deletions

View file

@ -481,7 +481,7 @@ class ResourceMetricCollector: # pylint: disable=too-many-instance-attributes
def __del__(self) -> None:
self._daemon_running.clear()
# pylint: disable=missing-function-docstring,too-many-branches,too-many-locals,too-many-statements
# pylint: disable-next=missing-function-docstring,too-many-branches,too-many-locals,too-many-statements
def take_snapshots(self) -> SnapshotResult:
if len(self.root_pids) > 0:
all_gpu_processes = []

View file

@ -378,10 +378,9 @@ class Device: # pylint: disable=too-many-instance-attributes,too-many-public-me
return Device._parse_cuda_visible_devices(cuda_visible_devices)
# pylint: disable=too-many-branches
@staticmethod
@ttl_cache(ttl=300.0)
def _parse_cuda_visible_devices(
def _parse_cuda_visible_devices( # pylint: disable=too-many-branches
cuda_visible_devices: Optional[str] = None,
) -> Union[List['PhysicalDevice'], List['MigDevice']]:
"""The underlining implementation for :meth:`parse_cuda_visible_devices`. The result will be cached."""
@ -1831,7 +1830,7 @@ class MigDevice(Device): # pylint: disable=too-many-instance-attributes
return list(map(cls, indices))
# pylint: disable=super-init-not-called
# pylint: disable-next=super-init-not-called
def __init__(
self, index: Optional[Union[Tuple[int, int], str]] = None, *, uuid: Optional[str] = None
) -> None:

View file

@ -15,7 +15,7 @@ from typing import Tuple as _Tuple
from typing import Type as _Type
# pylint: disable=missing-class-docstring,too-few-public-methods
# pylint: disable-next=missing-class-docstring,too-few-public-methods
class struct_c_CUdevice_t(_ctypes.Structure):
pass # opaque handle
@ -194,6 +194,7 @@ CUDA_ERROR_EXTERNAL_DEVICE = 911
"""This indicates that an async error has occurred in a device outside of CUDA. If CUDA was waiting for an external device's signal before consuming shared data, the external device signaled an error indicating that the data is not valid for consumption. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched."""
CUDA_ERROR_UNKNOWN = 999
"""This indicates that an unknown internal error has occurred."""
# pylint: enable=line-too-long
## Error Checking ##
@ -218,7 +219,7 @@ class CUDAError(Exception):
"""Maps value to a proper subclass of :class:`CUDAError`."""
if cls is CUDAError:
# pylint: disable=self-cls-assignment
# pylint: disable-next=self-cls-assignment
cls = CUDAError._value_class_mapping.get(value, cls)
obj = Exception.__new__(cls)
obj.value = value

View file

@ -139,12 +139,17 @@ del (
)
# 5. Add explicit references to appease linters
# pylint: disable=no-member
c_nvmlDevice_t = _pynvml.c_nvmlDevice_t
NVMLError_LibraryNotFound = _pynvml.NVMLError_LibraryNotFound # pylint: disable=no-member
NVMLError_FunctionNotFound = _pynvml.NVMLError_FunctionNotFound # pylint: disable=no-member
NVMLError_NotSupported = _pynvml.NVMLError_NotSupported # pylint: disable=no-member
NVMLError_NotFound = _pynvml.NVMLError_NotFound # pylint: disable=no-member
NVMLError_GpuIsLost = _pynvml.NVMLError_GpuIsLost # pylint: disable=no-member
NVMLError_FunctionNotFound = _pynvml.NVMLError_FunctionNotFound
NVMLError_GpuIsLost = _pynvml.NVMLError_GpuIsLost
NVMLError_InvalidArgument = _pynvml.NVMLError_InvalidArgument
NVMLError_LibraryNotFound = _pynvml.NVMLError_LibraryNotFound
NVMLError_NoPermission = _pynvml.NVMLError_NoPermission
NVMLError_NotFound = _pynvml.NVMLError_NotFound
NVMLError_NotSupported = _pynvml.NVMLError_NotSupported
NVMLError_Unknown = _pynvml.NVMLError_Unknown
# pylint: enable=no-member
# New members in `libnvml` #############################################################################################

View file

@ -200,7 +200,7 @@ class HostProcess(host.Process, metaclass=ABCMeta):
return instance
# pylint: disable=unused-argument,super-init-not-called
# pylint: disable-next=unused-argument,super-init-not-called
def __init__(self, pid: Optional[int] = None) -> None:
pass
@ -441,7 +441,7 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
INSTANCE_LOCK = threading.RLock()
INSTANCES = WeakValueDictionary()
# pylint: disable=too-many-arguments,unused-argument
# pylint: disable-next=too-many-arguments,unused-argument
def __new__(
cls,
pid: int,
@ -478,7 +478,7 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
return instance
# pylint: disable=too-many-arguments,unused-argument
# pylint: disable-next=too-many-arguments,unused-argument
def __init__(
self,
pid: int,
@ -630,10 +630,10 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
return self._gpu_decoder_utilization
# pylint: disable=attribute-defined-outside-init
def set_gpu_memory(self, value: Union[int, NaType]) -> None:
"""Sets the used GPU memory in bytes."""
# pylint: disable=attribute-defined-outside-init
self._gpu_memory = memory_used = value
self._gpu_memory_human = bytes2human(self.gpu_memory())
memory_total = self.device.memory_total()
@ -642,7 +642,6 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
gpu_memory_percent = round(100.0 * memory_used / memory_total, 1)
self._gpu_memory_percent = gpu_memory_percent
# pylint: disable=attribute-defined-outside-init
def set_gpu_utilization(
self,
gpu_sm_utilization: Optional[int] = None,
@ -652,6 +651,7 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
) -> None:
"""Sets the GPU utilization rates."""
# pylint: disable=attribute-defined-outside-init
if gpu_sm_utilization is not None:
self._gpu_sm_utilization = gpu_sm_utilization
if gpu_memory_utilization is not None:

View file

@ -49,7 +49,7 @@ def grouped(iterable, size, fillvalue=None):
class HistoryGraph: # pylint: disable=too-many-instance-attributes
MAX_WIDTH = 1024
# pylint: disable=too-many-arguments
# pylint: disable-next=too-many-arguments
def __init__(
self,
upperbound,
@ -254,7 +254,7 @@ class HistoryGraph: # pylint: disable=too-many-instance-attributes
class BufferedHistoryGraph(HistoryGraph):
# pylint: disable=too-many-arguments
# pylint: disable-next=too-many-arguments
def __init__(
self,
upperbound,

View file

@ -19,7 +19,7 @@ class BreakLoop(Exception):
class MainScreen(DisplayableContainer): # pylint: disable=too-many-instance-attributes
NAME = 'main'
# pylint: disable=redefined-builtin,too-many-arguments,too-many-locals,too-many-statements
# pylint: disable-next=redefined-builtin,too-many-arguments,too-many-locals,too-many-statements
def __init__(self, devices, filters, ascii, mode, win, root):
super().__init__(win, root)

View file

@ -392,7 +392,7 @@ class DevicePanel(Displayable): # pylint: disable=too-many-instance-attributes
def colorize(s):
if len(s) > 0:
# pylint: disable=cell-var-from-loop
# pylint: disable-next=cell-var-from-loop
return colored(s, device.display_color)
return ''

View file

@ -12,7 +12,7 @@ from nvitop.gui.screens import BreakLoop, EnvironScreen, HelpScreen, MainScreen,
class Top(DisplayableContainer): # pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-arguments
# pylint: disable-next=too-many-arguments
def __init__(
self,
devices,

View file

@ -54,7 +54,7 @@ from nvitop.version import __version__
TTY = sys.stdout.isatty()
# pylint: disable=too-many-branches,too-many-statements,too-many-locals
# pylint: disable-next=too-many-branches,too-many-statements,too-many-locals
def select_devices(
devices: Iterable[Device] = None,
*,