Skip to content

Validate input yaml - #100

Merged
lrobion merged 15 commits into
MIT-LAE:mainfrom
lrobion:validate-yaml-input
Aug 12, 2026
Merged

Validate input yaml#100
lrobion merged 15 commits into
MIT-LAE:mainfrom
lrobion:validate-yaml-input

Conversation

@lrobion

@lrobion lrobion commented May 14, 2026

Copy link
Copy Markdown
Contributor

Draft to start work on #99, all tests in test_yamlreader.cpp

  • YAML reader checks for input keys that do not exist in default and errors out, tested in TEST_CASE("Validate Input Files")
  • YAML reader checks that input keys have the same structure as default: a value node in the default is also a value node in the override, a map node in default is also a map node in override. Currently a menu with something like "SIMULATION MENU: 4" can overwrite the entire simulation menu with a value when that node should hold a map to the submenus. Tested in TEST_CASE("Validate Input Files")
  • YAML reader checks for inputs that are duplicated in the same file, tested in TEST_CASE("Validate Input Files")
  • YAML reader correctly merges the same key (currently they get appended but the correct one is returned by the operator[] lookup because it returns the first). This is not an issue currently, but might be when we dump the finalized YAML. Tested in TEST_CASE("mergeYamlNodes keeps each key exactly once")
  • YAML reader rejects non scalar keys: APCEMM does not use them, and this simplifies parsing logic, tested in TEST_CASE("mergeYamlNodes rejects non-scalar keys")
  • Fix defaults in advanced menu being set in readAdvancedMenu instead of in defaults/input.yaml
  • Ensure CMake re-generates the includable files when they are modified (before if you modified defaults/input.yaml and ran the build, the default values would not have been updated because this is done at the configure step)
  • Remove SampleRunDir/ which has been superseded by examples/issl_rhi140/ (it cannot run without an input met.nc and there is no reason to maintain it anymore)
  • Remove unused yaml test file

APCEMM now throws more helpful error messages for bad YAML files:

  • For a duplicated key in the same YAML: Invalid field in YAML input file '/home/louis/code/APCEMM/examples/issl_rhi140/example.yaml': Duplicate key found: 'PARAMETER MENU -> METEOROLOGICAL PARAMETERS SUBMENU -> Pressure [hPa] (double)'. Each key must appear only once. Group all the entries of a menu under a single heading.
  • Finding a key in a user input that does not exist in the default field: Invalid field in YAML input file '/home/louis/code/APCEMM/examples/issl_rhi140/example.yaml': Unknown key found: 'PARAMETER MENU -> METEOROLOGICAL PARAMETERS SUBMENU -> Unsupported field'

@lrobion
lrobion force-pushed the validate-yaml-input branch from 98ed65f to 4cb62d3 Compare August 10, 2026 21:07
@lrobion

lrobion commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Moving these goals as another PR to make it easier to review:

  • YAML reader does not accept Monte Carlo / sweep style inputs anymore
  • All inputs in default/input.yaml have been verified to be parsed and act on the code
  • YAML reader dumps a finalized YAML that is exactly what APCEMM will use
  • Get rid of all custom string parsing and use YAML tools (blocked by sweep style inputs)

@lrobion lrobion changed the title Validate and clean input yaml Validate input yaml Aug 11, 2026
@lrobion
lrobion marked this pull request as ready for review August 11, 2026 21:26
@lrobion
lrobion merged commit 69e0521 into MIT-LAE:main Aug 12, 2026
2 checks passed
@lrobion
lrobion deleted the validate-yaml-input branch August 12, 2026 19:41
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