[Cross Validation]Implement cross validation rules for daily spread inputs - #3168
[Cross Validation]Implement cross validation rules for daily spread inputs#3168matthew7838 wants to merge 9 commits into
Conversation
|
Current Coverage: 99% Mypy errors on daily-spread-cross-validation-3097 branch: 1136 |
1 similar comment
|
Current Coverage: 99% Mypy errors on daily-spread-cross-validation-3097 branch: 1136 |
|
Current Coverage: 99% Mypy errors on daily-spread-cross-validation-3097 branch: 1136 |
|
Current Coverage: 99% Mypy errors on daily-spread-cross-validation-3097 branch: 1136 |
|
Current Coverage: 99% Mypy errors on daily-spread-cross-validation-3097 branch: 1135 |
| ] | ||
| }, | ||
| { | ||
| "description": "manure_schedule_1 daily spread nitrogen or phosphorus spread amount must be greater than zero when spread_all_available_manure is false", |
There was a problem hiding this comment.
Is this the information reported to the user in the errors when the inputs violate the CV rules?
| ] | ||
| }, | ||
| { | ||
| "description": "manure_schedule_1 daily spread manure_type must be solid because DailySpread storages hold solid manure", |
There was a problem hiding this comment.
Is this an actual rule in the code? Will the simulation fail if the user sets the manure type in the daily spread inputs to liquid? If so, it's a bit confusing that we offer an input for manure type but don't actually accept any user input for it i.e. require manure type to be solid
There was a problem hiding this comment.
Well, the type is actually hard-coded in the code anyway. I am thinking that maybe we don't even have to specify manure type for daily spread.
There was a problem hiding this comment.
Looking back in our Slack conversations, Kristan and Clay's original intention was to let the user specify which type of manure the daily spread manure is (liquid or solid). Either option is ostensibly possible in reality and I believe the liquid vs. solid manure designation has some impacts on manure nutrient outcomes in C&S. I know in every other manure processor type, the user does not make this liquid vs. solid specification though, it is set based on what type of processor the manure came from, and I see DailySpread is hardcoded to ManureType.SOLID in ManureManager. I think this might've been something we missed in the original implementation that we should open a small, separate issue for (assuming it's mechanistically possible to set ManureType via user input). I can open the issue. The good news is it shouldn't hold up this PR - I think there is no CV required on the manure_type input for daily spread given that it can be either liquid or solid.
|
Current Coverage: % Mypy errors on daily-spread-cross-validation-3097 branch: 1135 |
|
🚨 Some tests have failed. |
Adds cross-validation rules for the manure schedule
daily_spreadblock so configurations that turn daily spreading on but silently apply no manure are rejected at input validation instead of running to completion with no manure applied.Context
Issue(s) closed by this pull request: closes #3097
What
input/metadata/cross_validation/crop_and_soil_cross_validation.json, four rules written once formanure_schedule_1and once formanure_schedule_2, matching how the existingfield_1/field_2andsoil_1/soil_2rules in that file are duplicated:daily_spread.is_daily_spreading: true,manure_management.storagemust contain at least one entry withprocessor_type: "DailySpread".spread_all_available_manurerequires the master switch. Whenspread_all_available_manureis true,is_daily_spreadingmust also be true.is_daily_spreadingis true andspread_all_available_manureis false,nitrogen_spread_amount + phosphorus_spread_amountmust be greater than zero.is_daily_spreadingis true,manure_typemust be"solid".manure_typeto"solid"ininput/data/manure_schedule/example_daily_spread_manure_schedule.json, which previously demonstrated the exact configuration the manure type rule now rejects.Why
Each of the four is a real misconfiguration that passes per-field schema validation today and produces a silent no-op, which is difficult to diagnose from the outputs because the run completes normally and simply shows no manure applied.
How
Each block pairs an apply_when clause that narrows it to the configuration under test with a single asserting condition, except the DailySpread storage check, which puts the constant on the left and a for_each filter on the right under is_in because the engine has no list-length operator.
Test plan
Input Changes
Output Changes
Filter