Merged
Conversation
alexdewar
reviewed
May 8, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #845 +/- ##
========================================
Coverage 94.76% 94.76%
========================================
Files 75 75
Lines 5559 5563 +4
========================================
+ Hits 5268 5272 +4
Misses 291 291 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
https://github.com/ImperialCollegeLondon/virtual_rainforest into 844-problem-with-running-compiled-configuration-files
vgro
reviewed
May 8, 2025
vgro
reviewed
May 8, 2025
vgro
reviewed
May 8, 2025
vgro
approved these changes
May 8, 2025
Collaborator
vgro
left a comment
There was a problem hiding this comment.
LGTM, have you tested running ve_run from a config file?
Collaborator
Author
Very good point: ➜ virtual_ecosystem ve_run --install-example /tmp
Example directory created at:
/tmp/ve_example
➜ virtual_ecosystem cd /tmp/ve_example
➜ ve_example ve_run config -o out --logfile out/out.log
100%|████████████████████| 24/24 [00:17<00:00, 1.37it/s]
➜ ve_example mkdir out2
➜ ve_example ve_run out/ve_full_model_configuration.toml -o out2 --logfile out2/out.log
100%|████████████████████| 24/24 [00:17<00:00, 1.35it/s]
➜ ve_example |
Co-authored-by: vgro <44095758+vgro@users.noreply.github.com>
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.
Description
The initial issue in #884 is that
_resolve_config_pathsiterates over the whole config dictionary looking for*_pathentries. If it find akey, itempair whereitemis a list, it assumes it is a list of dictionaries. Sometimes it is (like with thevariables: [{var...}, {var...}]structure) but sometimes it isn't (like withcore.soil_layers = [-0.25, -1.0]).So we can fix this by testing if
itemis a dictionary and only attempting to recursively resolve actual dictionaries and not random floats.However that reveals another problem with the failing code in #884:
_resolve_config_pathsresolves paths relative to theve_runexecution directory to make sure that paths referred to in config files with different locations are conserved when those configs are merged. That is fine for making sure all paths are congruent during the actual run, but if the run outputs the compiled configuration, that file may very well not be in the execution directory. In fact, the example run doesn't put it there and generally you don't want it to be - it should go in some nice directory of curated configurations. So the file then contains relative links that are relative to an unknown previous execution directory.There are potentially ways to update the paths to give relative paths from the output directory but that doesn't look well supported until
Path(..., walk_up=True)in Python 3.12 and even then I'm not sure how well it works.So, this PR changes
_resolve_config_pathsto convert everything to absolute paths. This is actually more robust (@dalonsoa noted issues with relative paths and drives on Windows) and works just fine - the main issue is that the resulting merged configuration output is tied to the file system on the execution machine.In this PR I've also:
virtual_ecosystem.__init__.pyto mute all of thepyrealmexperimental warnings.vr_*tove_*Fixes #844
Fixes #808
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks