Skip to content

Take in soil enzyme parameterisation as csv rather than toml - #1947

Merged
Jacob Cook (jacobcook1995) merged 9 commits into
1928-not-providing-parameterisation-for-soil-microbial-groups-and-enzymes-doesnt-result-in-a-configuration-errorfrom
1541-convert-soil-enzyme-inputs-to-csv-format-rather-than-toml
Oct 27, 2026
Merged

Jacob Cook (jacobcook1995) merged 9 commits into
1928-not-providing-parameterisation-for-soil-microbial-groups-and-enzymes-doesnt-result-in-a-configuration-errorfrom
1541-convert-soil-enzyme-inputs-to-csv-format-rather-than-toml

Conversation

@jacobcook1995

@jacobcook1995 Jacob Cook (jacobcook1995) commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR changes the way that soil enzyme classes are produced. Instead of being generated directly from the configuration, a path to a csv file is provided. This CSV file is then used in model setup to create multiple instances of SoilEnzymeClass.

Lai Hao Ran (@hrlai), I've just put down David as a reviewer for this PR as I mainly need feedback on the code at the moment. I'll put you down as a reviewer for the overall feature branch when that is being merged to main (because when that happens the input data will need to change)

Fixes #1541

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
  • If this PR changes the expected model inputs, are the relevant people from the
    data science team included as reviewers?

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.07519% with 93 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (1928-not-providing-parameterisation-for-soil-microbial-groups-and-enzymes-doesnt-result-in-a-configuration-error@42b3dde). Learn more about missing BASE report.

Files with missing lines Patch % Lines
virtual_ecosystem/models/soil/functional_groups.py 0.00% 86 Missing ⚠️
...ation_scripts/microbial_parametrisation_example.py 0.00% 7 Missing ⚠️
Additional details and impacted files
@@                                                                 Coverage Diff                                                                 @@
##             1928-not-providing-parameterisation-for-soil-microbial-groups-and-enzymes-doesnt-result-in-a-configuration-error    #1947   +/-   ##
===================================================================================================================================================
  Coverage                                                                                                                    ?   88.91%           
===================================================================================================================================================
  Files                                                                                                                       ?       85           
  Lines                                                                                                                       ?     9637           
  Branches                                                                                                                    ?        0           
===================================================================================================================================================
  Hits                                                                                                                        ?     8569           
  Misses                                                                                                                      ?     1068           
  Partials                                                                                                                    ?        0           

☔ View full report in Codecov by Harness.
📢 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

David Orme (davidorme) commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Jacob Cook (@jacobcook1995) I haven't looked in detail - nothing alarming but I think it would be more robust to make more direct use of the existing pydantic models and validation. I've pushed a module showing what I mean - my feeling is that things are more DRY using this structure and it allows the pydantic validation to handle loading and validation errors.

I haven't been through to try and get parity of all the checks with your new code - thought it was worth checking which direction to take it first.

ETA

  • I also have made no attempt at testing except that load_enzymes works with your new example file.
  • Also, the enzyme and microbe classes can be removed from model_config.py
  • The default settings on these classes forbid extra fields. I'd honestly stick with that - if you think it's worth warning, just forbid it?

@jacobcook1995

Copy link
Copy Markdown
Collaborator Author

Jacob Cook (Jacob Cook (@jacobcook1995)) I haven't looked in detail - nothing alarming but I think it would be more robust to make more direct use of the existing pydantic models and validation. I've pushed a module showing what I mean - my feeling is that things are more DRY using this structure and it allows the pydantic validation to handle loading and validation errors.

I haven't been through to try and get parity of all the checks with your new code - thought it was worth checking which direction to take it first.

Yes that is a lot cleaner, thanks! I'll work on integrating it into the main model flow now

@jacobcook1995
Jacob Cook (jacobcook1995) merged commit 7d2f811 into 1928-not-providing-parameterisation-for-soil-microbial-groups-and-enzymes-doesnt-result-in-a-configuration-error Oct 27, 2026
13 checks passed
@jacobcook1995
Jacob Cook (jacobcook1995) deleted the 1541-convert-soil-enzyme-inputs-to-csv-format-rather-than-toml branch October 27, 2026 14:28
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.

3 participants