Unify impedance CSV output across streaming and non-streaming paths#187
Merged
Conversation
Both synapsectl query and synapsectl query --stream now write identical
impedance CSVs via a shared synapse.cli.impedance_csv module:
Peripheral: <name>
Electrode ID,Magnitude (Ohms),Phase (degrees),Status
<electrode_id>,<magnitude>,<phase>,<status>
Changes:
- Add a 'Peripheral: <name>' metadata header line, resolved from the
device's peripheral list (preferring the query's peripheral_id, else
the broadband recording source).
- Fix streaming CSV discrepancies: it previously wrote a different header
('Electrode ID,Magnitude,Phase'), omitted units, and had no Status
column. It now matches the non-streaming format.
- Streaming now also writes failed measurements with Status=0 (success=1);
previously failed measurements were dropped from the CSV entirely.
6106171 to
91fede5
Compare
Use 'Peripheral,<name>' (a valid 2-column CSV row) instead of the colon-separated 'Peripheral: <name>' line, so standard CSV parsers handle the metadata line gracefully.
Contributor
|
Make info() resolution consistent across both paths. The streaming case resolves the peripheral name before stream_query(), and the non-streaming case resolves it after. We should make both resolve the peripheral name prior to the query, as if something happens to the probe to make it unenumerate after the query, we will not be able to correctly resolve the peripheral name. Just more robust this way. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
synapsectl queryandsynapsectl query --streamproduce identical impedance CSVs, fixes pre-existing format discrepancies, and adds a peripheral metadata header line.Unified format (both paths):
Changes
synapse/cli/impedance_csv.py— single source of truth for the header, columns, row format, and peripheral-name resolution. Both paths use it, so output is byte-identical (LF line endings forced).Peripheral: <name>header line. The name is resolved fromdevice.info(), preferring theperipheral_idnamed in the query, falling back to the broadband (recording) source, then the first peripheral, elseUnknown.Electrode ID,Magnitude,Phase), omitted the(Ohms)/(degrees)units, and had noStatuscolumn. It now matches the non-streaming format.Status=0(success =1). Previously failed electrodes were dropped from the CSV entirely.Notes
device.info(), not the impedance response. For a single-recording-device setup this is exact; with multiple broadband sources and noperipheral_idin the query it picks the first. Returning the peripheral in the response itself would require asynapse-apiproto change (out of scope here).peripheral_idlookup usesgetattr(..., "peripheral_id", 0)so it's robust to older protos that lack the field onImpedanceQuery.Testing
py_compilepasses on all three files. Generated*_pb2.pyare gitignored, so full runtime exercise requires a built environment / device.