Repository navigation
Write model headers from explicit fields - #895
Conversation
tompollard
left a comment
There was a problem hiding this comment.
The header step is correct, and it can merge. I have one follow-up about the duplicate it leaves on the Record side. The focused header, fixture, parity and warning tests pass (416 passed, 44 expected skips), as do the offline suite (2,293 passed, 48 skipped) and Ruff.
What I checked
-
The comparison test still compares old and new header code. Since the model no longer calls the inherited header methods, I checked what the legacy side runs.
LEGACY_WRITE_PATCHESswaps the public writers for their_legacy_*versions and_write_prepared_filesfor_legacy_write_prepared_files, so the legacy side never reaches_write_model_header. Every modern write is therefore still compared against the oldRecordheader path. -
Output compared directly with
main(9a79f42). Every modern write now goes through new header code, so I also compared bytes and errors across versions:- every readable sample header, both kinds and layouts, through
write_recordandSignalRead.write; - 3,000 random sparse records through
write_record, with optional names, units, formats, calibration,adc_res, comments, counter frequency, base counter and shared file names; - 15 invalid header fields through
write_record, coveringfs,sig_name,units,fmt,adc_gain,adc_res,baseline,counter_freq,base_counter,comments,file_name,byte_offsetandblock_size; - the 480 flattened multi-segment writes from my #891 check, across all four writers.
Every outcome matches
mainexactly, file names and bytes included. Every invalid case still fails with the same message and leaves no files. - every readable sample header, both kinds and layouts, through
-
The new test fails on
main. Onmain, the model inherits theseHeaderMixinmethods rather than binding them in its class body, so the patches do reach it. I copied the test into amaincheckout, and it fails there.
Follow-up: the Record header path is now a second copy
HeaderMixin._write_checked_header (from #875) and the new _header._write_checked_single_header now implement the same sequence twice: select fields, validate, check cohesion, serialize. _check_signal_snapshot_cohesion likewise repeats the snapshot branch of HeaderMixin.check_field_cohesion, including the "must have the same fmt" check. Record.wrsamp still uses the mixin versions, and it's public. As with #888/#889, having the mixin method call _write_checked_single_header with getattr-built fields, and check_field_cohesion call the new function in its snapshot branch, would leave one implementation. That fits naturally in the cleanup PR, before the legacy comparison paths are removed, while the comparison can still confirm the Record side.
|
Thanks, I agree. I kept |
## Summary Consolidate the duplicate header and signal validation left by #895 and #896. `Record._write_checked_header` now calls the explicit header function, its snapshot cohesion check calls the shared helper, and `SignalMixin.check_sig_cohesion` uses the explicit shape and range checker while keeping its direct-call checksum and initial-value checks. `_WriteModel` no longer inherits `BaseRecord`, `HeaderMixin`, or `SignalMixin`. This is the first #866 cleanup step. The `_legacy_*` paths and parity test remain independent for this review. Removing them needs a separate checklist that maps each parity case to a fixed byte fixture or test. The model still projects channel fields to lists while preparing a write; that remaining metadata representation work is separate from inheritance removal. ## Checks - 2,294 offline tests passed; 48 skipped and 23 network tests deselected. - Writer byte fixtures, old-versus-new parity, explicit header and `.dat` tests, and warning caller tests passed (417 passed, 44 expected skips in the focused run). - Direct `Record.check_sig_cohesion` calls matched pre-change main in 2,000 generated cases, including errors, printed diagnostics, and in-place samples-per-frame defaults. - Docs built with warnings treated as errors; Ruff and `git diff --check` passed. No changelog entry because this changes only internal writer structure.
Summary
Write
_WriteModelheaders from its current record fields and a captured channel snapshot. The new path validates fields, checks shared-file cohesion, serializes lines, and writes the header without calling inheritedHeaderMixinmethods. The legacyRecordheader method remains in place, and.datwriting is unchanged.This is the header step of #866. No public behavior or file output change is intended.
Checks
git diff --checkpassed.No changelog entry because this changes only the internal writer path.