Skip to content

Carry on when an optional parameter file is present but unreadable - #207

Merged
headmeister merged 2 commits into
isi-nmr:masterfrom
gdevenyi:fix/optional-parameter-files
Aug 10, 2026
Merged

Carry on when an optional parameter file is present but unreadable#207
headmeister merged 2 commits into
isi-nmr:masterfrom
gdevenyi:fix/optional-parameter-files

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #199.

_read_parameters tolerated a missing optional file but caught only FileNotFoundError, so anything else — an empty, truncated or unsupported-version JCAMP-DX file — propagated and aborted the whole dataset. The reco lookup for a fid did the same via with suppress(FileNotFoundError).

Spec 1.3:

Every entry in these listings is optional in the manuals' own framing ("may contain"), and derived PROCNOs bear that out: parameter-map and ISA PROCNOs carry 2dseq and visu_pars but no reco […] The dependable minimum for reading image data is therefore 2dseq + visu_pars; expect reco for primary reconstructions only.

A fid is read from acqp + method, yet a zero-byte pdata/1/reco made a complete raw acquisition unloadable:

JcampdxFileError: Not a valid JCAMP-DX file file .../7/pdata/1/reco is not a JCAMP-DX file

Five experiments in the local corpus are affected. Remove the empty reco and the same fid loads as (256, 256, 1, 1, 1).

Change

  • OPTIONAL_PARAMETER_ERRORS names the family: FileNotFoundError, InvalidJcampdxFile, JcampdxFileError, JcampdxVersionError.
  • Files listed in DEFAULT_STATES[type]["parameter_files"] stay fatal; optional ones are skipped.
  • Skipping warns (RuntimeWarning) unless the file is simply absent, so the omission is visible rather than silent.

Tests

  • test_an_unreadable_optional_parameter_file_does_not_abort_the_load — builds a synthetic PV6 experiment, records the reference array, drops a zero-byte pdata/1/reco next to it, and asserts the data is unchanged and the warning is raised. Fails on master.
  • test_a_missing_required_parameter_file_is_still_fatal — guards the other direction.

Suite: 2142 passed, 12 skipped.

gdevenyi and others added 2 commits August 8, 2026 16:33
`ruff format --check` reported twelve files as unformatted, so any change
touching one of them dragged unrelated reflow into its diff. Run the
formatter once, on its own, so subsequent changes show only what they
actually change.

Formatting only: no behaviour changes, and `ruff check` is clean before and
after. The suite is unchanged at 2140 passed, 12 skipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017SNrm3jFhpTPShP8xGkePC
_read_parameters tolerated a missing optional file but caught only
FileNotFoundError, so anything else -- an empty, truncated or
unsupported-version JCAMP-DX file -- propagated and aborted the whole
dataset. The reco lookup for a fid did the same through
`with suppress(FileNotFoundError)`.

Spec 1.3 makes every PROCNO entry optional in the manuals' own framing, and
notes that derived reconstructions carry 2dseq and visu_pars with no reco at
all; a fid is read from acqp and method. A zero-byte pdata/1/reco -- what an
aborted or interrupted reconstruction leaves behind, which is exactly the
case a raw-data reader exists to rescue -- nevertheless made a complete raw
acquisition unloadable. Five experiments in the local corpus are affected.

Widen the tolerated set to the JCAMP-DX error family, keep it fatal for the
files DEFAULT_STATES declares required, and warn rather than raise so the
omission is visible. Absence stays silent, as before.

Closes isi-nmr#199

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017SNrm3jFhpTPShP8xGkePC
@gdevenyi
gdevenyi force-pushed the fix/optional-parameter-files branch from 7ea840b to 374e9c1 Compare August 8, 2026 20:51
@gdevenyi

gdevenyi commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #213 (ruff format), so this branch carries that commit until #213 merges — merge #213 first and this diff reduces to its own change. Verified after the rebase: ruff check and ruff format --check clean, full suite green.

Integration check across all eleven conformance PRs merged together: 2164 passed, 12 skipped; corpus load test 3202 → 3207 of 3478 with zero newly broken datasets.

@headmeister
headmeister merged commit 04c233b into isi-nmr:master Aug 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unparsable optional reco/d3proc aborts loading of an otherwise valid fid or 2dseq (spec 1.3)

2 participants