Skip to content

Allow v1 mechanism configuration to be organized across multiple yaml files#256

Merged
boulderdaze merged 9 commits intomainfrom
allow_file_path_for_v1_config
Mar 24, 2026
Merged

Allow v1 mechanism configuration to be organized across multiple yaml files#256
boulderdaze merged 9 commits intomainfrom
allow_file_path_for_v1_config

Conversation

@boulderdaze
Copy link
Copy Markdown
Contributor

@boulderdaze boulderdaze commented Mar 20, 2026

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.

# structure
examples/v1/config/yaml/
├── gas_phase.yaml
├── main.yaml
├── species.yaml
├── stratosphere.yaml
└── troposphere.yaml
# main.yaml
version: "1.1.0"
name: troposophere and stratosphere configs
species:
  files:
    - species.yaml
phases:
  files:
    - gas_phase.yaml
reactions:
  files:
    - troposophere.yaml
    - stratosphere.yaml
# species.yaml
- name: A
- name: B
  ...
# gas_phase.yaml
- name: gas
  species:
    - A
    - B
# stratosphere.yaml
- type: ARRHENIUS
  gas phase: gas
  ...

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/unit/v1/file_configs/test_parse_from_file_configs.cpp
Comment thread test/integration/CMakeLists.txt
Comment thread src/v1/parser.cpp Outdated
Comment thread test/unit/v1/file_configs/test_parse_from_file_configs.cpp Outdated
Comment thread test/integration/test_v1_read_from_file_configs.cpp
Comment thread test/integration/test_v1_read_from_file_configs.cpp Outdated
Comment thread src/v1/parser.cpp
Comment thread test/unit/v1/file_configs/test/test_parse_from_file_configs.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/v1/parser.cpp
Comment thread include/mechanism_configuration/v1/parser.hpp Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.00%. Comparing base (f1ebd17) to head (ba03bdb).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boulderdaze boulderdaze marked this pull request as ready for review March 23, 2026 17:45
@boulderdaze boulderdaze requested a review from K20shores March 23, 2026 17:47
Comment thread src/v1/parser.cpp Outdated
Comment thread src/v1/parser.cpp Outdated
Comment thread src/v1/parser.cpp
Comment thread src/v1/parser.cpp Outdated
Copy link
Copy Markdown
Collaborator

@K20shores K20shores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat. I'd also like this documented in our docs. Please address that either in this PR or a follow up PR

@boulderdaze
Copy link
Copy Markdown
Contributor Author

Neat. I'd also like this documented in our docs. Please address that either in this PR or a follow up PR

Added

@boulderdaze boulderdaze merged commit 6b55618 into main Mar 24, 2026
15 of 16 checks passed
@boulderdaze boulderdaze deleted the allow_file_path_for_v1_config branch March 24, 2026 15:51
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.

4 participants