✨ feat: get_devices_ts_time_ago — concurrent batch helper #168

Merged
mat merged 1 commit from feat/devices-ts-batch into main 2026-10-27 11:11:04 +00:00
Owner

Summary

+ BatchMixin (_batch.py) → ComwattClient (MRO, after CataloguesMixin)
+  get_devices_ts_time_ago(device_ids, *, max_workers=None, **kwargs)
+    ThreadPoolExecutor fan-out of get_device_ts_time_ago
+    results in input order · first-failure-in-input-order raised · min(8, n) workers

No REST bulk endpoint exists for per-device series (repeated id= keeps only the first — field notes), so N devices mean N calls; this mirrors the SPA's parallel fan-out. Fail-fast is deterministic: all futures are collected, then the exception of the first failing device in input order is raised — same semantics as a sequential loop that dies, just faster. Docstring carries the shared-requests.Session-across-threads caveat (simple GETs, urllib3 pool is thread-safe; not an official requests guarantee).

Evidence

  • Before: AttributeError — no batch method; N devices = N sequential round-trips.
  • After: 7 new mocked tests (input-order preservation with staggered completion, kwargs passthrough, fail-fast picks input-order-first error among multiple failures, empty input → [], max_workers cap/short-list/explicit); pytest = 227 passed (baseline 220); mypy clean. Reviewer verdicts: spec PASS, quality PASS (3 Minor parked — see PR comments if needed).

Merge Danger

Door: two-way — additive mixin; revert removes it cleanly.

Blast Radius: low — one new public method; no existing method touched.

Closes #103

## Summary ```diff + BatchMixin (_batch.py) → ComwattClient (MRO, after CataloguesMixin) + get_devices_ts_time_ago(device_ids, *, max_workers=None, **kwargs) + ThreadPoolExecutor fan-out of get_device_ts_time_ago + results in input order · first-failure-in-input-order raised · min(8, n) workers ``` No REST bulk endpoint exists for per-device series (repeated `id=` keeps only the first — field notes), so N devices mean N calls; this mirrors the SPA's parallel fan-out. Fail-fast is deterministic: all futures are collected, then the exception of the first failing device **in input order** is raised — same semantics as a sequential loop that dies, just faster. Docstring carries the shared-`requests.Session`-across-threads caveat (simple GETs, urllib3 pool is thread-safe; not an official requests guarantee). ## Evidence - **Before:** `AttributeError` — no batch method; N devices = N sequential round-trips. - **After:** 7 new mocked tests (input-order preservation with staggered completion, kwargs passthrough, fail-fast picks input-order-first error among multiple failures, empty input → `[]`, max_workers cap/short-list/explicit); `pytest` = **227 passed** (baseline 220); `mypy` clean. Reviewer verdicts: spec **PASS**, quality **PASS** (3 Minor parked — see PR comments if needed). ## Merge Danger **Door:** two-way — additive mixin; revert removes it cleanly. **Blast Radius:** low — one new public method; no existing method touched. Closes #103
✨ feat: get_devices_ts_time_ago — concurrent batch helper (#103)
All checks were successful
Tests / forgejo-pytest (push) Successful in 46s
Tests / forgejo-pytest (pull_request) Successful in 45s
fba27a49f1
mat changed title from WIP: ✨ feat: get_devices_ts_time_ago — concurrent batch helper to ✨ feat: get_devices_ts_time_ago — concurrent batch helper 2026-10-27 11:10:53 +00:00
mat merged commit c9b9ab95ec into main 2026-10-27 11:11:04 +00:00
mat deleted branch feat/devices-ts-batch 2026-10-27 11:11:04 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mat/python-comwatt-client!168
No description provided.