Skip to content

io/yaml: preserve unknown metaData annotation fields on write/read - #717

Merged
edkerk merged 1 commit into
develop3from
fix/yaml-metadata-passthrough-extra-fields
Aug 30, 2026
Merged

io/yaml: preserve unknown metaData annotation fields on write/read#717
edkerk merged 1 commit into
develop3from
fix/yaml-metadata-passthrough-extra-fields

Conversation

@edkerk

@edkerk edkerk commented Aug 30, 2026

Copy link
Copy Markdown
Member

Summary

  • writeMetadata (in writeYAMLmodel.m) only ever emits its own fixed annoFields list (defaultLB, defaultUB, givenName, familyName, authors, email, organization, taxonomy, note, sourceUrl). Any other model.annotation field a caller had set was silently dropped instead of being written.
  • readYAMLmodel.m's metaData switch block has the matching read-side gap: any key it doesn't recognise falls through with no otherwise case and is discarded rather than stored back onto model.annotation.
  • This was found while chasing a geckopy CI regression: geckopy's save_ec_model stashes a geckopy_version provenance field into the model's metaData before writing, expecting it to pass straight through — since #106 tightened write_yaml_model's metaData handling to the fixed RAVEN field set, that field (and any other caller-specific key) is now silently lost on write. This PR is the MATLAB side of that fix; the equivalent raven-toolbox (Python) fix is in a companion PR.

Fix

  • writeMetadata: after emitting the fixed annoFields, emit any other model.annotation field too, sorted alphabetically for deterministic output.
  • readYAMLmodel.m: add an otherwise case to the metaData switch that stores an unrecognised key onto model.annotation.(key) (guarded by isvarname, matching the existing convention of skipping malformed input silently), so a write/read round trip is lossless for caller-specific fields, not just RAVEN's own.

Test plan

  • Added tIO/writeReadYAMLPreservesUnknownAnnotationFields, verifying a custom field (geckopyVersion) round-trips alongside a normal annoFields entry (taxonomy).
  • Ran the full tIO suite (matlab -batch, runtests-equivalent): 15/15 applicable tests pass (1 pre-existing skip for a missing optional pyyaml dependency, unrelated).
  • Manual round-trip check confirms a second write of the re-read model is byte-identical to the first (idempotent), and that a value aliased to an existing field (note/description, an existing human-GEM compat alias) still resolves exactly as before.

writeYAMLmodel's metaData block only emitted its own fixed annoFields
list (defaultLB/defaultUB/givenName/familyName/authors/email/
organization/taxonomy/note/sourceUrl); any other model.annotation
field a caller had set (e.g. geckopy's custom geckopy_version
provenance key) was silently dropped instead of being written.
readYAMLmodel's metaData switch had the matching gap: any key it
didn't recognise was discarded rather than stored back onto
model.annotation.

Emit any remaining model.annotation field not in the fixed list too,
sorted alphabetically for deterministic output, and capture any
unrecognised metaData key on read via a generic otherwise case (guarded
by isvarname) so a write/read round trip is lossless for
caller-specific fields, not just RAVEN's own.
@github-actions

Copy link
Copy Markdown

Function test results

304 tests   277 ✅  53s ⏱️
 25 suites   27 💤
  1 files      0 ❌

Results for commit 4756e26.

edkerk added a commit to SysBioChalmers/raven-toolbox that referenced this pull request Aug 30, 2026
_build_metadata only ever emitted its own fixed set of fields (id,
name, version, date, defaultLB/defaultUB, plus the eight
_META_ANNOTATION_FIELDS). Any other key a caller had stashed in
model.notes["metaData"] was silently dropped on write, even though
model_from_yaml_data already restores the full parsed metaData dict
verbatim on read -- an asymmetry that breaks a caller-specific
provenance field (e.g. geckopy save_ec_model's geckopy_version) on a
write/read round trip.

Append any stored_meta key not already handled, sorted alphabetically
for deterministic output, mirroring the equivalent fix in RAVEN
MATLAB's writeYAMLmodel.m/readYAMLmodel.m
(SysBioChalmers/RAVEN#717).
@edkerk
edkerk merged commit fa75a84 into develop3 Aug 30, 2026
4 checks passed
@edkerk
edkerk deleted the fix/yaml-metadata-passthrough-extra-fields branch August 30, 2026 14:26
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.

1 participant