Skip to content

Commit 53b4eee

Browse files
DannyWall92claude
andcommitted
Fix CI across probe-agent, training-monitor, and inference-monitor
Probe Agent: - Create libnvidia-ml.so.1 symlink to CUDA stubs in build and unit-test CI jobs so test binaries can load without a real driver - Add LD_LIBRARY_PATH for stubs dir in build step Training Monitor (58 ruff errors): - Fix UP035/UP037: modernize type annotations (collections.abc imports, remove string quotes from annotations) - Fix F841: remove unused variables - Fix F401: remove unused imports - Fix E402: add noqa for post-importorskip imports in tests - Fix E501: break long lines - Fix SIM102/SIM105/SIM108: simplify conditionals and exception handling - Fix B007/B905: prefix unused loop vars, add strict=False to zip - Fix N803/N806: rename uppercase variables Inference Monitor (38 ruff errors): - Fix F401: remove unused imports - Fix UP041: replace asyncio.TimeoutError with TimeoutError - Fix SIM105: use contextlib.suppress instead of try/except/pass - Fix E501: break long lines - Fix F841: prefix unused variables with underscore - Fix N803: rename uppercase parameter - Fix SIM108: use ternary expressions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f58d7f2 commit 53b4eee

32 files changed

Lines changed: 114 additions & 147 deletions

.github/workflows/ci-probe-agent.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
libgrpc++-dev libgtest-dev libgmock-dev pkg-config ca-certificates \
4141
libspdlog-dev nlohmann-json3-dev libssl-dev
4242
rm -rf /var/lib/apt/lists/*
43+
ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1
4344
4445
- name: Configure CMake
4546
working-directory: probe-agent
@@ -51,6 +52,8 @@ jobs:
5152
5253
- name: Build
5354
working-directory: probe-agent
55+
env:
56+
LD_LIBRARY_PATH: /usr/local/cuda/lib64/stubs
5457
run: cmake --build build --parallel $(nproc)
5558

5659
- name: Upload build artifacts
@@ -75,6 +78,7 @@ jobs:
7578
cmake ninja-build g++ libgtest-dev libgmock-dev libprotobuf-dev \
7679
libgrpc++-dev pkg-config libspdlog-dev nlohmann-json3-dev libssl-dev
7780
rm -rf /var/lib/apt/lists/*
81+
ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1
7882
7983
- name: Build and test
8084
working-directory: probe-agent

inference-monitor/src/sentinel_inference/analyzers/entropy_analyzer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212

1313
from __future__ import annotations
1414

15-
import dataclasses
16-
from typing import Any
17-
1815
import numpy as np
1916
import structlog
2017

inference-monitor/src/sentinel_inference/analyzers/kl_divergence.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import dataclasses
1212
import time
1313
from collections import OrderedDict
14-
from typing import Any
1514

1615
import numpy as np
1716
import structlog

inference-monitor/src/sentinel_inference/analyzers/logit_analyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ class EWMATracker:
6666
"_sigma",
6767
)
6868

69-
def __init__(self, lambda_: float = 0.1, L: float = 3.5, burn_in: int = 1000) -> None:
69+
def __init__(
70+
self, lambda_: float = 0.1, control_limit: float = 3.5, burn_in: int = 1000,
71+
) -> None:
7072
self._lambda = lambda_
71-
self._L = L
73+
self._L = control_limit
7274
self._burn_in = burn_in
7375
self._count: int = 0
7476
self._ewma: float = 0.0

inference-monitor/src/sentinel_inference/analyzers/spectral_analyzer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
from __future__ import annotations
2020

21-
import dataclasses
2221
from collections import deque
23-
from typing import Any
2422

2523
import numpy as np
2624
import structlog

inference-monitor/src/sentinel_inference/analyzers/statistical_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
from __future__ import annotations
99

10-
import dataclasses
1110
from collections import deque
12-
from typing import Any
1311

1412
import numpy as np
1513
import structlog
@@ -110,7 +108,9 @@ def analyze(self, logits: np.ndarray) -> list[AnomalyEvent]:
110108
ucl=self._config.ks_p_value_threshold,
111109
lcl=0.0,
112110
sample_count=len(self._baseline),
113-
severity="critical" if ks_p < self._config.ks_p_value_threshold / 10 else "warning",
111+
severity=(
112+
"critical" if ks_p < self._config.ks_p_value_threshold / 10 else "warning"
113+
),
114114
details={"ks_statistic": ks_stat, "p_value": ks_p},
115115
)
116116
)

inference-monitor/src/sentinel_inference/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ class StatisticalTestsConfig(BaseModel):
120120
default=1,
121121
ge=0,
122122
le=4,
123-
description="Index into Anderson-Darling significance levels (0=15%, 1=10%, 2=5%, 3=2.5%, 4=1%).",
123+
description="Index into Anderson-Darling significance levels "
124+
"(0=15%, 1=10%, 2=5%, 3=2.5%, 4=1%).",
124125
)
125126
baseline_size: int = Field(
126127
default=5000,
@@ -252,15 +253,15 @@ class MonitorConfig(BaseModel):
252253
metrics: MetricsConfig = Field(default_factory=MetricsConfig)
253254

254255
@model_validator(mode="after")
255-
def _set_defaults(self) -> "MonitorConfig":
256+
def _set_defaults(self) -> MonitorConfig:
256257
if not self.node_id:
257258
self.node_id = os.environ.get("HOSTNAME", "unknown")
258259
if not self.replica_id:
259260
self.replica_id = os.environ.get("POD_NAME", self.node_id)
260261
return self
261262

262263
@classmethod
263-
def from_yaml(cls, path: str | Path) -> "MonitorConfig":
264+
def from_yaml(cls, path: str | Path) -> MonitorConfig:
264265
"""Load configuration from a YAML file, with env-var overrides."""
265266
import yaml # type: ignore[import-untyped]
266267

@@ -273,7 +274,7 @@ def from_yaml(cls, path: str | Path) -> "MonitorConfig":
273274
return cls.model_validate(raw)
274275

275276
@classmethod
276-
def from_env(cls) -> "MonitorConfig":
277+
def from_env(cls) -> MonitorConfig:
277278
"""Build config from environment variables prefixed with SENTINEL_."""
278279
overrides: dict[str, str] = {}
279280
for key, val in os.environ.items():

inference-monitor/src/sentinel_inference/grpc_client.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from __future__ import annotations
1010

1111
import asyncio
12+
import contextlib
1213
import hashlib
1314
import time
1415
import uuid
@@ -201,24 +202,18 @@ async def stop(self) -> None:
201202
self._running = False
202203
if self._flush_task is not None:
203204
self._flush_task.cancel()
204-
try:
205+
with contextlib.suppress(asyncio.CancelledError):
205206
await self._flush_task
206-
except asyncio.CancelledError:
207-
pass
208207
if self._ack_task is not None:
209208
self._ack_task.cancel()
210-
try:
209+
with contextlib.suppress(asyncio.CancelledError):
211210
await self._ack_task
212-
except asyncio.CancelledError:
213-
pass
214211
# Final flush.
215212
await self._flush()
216213
# Close the bidi stream if open.
217214
if self._stream is not None:
218-
try:
215+
with contextlib.suppress(Exception):
219216
await self._stream.done_writing()
220-
except Exception:
221-
pass
222217
self._stream = None
223218
if self._channel is not None:
224219
await self._channel.close()
@@ -386,8 +381,10 @@ async def _do_send(self, report: AnomalyReport) -> None:
386381
async def _do_send_proto(self, report: AnomalyReport) -> None:
387382
"""Send using generated protobuf stubs."""
388383
from google.protobuf.timestamp_pb2 import Timestamp # type: ignore[import-untyped]
389-
from sentinel.v1 import anomaly_pb2 # type: ignore[import-untyped]
390-
from sentinel.v1 import common_pb2 # type: ignore[import-untyped]
384+
from sentinel.v1 import (
385+
anomaly_pb2, # type: ignore[import-untyped]
386+
common_pb2, # type: ignore[import-untyped]
387+
)
391388

392389
# Build the AnomalyBatch protobuf message.
393390
batch = anomaly_pb2.AnomalyBatch()
@@ -473,7 +470,6 @@ async def _do_send_manual(self, report: AnomalyReport) -> None:
473470
"""
474471
import json
475472

476-
import grpc # type: ignore[import-untyped]
477473

478474
payload = json.dumps({
479475
"source_hostname": report.source_hostname,

inference-monitor/src/sentinel_inference/interceptors/triton_interceptor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import struct
1212
import uuid
1313
from multiprocessing import shared_memory
14-
from typing import Any
1514

1615
import numpy as np
1716
import structlog

inference-monitor/src/sentinel_inference/interceptors/trtllm_interceptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ async def capture_output(self) -> TensorCapture | None:
108108
"""Retrieve the next captured tensor from the internal queue."""
109109
try:
110110
return await asyncio.wait_for(self._queue.get(), timeout=0.1)
111-
except asyncio.TimeoutError:
111+
except TimeoutError:
112112
return None

0 commit comments

Comments
 (0)