Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
glentner committed Dec 19, 2021
2 parents fde2752 + c592cb8 commit 1014ad2
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 38 deletions.
2 changes: 1 addition & 1 deletion monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# package metadata
__appname__ = 'monitor'
__version__ = '2.3.0'
__version__ = '2.3.1'
__authors__ = 'Geoffrey Lentner'
__contact__ = 'glentner@purdue.edu'
__license__ = 'Apache Software License 2.0'
Expand Down
11 changes: 7 additions & 4 deletions monitor/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE, SIG_DFL)

# external libs
from cmdkit.app import Application
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ..core.logging import Logger
from ..core.exceptions import CompletedCommand
from .. import (__appname__, __version__, __description__,
__copyright__, __license__, __website__)

# external libs
from cmdkit.app import Application
from cmdkit.cli import Interface, ArgumentError

# resource commands
from .cpu import CPUDevice
from .gpu import GPUDevice

# public interface
__all__ = ['ResourceMonitor', 'main', ]


DEVICES = {
'cpu': CPUDevice,
Expand Down
13 changes: 8 additions & 5 deletions monitor/cli/cpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
# standard libs
import sys

# internal libs
from ...core.logging import Logger
from ...core.exceptions import CompletedCommand
from ... import __appname__

# external libs
from cmdkit.app import Application
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...core.logging import Logger
from ...core.exceptions import CompletedCommand

# resource commands
from .percent import CPUPercent
from .memory import CPUMemory

# public interface
__all__ = ['CPUDevice', ]


RESOURCES = {
'percent': CPUPercent,
Expand Down
11 changes: 7 additions & 4 deletions monitor/cli/cpu/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
import psutil
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER
from ... import __appname__

# external libs
import psutil
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['CPUMemory', ]


PROGRAM = f'{__appname__} cpu memory'
Expand Down
11 changes: 7 additions & 4 deletions monitor/cli/cpu/percent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
import psutil
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER
from ... import __appname__

# external libs
import psutil
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['CPUPercent', ]


PROGRAM = f'{__appname__} cpu percent'
Expand Down
11 changes: 7 additions & 4 deletions monitor/cli/gpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@
# standard libs
import sys

# external libs
from cmdkit.app import Application
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...core.logging import Logger
from ...core.exceptions import CompletedCommand

# external libs
from cmdkit.app import Application
from cmdkit.cli import Interface, ArgumentError

# resource commands
from .percent import GPUPercent
from .memory import GPUMemory
from .power import GPUPower
from .temp import GPUTemp

# public interface
__all__ = ['GPUDevice', ]


RESOURCES = {
'percent': GPUPercent,
Expand Down
9 changes: 6 additions & 3 deletions monitor/cli/gpu/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...contrib import SMIData
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['GPUMemory', ]


PROGRAM = f'{__appname__} gpu memory'
Expand Down
9 changes: 6 additions & 3 deletions monitor/cli/gpu/percent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...contrib import SMIData
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['GPUPercent', ]


PROGRAM = f'{__appname__} gpu percent'
Expand Down
9 changes: 6 additions & 3 deletions monitor/cli/gpu/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...contrib import SMIData
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['GPUPower', ]


PROGRAM = f'{__appname__} gpu power'
Expand Down
9 changes: 6 additions & 3 deletions monitor/cli/gpu/temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import time
import functools

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError

# internal libs
from ... import __appname__
from ...contrib import SMIData
from ...core.exceptions import log_and_exit
from ...core.logging import Logger, PLAIN_HANDLER, CSV_HANDLER

# external libs
from cmdkit.app import Application, exit_status
from cmdkit.cli import Interface, ArgumentError
# public interface
__all__ = ['GPUTemp', ]


PROGRAM = f'{__appname__} gpu temp'
Expand Down
3 changes: 3 additions & 0 deletions monitor/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from .nvidia import NvidiaPercent, NvidiaMemory, NvidiaTemperature, NvidiaPower
from .rocm import RocmPercent, RocmMemory, RocmTemperature, RocmPower

# public interface
__all__ = ['SMIData', ]


class SMIData:
"""High-level interface to external smi tool for GPU telemetry."""
Expand Down
3 changes: 3 additions & 0 deletions monitor/contrib/nvidia.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# internal libs
from ..core.extern import ExternalMetric

# public interface
__all__ = ['NvidiaMetric', 'NvidiaPercent', 'NvidiaMemory', 'NvidiaPower', 'NvidiaTemperature', ]


class NvidiaMetric(ExternalMetric, ABC):
"""Status object for Nvidia GPU resource."""
Expand Down
3 changes: 3 additions & 0 deletions monitor/contrib/rocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
# internal libs
from ..core.extern import ExternalMetric

# public interface
__all__ = ['RocmMetric', 'RocmPercent', 'RocmMemory', 'RocmPower', 'RocmTemperature', ]


class RocmMetric(ExternalMetric, ABC):
"""Run rocm-smi to collect metrics on GPU usage."""
Expand Down
3 changes: 3 additions & 0 deletions monitor/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# type annotations
from typing import Callable

# public interface
__all__ = ['CompletedCommand', 'log_and_exit', ]


class CompletedCommand(Exception):
"""Lift exit_status of sub-commands `main` method."""
Expand Down
7 changes: 6 additions & 1 deletion monitor/core/extern.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# You should have received a copy of the Apache License along with this program.
# If not, see <https://www.apache.org/licenses/LICENSE-2.0>.

"""Stat class implementations for external tools (e.g., nvidia-smi, rocm-smi)."""
"""Simple support for external metrics (subprocess call to external commands)."""


# type annotations
Expand All @@ -19,10 +19,15 @@
from abc import ABC, abstractclassmethod
from subprocess import check_output

# public interface
__all__ = ['ExternalMetric', ]


# value type for metrics
# either individual value, a list, or indexed collection
T = TypeVar('T', float, List[float], Dict[int, float])


class ExternalMetric(ABC):
"""Structured object from text-block."""

Expand Down
9 changes: 6 additions & 3 deletions monitor/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
# internal library
from .. import __appname__

# public interface
__all__ = ['HOSTNAME', 'Logger', 'PLAIN_HANDLER', 'CSV_HANDLER', ]

# get hostname from `socket` instead of `.config`

# cache hostname
HOSTNAME = socket.gethostname()

# NOTICE messages won't actually be formatted with color.

LEVELS = levels.Level.from_names(['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) # noqa: typing is broken
COLORS = colors.Color.from_names(['blue', 'green', 'yellow', 'red', 'magenta']) # noqa: typing is broken
RESET = colors.Color.reset
Expand Down Expand Up @@ -67,7 +70,7 @@ def with_name(cls, name: str) -> Logger:

@property
def handlers(self) -> List[handlers.Handler]:
"""Overide of local handlers to global list."""
"""Override of local handlers to global list."""
global _handlers
return _handlers

Expand Down

0 comments on commit 1014ad2

Please sign in to comment.