Allow v1 mechanism configuration to be organized across multiple yaml files#256
Allow v1 mechanism configuration to be organized across multiple yaml files#256boulderdaze merged 9 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for organizing v1 mechanism configurations across multiple files (file-list format) and introduces unit/integration tests plus example multi-file configs to validate the behavior.
Changes:
- Extend the v1 parser to detect “inline” vs “file-list” entity formats and load/merge entities from multiple files for v1.1.x configs.
- Add unit tests and fixture configs for multi-file parsing and error cases.
- Add example v1 JSON/YAML multi-file configurations and an integration test to parse them.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/v1/parser.cpp |
Implements entity format detection and file-list config loading/merging logic. |
include/mechanism_configuration/v1/parser.hpp |
Exposes new helper/API for parsing file-list configs. |
test/unit/v1/CMakeLists.txt |
Adds the new file_configs unit-test subdirectory. |
test/unit/v1/file_configs/CMakeLists.txt |
Adds a unit test target and a copy target for file-config fixtures. |
test/unit/v1/file_configs/test/test_parse_from_file_configs.cpp |
Adds unit tests for file-list parsing and several error scenarios. |
test/unit/v1/file_configs/configs/two_species_sets/main.json |
Fixture: species split across multiple files, reactions split across files. |
test/unit/v1/file_configs/configs/two_species_sets/species_set_1.json |
Fixture: first species subset. |
test/unit/v1/file_configs/configs/two_species_sets/species_set_2.json |
Fixture: second species subset. |
test/unit/v1/file_configs/configs/two_species_sets/gas_phase.json |
Fixture: phase definition used by two-species-sets case. |
test/unit/v1/file_configs/configs/two_species_sets/troposophere.json |
Fixture: first reaction file for two-species-sets. |
test/unit/v1/file_configs/configs/two_species_sets/stratosphere.json |
Fixture: second reaction file for two-species-sets. |
test/unit/v1/file_configs/configs/two_phases_sets/main.json |
Fixture: phases split across multiple files. |
test/unit/v1/file_configs/configs/two_phases_sets/species.json |
Fixture: shared species for two-phases-sets case. |
test/unit/v1/file_configs/configs/two_phases_sets/gas_phase_1.json |
Fixture: first phase file. |
test/unit/v1/file_configs/configs/two_phases_sets/gas_phase_2.json |
Fixture: second phase file. |
test/unit/v1/file_configs/configs/two_phases_sets/troposophere.json |
Fixture: photolysis reactions file. |
test/unit/v1/file_configs/configs/two_phases_sets/stratosphere.json |
Fixture: arrhenius reactions file. |
test/unit/v1/file_configs/configs/missing_species_set/main.json |
Fixture: missing required top-level species key. |
test/unit/v1/file_configs/configs/missing_species_set/gas_phase.json |
Fixture: phase file for missing-species-set case. |
test/unit/v1/file_configs/configs/missing_species_set/troposophere.json |
Fixture: reaction file for missing-species-set case. |
test/unit/v1/file_configs/configs/missing_species_set/stratosphere.json |
Fixture: reaction file for missing-species-set case. |
test/unit/v1/file_configs/configs/missing_phase_set/main.json |
Fixture: phases present but missing files key. |
test/unit/v1/file_configs/configs/missing_phase_set/species.json |
Fixture: species file for missing-phase-set case. |
test/unit/v1/file_configs/configs/missing_phase_set/troposophere.json |
Fixture: reaction file for missing-phase-set case. |
test/unit/v1/file_configs/configs/missing_phase_set/stratosphere.json |
Fixture: reaction file for missing-phase-set case. |
test/unit/v1/file_configs/configs/missing_reaction_set/main.json |
Fixture: reactions file list is empty. |
test/unit/v1/file_configs/configs/missing_reaction_set/species.json |
Fixture: species file for missing-reaction-set case. |
test/unit/v1/file_configs/configs/missing_reaction_set/gas_phase.json |
Fixture: phase file for missing-reaction-set case. |
test/unit/v1/file_configs/configs/version_mismatch/main.json |
Fixture: version minor mismatch for file-list format. |
test/unit/v1/file_configs/configs/duplicate_species_set/main.json |
Fixture: duplicate species across multiple included files (currently not asserted by a test). |
test/unit/v1/file_configs/configs/duplicate_species_set/species_set_1.json |
Fixture: duplicate species set 1. |
test/unit/v1/file_configs/configs/duplicate_species_set/species_set_2.json |
Fixture: duplicate species set 2. |
test/unit/v1/file_configs/configs/duplicate_species_set/gas_phase.json |
Fixture: phase for duplicate-species-set case. |
test/unit/v1/file_configs/configs/duplicate_species_set/troposophere.json |
Fixture: reaction file for duplicate-species-set case. |
test/unit/v1/file_configs/configs/duplicate_species_set/stratosphere.json |
Fixture: reaction file for duplicate-species-set case. |
test/integration/CMakeLists.txt |
Adds a new integration test target for reading the example file-list configs. |
test/integration/test_v1_read_from_file_configs.cpp |
Integration test that parses the example JSON/YAML file-list configs. |
examples/v1/config/json/main.json |
Example v1 JSON main config using file lists. |
examples/v1/config/json/species.json |
Example v1 JSON species file. |
examples/v1/config/json/gas_phase.json |
Example v1 JSON phases file. |
examples/v1/config/json/troposophere.json |
Example v1 JSON reactions file (part 1). |
examples/v1/config/json/stratosphere.json |
Example v1 JSON reactions file (part 2). |
examples/v1/config/yaml/main.yaml |
Example v1 YAML main config using file lists. |
examples/v1/config/yaml/species.yaml |
Example v1 YAML species file. |
examples/v1/config/yaml/gas_phase.yaml |
Example v1 YAML phases file. |
examples/v1/config/yaml/troposophere.yaml |
Example v1 YAML reactions file (part 1). |
examples/v1/config/yaml/stratosphere.yaml |
Example v1 YAML reactions file (part 2). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/v1/parser.cpp:197
- ParseFromNode no longer performs schema/version validation and will call
.as<std::string>()on required keys unconditionally (e.g.,object[version]), which can throw if callers pass an invalid/partial YAML node. Since ParseFromNode is a public API (and is used by tests), consider restoring ValidateSchema/version checks inside ParseFromNode or making this method private/internal so callers cannot accidentally bypass validation.
ParserResult<types::Mechanism> Parser::ParseFromNode(const YAML::Node& object)
{
ParserResult<types::Mechanism> result;
std::unique_ptr<types::Mechanism> mechanism = std::make_unique<types::Mechanism>();
mechanism->version = Version(object[validation::version].as<std::string>());
if (object[validation::name])
{
std::string name = object[validation::name].as<std::string>();
mechanism->name = name;
}
auto species_parsing = ParseSpecies(object[validation::species]);
result.errors.insert(result.errors.end(), species_parsing.first.begin(), species_parsing.first.end());
mechanism->species = species_parsing.second;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #256 +/- ##
=======================================
Coverage 70.00% 70.00%
=======================================
Files 5 5
Lines 10 10
=======================================
Hits 7 7
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
K20shores
left a comment
There was a problem hiding this comment.
Neat. I'd also like this documented in our docs. Please address that either in this PR or a follow up PR
Added |
Adds support for organizing v1 configurations across multiple files to address the request described in #255.
You can have a main file that specifies where to find each component file, as shown below.