Skip to content

add config defaults inheritance and startup validation#11

Open
jl33-ai wants to merge 2 commits into
LorenFrankLab:mainfrom
jl33-ai:add-config-defaults-and-validation
Open

add config defaults inheritance and startup validation#11
jl33-ai wants to merge 2 commits into
LorenFrankLab:mainfrom
jl33-ai:add-config-defaults-and-validation

Conversation

@jl33-ai
Copy link
Copy Markdown

@jl33-ai jl33-ai commented May 29, 2026

stacked on top of #10 (synthetic data source). until that one merges the diff here will include both commits. once #10 lands, GitHub will collapse this to just the config_loader / defaults.yml changes.

most of the per-animal yamls in `config/` duplicate the same sampling rates, ripple filter coefficients, gui colors, kinematics smoothing filter, mua thresholds, etc. drift across them is real and 'what is the canonical value of X' is currently unanswerable. this PR introduces a small loader so configs can share defaults.

  • configs can declare `_extends: defaults.yml` at the top and only override what is actually different. nested dicts deep merge key by key, lists and scalars replace (operator-intuitive: 'override X' means 'replace X').

  • `config/defaults.yml` holds the values that are stable across the SC* / fred / ginny configs.

  • `runscript.py` routes config loading through a new `realtime_decoder.config_loader` module that runs a small validator on the resolved config. catches things like:

    • missing `rank.supervisor`
    • unknown `algorithm`
    • missing `encoder.mark_dim`
    • decoder rank with no entry in `decoder_assignment`
    • `encoder.mark_dim` != `synthetic.mark_dim`

    errors print one readable message and exit cleanly with code 2 before MPI workers spawn, instead of surfacing as `IndexError` / `KeyError` deep inside a rank's main loop.

  • `config/demo_synthetic.yml` is rewritten as `_extends: defaults.yml` + overrides. drops about 80 lines.

  • loader uses stdlib pyyaml instead of oyaml. python 3.7+ dicts already preserve insertion order so the oyaml dep was load-bearing-by-accident only. one fewer install dep.

backward compatible: I ran the loader against all 16 existing per-animal configs and they all load and pass validation unchanged. configs without `_extends` behave exactly as before.

follow up not in this PR: the SC* / fred / ginny configs can each be rewritten as `_extends: defaults.yml` + only-the-overrides which would shrink them roughly in half. left as a separate diff so per-config behavior changes are auditable on their own.

jl33-ai added 2 commits May 29, 2026 09:27
lets you run the pipeline end to end without an acquisition rig. useful for smoke testing a fresh install, working on a laptop, and CI.

- realtime_decoder/synthetic.py: SyntheticDataReceiver and SyntheticClient that match the surface of TrodesDataReceiver and TrodesClient. drop in replacements. non-blocking __next__ semantics so the polling loops in encoder/decoder/ripple work unchanged.
- runscript.py picks the data source via config['datasource']. defaults to 'trodes' so every existing config keeps working.
- config/demo_synthetic.yml is a 5 rank demo wired to the synthetic source.
- README adds a 'running without acquisition hardware' section.

spikes are poisson, marks gaussian, position walks a triangle wave along a single segment. not biologically realistic, the point is to exercise the data path and message plumbing.

to try it:
  mpiexec -np 5 python -u runscript.py config/demo_synthetic.yml
most of the per-animal yamls duplicate the same sampling rates, ripple filter, gui colors, kinematics smoothing filter, mua, etc. drift is real and 'what is the canonical value of X' is currently unanswerable.

- configs can declare `_extends: defaults.yml` and only override what is actually different. nested dicts deep merge key by key, lists and scalars replace.
- config/defaults.yml holds the values stable across the SC*/fred/ginny configs.
- runscript routes config loading through a new config_loader module that runs a small validator on the resolved dict. catches missing rank.supervisor, unknown algorithm, missing encoder.mark_dim, decoder ranks with no assignment, encoder.mark_dim != synthetic.mark_dim, etc. errors print one readable message and exit 2 before MPI workers spawn, instead of surfacing as IndexError deep in a rank.
- config/demo_synthetic.yml now uses _extends, drops about 80 lines.
- loader uses stdlib pyyaml instead of oyaml since python 3.7+ dicts preserve order. one fewer dep.

backward compatible. verified all 16 existing per-animal configs still load and validate unchanged.

follow up not in this PR: the SC*/fred/ginny configs can each be rewritten as _extends + overrides which would shrink them by roughly half. left as a separate diff so per-config behavior changes are auditable on their own.
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