fix(docs/comments): rename refs to 'event files' to reflect their timestamp extenion names.

This commit is contained in:
2026-05-06 19:08:38 +00:00
parent 3711b11bda
commit 0484680c89
5 changed files with 42 additions and 33 deletions
+22 -15
View File
@@ -1,18 +1,22 @@
"""
sfm/waveform_store.py — On-disk store for Blastware-format waveform files.
sfm/waveform_store.py — On-disk store for Blastware-format event files.
Layout (flat per-serial):
<root>/<serial>/<filename> ← .G10 / .W / .H / etc. (Blastware-readable)
<root>/<serial>/<filename> ← event file (Blastware-readable binary)
<root>/<serial>/<filename>.a5.pkl ← pickled list of A5 S3Frame dicts
`<filename>` is whatever `minimateplus.blastware_file.blastware_filename`
produces for the event (encodes serial + timestamp + record type). Filenames
never collide for the same physical event.
produces for the event. The extension is NOT a fixed type tag — it encodes
the event timestamp (`AB0T` format: 2-char base-36 of `total_seconds %
1296`, literal `0`, then `W`=Full Waveform / `H`=Full Histogram for ACH
downloads, or 3-char `AB0` for direct/manual downloads). Every event's
filename therefore contains its own timestamp + record-type fingerprint and
collisions across the same physical event don't occur.
The `.a5.pkl` sidecar lets the .G10 be regenerated later if the encoder
changes — captures the raw 5A frame stream as serializable dicts so the
schema isn't tied to the `S3Frame` dataclass layout.
The `.a5.pkl` sidecar lets the event file be regenerated later if the
encoder changes — captures the raw 5A frame stream as serializable dicts so
the schema isn't tied to the `S3Frame` dataclass layout.
"""
from __future__ import annotations
@@ -81,7 +85,7 @@ class WaveformStore:
return d / filename, d / f"{filename}.a5.pkl"
def open_blastware(self, serial: str, filename: str) -> Optional[Path]:
"""Return absolute path to an existing .G10 file or None."""
"""Return absolute path to an existing event file or None."""
bw_path, _ = self.paths_for(serial, filename)
return bw_path if bw_path.exists() else None
@@ -94,18 +98,21 @@ class WaveformStore:
a5_frames: list[S3Frame],
) -> dict:
"""
Write the .G10 file and the .a5.pkl sidecar for one event.
Write the event file and its .a5.pkl sidecar for one event.
Returns a record dict suitable for persisting alongside the DB row:
{
"filename": "M529LKIQ.G10",
"filesize": 8708,
"a5_pickle_filename": "M529LKIQ.G10.a5.pkl",
"filename": "M529LKIQ.7M0W",
"filesize": 8708,
"a5_pickle_filename": "M529LKIQ.7M0W.a5.pkl",
}
Idempotent: if the .G10 already exists, it is overwritten with the
freshly-encoded version (same bytes for the same a5_frames).
The exact extension is timestamp-encoded per event (see
`minimateplus.blastware_file.blastware_filename`).
Idempotent: if the event file already exists, it is overwritten with
the freshly-encoded version (same bytes for the same a5_frames).
"""
if not a5_frames:
raise ValueError("WaveformStore.save: a5_frames is empty")
@@ -115,7 +122,7 @@ class WaveformStore:
filename = blastware_filename(ev, serial)
bw_path, a5_path = self.paths_for(serial, filename)
# 1. encode the .G10
# 1. encode the event file
# Delete any stale file at this path so partial writes never leak
# trailing bytes from a previous larger file (matches the live
# endpoint's defensive unlink).