Reject raw files without padding if discard partial is not set (#374)
Build on RHEL9 / build (push) Successful in 3m3s
Build on RHEL8 / build (push) Successful in 3m25s
Run tests using data on local RHEL8 / build (push) Successful in 4m21s
Build on local RHEL8 / build (push) Successful in 3m5s

We have no code in aare to deal with RawFiles that have missing packets
if they are not padded to full size or frames with packet loss dropped.

Added: 
- check that we don't try to read files that are not supported
- python bindings for frame discard policy

at least we get the check in: 
closes #171

---------

Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch>
This commit is contained in:
Erik Fröjdh
2026-09-18 17:06:11 +02:00
committed by GitHub
co-authored by mazzol_a
parent 97ddf6e7c1
commit 0dc72634a9
12 changed files with 181 additions and 8 deletions
+14 -3
View File
@@ -3,7 +3,7 @@
import json
import pytest
from aare import RawMasterFile, ReadoutMode, DetectorType
from aare import RawMasterFile, ReadoutMode, DetectorType, FrameDiscardPolicy
@pytest.mark.withdata
@@ -16,7 +16,15 @@ def test_read_rawfile_quad_eiger_and_compare_to_numpy(test_data_path):
assert(f.detector_type == DetectorType.Jungfrau)
def test_raw_master_file_context_manager(tmp_path):
@pytest.mark.parametrize(
"policy, expected_policy",
[
("nodiscard", FrameDiscardPolicy.NoDiscard),
("discard", FrameDiscardPolicy.Discard),
("discardpartial", FrameDiscardPolicy.DiscardPartial),
],
)
def test_raw_master_file_context_manager(tmp_path, policy, expected_policy):
file_name = tmp_path / "run_master_0.json"
file_name.write_text(json.dumps({
"Version": 7.2,
@@ -29,10 +37,13 @@ def test_raw_master_file_context_manager(tmp_path):
"Total Frames": 2,
"Frames in File": 2,
"Frame Padding": 1,
"Frame Discard Policy": "nodiscard",
"Frame Discard Policy": policy,
}))
with RawMasterFile(file_name) as context_file:
assert context_file.reading_mode == ReadoutMode.UNKNOWN
assert context_file.detector_type == DetectorType.Jungfrau
frame_discard_policy = context_file.frame_discard_policy
assert isinstance(frame_discard_policy, FrameDiscardPolicy)
assert frame_discard_policy == expected_policy