cjm-infra-plugin-system
Install
pip install cjm_infra_plugin_system
Project Structure
nbs/
├── core.ipynb # Core data structures for infrastructure monitoring
└── plugin_interface.ipynb # Domain-specific plugin interface for system monitoring
Total: 2 notebooks
Module Dependencies
graph LR
core[core<br/>core]
plugin_interface[plugin_interface<br/>plugin_interface]
plugin_interface --> core
1 cross-module dependencies detected
CLI Reference
No CLI commands found in this project.
Module Overview
Detailed documentation for each module in the project:
core (core.ipynb)
Core data structures for infrastructure monitoring
Import
from cjm_infra_plugin_system.core import (
SystemStats,
ProcessStats
)
Classes
@dataclass
class SystemStats:
"Standardized snapshot of system resources."
cpu_percent: float = 0.0 # Overall CPU utilization percentage
memory_used_mb: float = 0.0 # Currently used system RAM in MB
memory_total_mb: float = 0.0 # Total system RAM in MB
memory_available_mb: float = 0.0 # Available system RAM in MB
gpu_type: str = 'None' # GPU vendor: 'NVIDIA', 'AMD', 'Intel', 'None'
gpu_free_memory_mb: float = 0.0 # Free GPU memory in MB (sum of all visible devices)
gpu_total_memory_mb: float = 0.0 # Total GPU memory in MB
gpu_used_memory_mb: float = 0.0 # Used GPU memory in MB
gpu_load_percent: float = 0.0 # GPU compute utilization percentage
details: Dict[str, Any] = field(...) # Per-device stats, temperatures, etc.
def to_dict(self) -> Dict[str, Any]: # Dictionary representation for JSON serialization
"Convert to dictionary for JSON serialization."
@dataclass
class ProcessStats:
"""
Per-process resource usage snapshot reported by `MonitorPlugin.list_processes`.
CR-3 introduced this as the typed replacement for `SystemStats.details['processes']`.
Monitor plugins that can enumerate per-process GPU usage (e.g. NVIDIA via `nvitop`)
return a list of these; monitors without per-process visibility return `[]` from
the default `MonitorPlugin.list_processes()` implementation.
"""
pid: int = 0 # OS process ID
gpu_index: int = -1 # GPU index (0-based); -1 if not GPU-bound or unknown
gpu_memory_mb: float = 0.0 # GPU memory usage attributable to this process, in MB
command: str = '' # Process command line (or short name)
def to_dict(self) -> Dict[str, Any]: # Dictionary representation for JSON serialization
"Convert to dictionary for JSON serialization."
plugin_interface (plugin_interface.ipynb)
Domain-specific plugin interface for system monitoring
Import
from cjm_infra_plugin_system.plugin_interface import (
MonitorPlugin
)
Classes
class MonitorPlugin(PluginInterface):
"""
Abstract base class for hardware monitoring plugins.
CR-3 shifted MonitorPlugin from dispatcher-style `execute(command=...)` to a
typed surface: subclasses override `get_system_status()` returning `SystemStats`
and optionally `list_processes()` returning `List[ProcessStats]`. The legacy
`execute(command=...)` dispatcher is kept as a backward-compat shim so monitors
that predate CR-3 keep working until the SG-47 migration cascade.
Subclasses MUST override at least one of `execute()` or `get_system_status()` —
the `__init_subclass__` guard enforces this at class-definition time to prevent
the recursion trap where both defaults call each other.
"""
def execute(
self,
command: str = "get_system_status", # REMOVE-AFTER-OVERHAUL: rename to `action=` via SG-47 + SG-42 cascade
**kwargs: Any,
) -> Any
"Backward-compat dispatcher (REMOVE-AFTER-OVERHAUL).
Bridges pre-CR-3 callers (substrate's `_get_global_stats` + job-monitor's
`services/monitor.py`) to typed methods. New MonitorPlugin subclasses
override `get_system_status()` directly and inherit this dispatcher; old
subclasses override this dispatcher with their own dict-returning logic
and rely on the default `get_system_status()` to wrap the result.
After SG-47 cascade migrates consumers off the dispatcher and SG-48 sweep
runs, this default body drops; `execute()` either becomes abstract again
(with `command=` renamed to `action=` per SG-42) or is removed from
MonitorPlugin entirely if all monitors override typed methods."
def get_system_status(self) -> SystemStats: # Current system telemetry
"""Gather current system statistics as a typed `SystemStats` snapshot.
The default body (REMOVE-AFTER-OVERHAUL) delegates to
`self.execute("get_system_status")` and wraps the returned dict so that
monitor plugins predating CR-3 keep working. New monitors override this
method directly; the `__init_subclass__` guard ensures at least one of
`execute()` or `get_system_status()` is overridden by every concrete
subclass.
Unknown fields in the dispatcher's return dict are filtered out (rather
than raising `TypeError`) so monitors that emit extra debug fields don't
crash the wrapping.
"""
raw = self.execute("get_system_status")
if isinstance(raw, SystemStats)
"Gather current system statistics as a typed `SystemStats` snapshot.
The default body (REMOVE-AFTER-OVERHAUL) delegates to
`self.execute("get_system_status")` and wraps the returned dict so that
monitor plugins predating CR-3 keep working. New monitors override this
method directly; the `__init_subclass__` guard ensures at least one of
`execute()` or `get_system_status()` is overridden by every concrete
subclass.
Unknown fields in the dispatcher's return dict are filtered out (rather
than raising `TypeError`) so monitors that emit extra debug fields don't
crash the wrapping."
def list_processes(self) -> List[ProcessStats]: # Per-process resource usage
"List per-process resource usage. Default returns `[]`.
Monitors with per-process GPU visibility (NVIDIA via `nvitop`/`pynvml`)
override this. CPU-only monitors and AMD pre-ROCm inherit the empty
default since they cannot enumerate per-GPU-process attribution.
`list_devices()` is deliberately omitted per audit's Q-CR3-1=(c) YAGNI
disposition — add when multi-GPU support surfaces a concrete consumer
need."
Metadata
Release files for cjm-infra-plugin-system 0.0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cjm_infra_plugin_system-0.0.19.tar.gz | 11.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cjm_infra_plugin_system-0.0.19-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.4 kB
Release files / cjm_infra_plugin_system-0.0.19.tar.gz
| Download URL | cjm_infra_plugin_system-0.0.19.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4209788b29122bcf00f85c9ece861e8d278c6712d586c76bea9674955c53e51e
|
|
BLAKE2b-256 checksum How to use checksums |
85b934f3def0c22ae80a9eb900f85f060c0a4e56242847eb5c91812d6c023e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / cjm_infra_plugin_system-0.0.19-py3-none-any.whl
| Download URL | cjm_infra_plugin_system-0.0.19-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d6ffb1d24b82490935f9f9fae7fff2e5b034b3aa17eefb64f2e48663b83254f
|
|
BLAKE2b-256 checksum How to use checksums |
7893978fa9230edee1ee6ca6a3a36f30d794483564c82b460ba222d96fe56014
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for cjm-infra-plugin-system 0.0.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.