Skip to content

Moving soil model to new configuration#1109

Merged
davidorme merged 12 commits intodevelopfrom
1108-move-soils-over-to-the-new-configuration-system
Oct 24, 2025
Merged

Moving soil model to new configuration#1109
davidorme merged 12 commits intodevelopfrom
1108-move-soils-over-to-the-new-configuration-system

Conversation

@davidorme
Copy link
Copy Markdown
Collaborator

@davidorme davidorme commented Oct 23, 2025

Description

This PR:

  • Moves the SoilModel and all of its methods functions etc over to the new configuration classes.
  • Updates the prototype soil.model_config to add docstrings and then move a bunch of validation (ordering of pH values, required enzyme and microbial group classes) out of the model methods and into field and model validators.
  • Moves the find_microbial_stoichiometries helper function over to the animal.cnp module, since it now has access to the full configuration directly and doesn't need soil to look up the data for it.
  • Retires soil.microbial_groups.EnzymeConstants and the make_full_set_of_enzymes completely, since the old dataclass is functionally identical to the new validator class soil.model_config.SoilEnzymeClass and the function is basically identical to the custom validation on that pydantic model. It's basically a straight swap of things that are dict[str, EnzymeConstants] for dict[str, SoilEnzymeClass].

Note

There is similarly a huge amount of overlap between the new validator class soil.model_config.SoilMicrobialGroup and soil.microbial_groups.MicrobialGroupConstants, but that has an extra factory method. I'm sure we can combine the two, but maybe leave this for another day - lets get configuration up and running first.

  • Moves all of the testing over to use the new configuration and model constants. I've added some new fixtures to get constants classes - cuts down on importing the constant classes all the time, since I'd have had to swap SoilConsts to SoilConstants etc. anyway.
  • Retires a couple of model config tests and moves some of their functionality into a couple of additional soil.model_config tests.

Fixes #1108

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

Base automatically changed from 1101-switch-core-over-to-new-configuration to develop October 23, 2025 12:15
@davidorme davidorme linked an issue Oct 23, 2025 that may be closed by this pull request
@davidorme davidorme marked this pull request as ready for review October 23, 2025 22:09
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.63%. Comparing base (e435fbf) to head (eaa3233).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1109      +/-   ##
===========================================
- Coverage    94.64%   94.63%   -0.01%     
===========================================
  Files           90       90              
  Lines         7896     7887       -9     
===========================================
- Hits          7473     7464       -9     
  Misses         423      423              

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

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!

turnover_rate = 2.4e-2
c_n_ratio = 6.5
c_p_ratio = 40.0
""",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very happy for this monstrosity to die

< cls.highest_optimal_pH_microbes
< cls.max_pH_microbes
):
raise ValueError("Microbe pH values not in increasing sequence")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably slightly easier to understand if these are called "thresholds" rather than "values" (apologies if this is just copied directly from something I previously wrote 🫠)

@OpenDev-StockholmUni
Copy link
Copy Markdown

Hi @jacobcook1995, we're researchers from Stockholm University studying communication on GitHub.

A message you posted may come across as rude, disrespectful, or unreasonable — something that could discourage others from contributing or sharing their ideas:

very happy for this monstrosity to die

You can opt out of messages like this here.

If you are the moderator of this repository, you can opt out of messages like this for the entire repo here.

Note

Participate in our four-question survey to provide feedback, and follow us for project updates!


This message was flagged by an automated system and reviewed using an AI tool to check for tone and clarity concerns.

We’re not here to judge. Our goal is to help make collaboration smoother for everyone.

Messages like this can sometimes cause stress or burnout for others involved in the project.

Here are a few quick tips to make messages clearer and easier to engage with:

  • Rephrase strong or absolute language
  • Explain your reasoning, or suggest an alternative
  • Use tools like AI writing assistants to help reword or check tone

Thanks for contributing to GitHub and helping improve collaboration for everyone!

@davidorme davidorme merged commit cad842d into develop Oct 24, 2025
13 checks passed
@davidorme davidorme deleted the 1108-move-soils-over-to-the-new-configuration-system branch October 24, 2025 08:36
@davidorme
Copy link
Copy Markdown
Collaborator Author

@OpenDev-StockholmUni

Interesting. I guess it is a good thing to try and encourage polite discourse on GitHub - lack of moderation is a serious issue in online platforms. Having said that - what's the false positive rate like on what your tool flags? The context here is that @jacobcook1995 is commenting on his own code - without that context it's very difficult to triage comments, particularly such short ones.

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.

Move soils over to the new configuration system

4 participants