Skip to content

Switch core over to new configuration#1103

Merged
davidorme merged 21 commits intodevelopfrom
1101-switch-core-over-to-new-configuration
Oct 23, 2025
Merged

Switch core over to new configuration#1103
davidorme merged 21 commits intodevelopfrom
1101-switch-core-over-to-new-configuration

Conversation

@davidorme
Copy link
Copy Markdown
Collaborator

@davidorme davidorme commented Oct 21, 2025

Description

This PR updates the whole of the core model to using the new configuration system.

The big changes are:

  • The core.core_component and core.grid modules have been updated to use data provided from core.model_config classes, removing all usage of the old Config dictionary.
  • The core.model_config module has been updated to improve the docstrings and to provide better validation and class structure.
  • The soil.model_config has been updated. I'd been planning to move forward with moving soil config into CSV files and had left a lot of structure out of this file, which is now provided. I still think we should move to CSV, but not within the [META] Replacing the configuration system. #1085 meta PR

The other changes are utility fixes, improvements

  • Made the new configuration classes frozen and also stopped them silently ignoring unknown inputs.
  • Added a TOML output method to CompiledConfiguration
  • Some of the core tests were config validation within the setup - these tests are all now more appropriate at the level of the core.model_config classes since that is one of the key advantages of the new system. Bad configs basically can't be created.

Everything else is test fixes:

  • Core stuff and the core fixtures all swap out the old style Config dict for the new classes.
  • Other model tests are updated to fix. These mostly maintain a dual system for now until they can be swapped over. Several of the Model.from_config tests currently throw in a test case with bad config inputs. As noted above - this is no longer a thing under the new system - the configuration classes auto-validate on loading before they even get near a from_config method, so a bad Configuration object is no longer possible. I've propped these tests up for now but those test cases can be retired as models are updated.

Fixes #1101

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 98.10127% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.56%. Comparing base (8ad15e1) to head (18e8967).

Files with missing lines Patch % Lines
virtual_ecosystem/core/configuration.py 60.00% 2 Missing ⚠️
virtual_ecosystem/core/model_config.py 98.59% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1103      +/-   ##
===========================================
+ Coverage    94.55%   94.56%   +0.01%     
===========================================
  Files           90       90              
  Lines         7882     7916      +34     
===========================================
+ Hits          7453     7486      +33     
- Misses         429      430       +1     

☔ 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.

@davidorme davidorme linked an issue Oct 21, 2025 that may be closed by this pull request
@davidorme davidorme marked this pull request as ready for review October 22, 2025 17:12
Base automatically changed from 1089-new-config-into-basemodel to develop October 23, 2025 07:24
@davidorme
Copy link
Copy Markdown
Collaborator Author

@jacobcook1995 Do you think you'd have time to look at this before you leave? There are quite a lot of files, but it is basically swapping out configuration settings to maintain the same set of tests.

I've edited tests that incorporated config validation, since that now all happens much earlier.

@jacobcook1995
Copy link
Copy Markdown
Collaborator

@davidorme if it's ready to review now I can take a look today

Copy link
Copy Markdown
Collaborator

@jacobcook1995 jacobcook1995 left a comment

Choose a reason for hiding this comment

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

LGTM! A few minor comments + queries but nothing that should prevent merging

Comment thread docs/source/conf.py
Comment thread tests/core/test_model_config.py
Comment thread virtual_ecosystem/models/soil/soil_model.py
Comment thread virtual_ecosystem/models/soil/model_config.py
@davidorme davidorme merged commit 971a09e into develop Oct 23, 2025
13 checks passed
@davidorme davidorme deleted the 1101-switch-core-over-to-new-configuration branch October 23, 2025 12:15
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.

Switch core over to new configuration.

3 participants