Retire patching in __init__ testing#1223
Conversation
… 1221-retire-patching-in-init-testing
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1223 +/- ##
===========================================
- Coverage 95.05% 95.04% -0.01%
===========================================
Files 71 71
Lines 7293 7292 -1
===========================================
- Hits 6932 6931 -1
Misses 361 361 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… 1221-retire-patching-in-init-testing
|
Oh super. A heisenbug. 👿 Stochastic failures of |
This turned out to be an issue with variable requirements and the model initialisation order sequencing: There's an issue with the variable config on the Hydrology and Abiotic models. The hydrology model populates these four variables when it initialises (they are in
The abiotic model then has the same variables in This is a problem because - at the moment - those variables aren't in This feels like a hack to me - those variables aren't really required for init. I think the issue is that one model populates the variables and another updates them, and I don't think the static model update variable checking anticipated that possibility. |
vgro
left a comment
There was a problem hiding this comment.
LGTM.
I wonder if the weird behavior could be resolved by moving the initialisation of variables between the models, but I think for now this does the job.
jacobcook1995
left a comment
There was a problem hiding this comment.
LGTM (with one minor comment)!
Description
@vgro and @jacobcook1995
Your models both used the
patchroutines in testing - I've summarised the changes needed for each set of tests below. If you could have a look and see that it makes sense?Abiotic
test_abiotic_model.pyAbioticModel()soil_temperaturedata array from an empty template inAbioticModel._setup(). The variable is populated with real data by a later function.AbioticSimpleModel.vars_required_for_init. These aren't strictly used by the model but this is currently the only way to stop the static model checking from freezing up: see the comment belowAbiotic simple
test_abiotic_simple_model.pyAbioticSimpleModel()AbioticSimpleModel.vars_required_for_initAbioticSimpleModel.vars_required_for_updateHydrology
fixture_hydrology_init_data, now used intest_hydrology_model.pycallsHydrologyModel()HydrologyModel.vars_required_for_initLitter
fixture_litter_init_data, now used infixture_litter_modelandtest_litter_model.pycallsLitterModel()Soil model
fixture_soil_modelFixes #1221
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks