Repository navigation
Separate current storage fields from logical metadata - #841
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. Nothing user-visible changes: Record.metadata matches the merge base for every record in sample-data and for odd manual records (short lists, invalid skew, NumPy arrays, missing or boolean n_sig), and write_record writes byte-identical files for every single-segment sample record. The offline suite, Ruff and the strict docs build pass locally.
One thing I'd change:
skew_appliedis decided for the whole record._capture_signal_fieldssets the flag only when the wholeskewlist still equals_applied_skew. On100skewthat gives[(None, False), (3, True)]after a read, but after changing only channel 0's skew to 1 it gives[(1, False), (3, False)], although channel 1's samples are still realigned by 3. Nothing readsskew_appliedyet, so it's latent, but it would be safer to compare each channel with its own_applied_skewentry, or to leave the field out until a consumer needs it.
Optional, and already the case on main: now that Record.metadata is built with _capture_signal_fields, a string still passes the length check, so Record(n_sig=2, sig_name="II").metadata.signals has two channels named "I". The write path rejects strings as "not a per-channel sequence"; applying the same rule here would give None rather than wrong names.
|
Thanks. I addressed both points in 6ce9417. I removed I also made The full offline suite passes (1,623 passed, 4 skipped), as do Ruff and the strict docs build. |
tompollard
left a comment
There was a problem hiding this comment.
Thanks, 6ce9417 covers both. Dropping skew_applied makes sense while the writer still decides from the whole list. String channel fields now give metadata.signals is None, including a one-channel sig_name="I", which matches the writers (wrsamp and write_record reject units="V" with the same message as before), and channel-selected reads are unchanged. The offline suite, Ruff and the strict docs build pass locally.
Tiny nit: the final assert hasattr(record, "metadata") in test_metadata_rejects_string_channel_field can't fail after the two lines above it.
Ready to merge once CI is green.
|
Agreed. I removed the redundant |
Summary
This continues #744 by separating logical channel metadata from the current Record's storage declarations within the on-demand channel snapshot.
_SignalFieldSnapshot.storagegroups file name, format, samples per frame, skew, offsets, and other storage fields for each channel. Skew is the current declared field; loaded values may already have it applied.Record.metadata.signalsnow projects its logical fields from the same snapshot builder. A malformed storage list does not hide otherwise valid logical metadata.Recordlists remain the only mutable owner of these values, andsource_headerremains the description of the original file.The storage view stays internal in this PR. It describes fields currently declared on a Record; it is not an exact byte-level write plan, since writing may rename files, clear offsets, or omit already applied skew. This keeps the public naming and semantics open for review before adding an API.
Verification
New tests cover selected records with skew, manual records without a source, in-place edits, incomplete storage fields, and variable-layout headers. A review follow-up also rejects strings as per-channel lists in
Record.metadata, with a regression test and changelog entry. The full offline suite, Ruff, and the strict Sphinx build pass.Refs #744 and #749.