Skip to content

Streamline settings management via ezmsg-baseproc delegation#26

Merged
cboulay merged 4 commits into
mainfrom
baseproc_settings_mgmt
Apr 25, 2026
Merged

Streamline settings management via ezmsg-baseproc delegation#26
cboulay merged 4 commits into
mainfrom
baseproc_settings_mgmt

Conversation

@cboulay

@cboulay cboulay commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

Adopts the new update_settings / NONRESET_SETTINGS_FIELDS machinery from ezmsg-baseproc#8 so this repo's units delegate live-update logic to their underlying processors instead of carrying it in unit-level on_settings overrides.

Net effect: CerePlexImpedance loses ~40 lines of bespoke override; live tweaks to freq_lo / freq_hi / test_current_nA no longer churn through a full processor recreate; the offsets-only fast path that preserves the accumulated impedance array is unchanged behaviorally but now expressed as a 10-line update_settings override on the processor.

Per-unit decisions

Unit Change NONRESET_SETTINGS_FIELDS
ChannelMapUnit None — already inherits the right behavior frozenset() (default; channel_map change should reset)
CerePlexImpedance Drop unit on_settings override; add processor update_settings for the offsets-only fast path {"freq_lo", "freq_hi", "test_current_nA", "headstage_channel_offsets"}
CereLinkSource Untouched — async, multi-Session lifecycle doesn't fit BaseProducer.update_settings {"cbtime", "microvolts"} (documentary; cont_buffer_dur deliberately excluded — consumed only inside open())

CerePlexImpedanceProcessor

  • freq_lo, freq_hi, test_current_nA are read live in extract_impedance(...) and never cached in state → safe to update without resetting.
  • headstage_channel_offsets requires re-laying out trackers but the accumulated state.impedance array remains valid; update_settings patches trackers in place via _build_trackers(n_ch).
  • collect_duration_s and fft_duration_s are baked into state during _reset_state (buffer sizes, FFT window length); they correctly fall through the default reset path.
  • The unit's prior on_settings override (and the dataclasses import) are removed; the inherited base-class default now routes through processor.update_settings(self.SETTINGS).

CereLinkProducer

NONRESET_SETTINGS_FIELDS added but documentary — the producer is non-stateful and CereLinkSource.on_settings overrides the base flow entirely (it manages two sessions across an async close → open, emits DeviceStatus, and rolls back SETTINGS on failure). The constant records which fields are safe to change live for future maintainers.

What's not changing

  • CereLinkSource.on_settings — kept verbatim. The pycbsdk Session lifecycle needs await asyncio.to_thread, must avoid two simultaneous Sessions, and needs to publish DeviceStatus — none of which fits inside a sync update_settings(new_settings) -> None.
  • ChannelMapProcessor — no code change. The new default behavior fixes a latent bug for free: today, swapping channel_map on a stream whose n_ch is unchanged would not re-parse the CMP because _hash_message only hashes n_ch. Post-PR, update_settings arms _hash = -1 so _reset_state re-runs on the next message.

Dependency

Requires ezmsg-baseproc with the new BaseProcessor.update_settings / BaseProducer.update_settings and the unit-level delegation in BaseProducerUnit.on_settings / BaseProcessorUnit.on_settings. The pinned range needs to be bumped to whatever version ships ezmsg-org/ezmsg-baseproc#8 once it merges (currently using a local editable checkout for development).

Test plan

  • pytest tests/ --ignore=tests/test_impedance_integration.py --ignore=tests/test_integration.py — 44/44 pass
  • ruff check src/ tests/ — clean
  • New test test_offsets_only_update_preserves_impedance — verifies the
    accumulated impedance array survives an offsets-only update and trackers
    are re-laid out
  • New test test_non_safe_field_arms_reset — verifies collect_duration_s
    change arms a full reset (_hash == -1)
  • New test test_live_safe_field_does_not_reset — verifies
    freq_lo / freq_hi / test_current_nA updates don't reset state
  • Integration test against live nPlay / hardware — settings push from GUI
    that toggles only microvolts should now apply without a Session restart
    (was previously silently ignored on idle, applied no-op on live session)

@cboulay cboulay merged commit 856a182 into main Apr 25, 2026
16 checks passed
@cboulay cboulay deleted the baseproc_settings_mgmt branch April 25, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant