io/yaml: preserve unknown metaData annotation fields on write/read - #717
Merged
Merged
Conversation
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.
Function test results304 tests 277 ✅ 53s ⏱️ Results for commit 4756e26. |
Merged
3 tasks
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
writeMetadata(inwriteYAMLmodel.m) only ever emits its own fixedannoFieldslist (defaultLB,defaultUB,givenName,familyName,authors,email,organization,taxonomy,note,sourceUrl). Any othermodel.annotationfield a caller had set was silently dropped instead of being written.readYAMLmodel.m's metaDataswitchblock has the matching read-side gap: any key it doesn't recognise falls through with nootherwisecase and is discarded rather than stored back ontomodel.annotation.save_ec_modelstashes ageckopy_versionprovenance field into the model's metaData before writing, expecting it to pass straight through — since#106tightenedwrite_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 fixedannoFields, emit any othermodel.annotationfield too, sorted alphabetically for deterministic output.readYAMLmodel.m: add anotherwisecase to the metaData switch that stores an unrecognised key ontomodel.annotation.(key)(guarded byisvarname, 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
tIO/writeReadYAMLPreservesUnknownAnnotationFields, verifying a custom field (geckopyVersion) round-trips alongside a normalannoFieldsentry (taxonomy).tIOsuite (matlab -batch,runtests-equivalent): 15/15 applicable tests pass (1 pre-existing skip for a missing optionalpyyamldependency, unrelated).note/description, an existing human-GEM compat alias) still resolves exactly as before.