Skip to content

[Cross Validation]Implement cross validation rules for daily spread inputs - #3168

Open
matthew7838 wants to merge 9 commits into
devfrom
daily-spread-cross-validation-3097
Open

[Cross Validation]Implement cross validation rules for daily spread inputs#3168
matthew7838 wants to merge 9 commits into
devfrom
daily-spread-cross-validation-3097

Conversation

@matthew7838

@matthew7838 matthew7838 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Adds cross-validation rules for the manure schedule daily_spread block 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

  • Eight new blocks in input/metadata/cross_validation/crop_and_soil_cross_validation.json, four rules written once for manure_schedule_1 and once for manure_schedule_2, matching how the existing field_1/field_2 and soil_1/soil_2 rules in that file are duplicated:
    • Daily spreading requires a DailySpread storage. When a schedule has daily_spread.is_daily_spreading: true, manure_management.storage must contain at least one entry with processor_type: "DailySpread".
    • spread_all_available_manure requires the master switch. When spread_all_available_manure is true, is_daily_spreading must also be true.
    • A targeted daily spread must request something. When is_daily_spreading is true and spread_all_available_manure is false, nitrogen_spread_amount + phosphorus_spread_amount must be greater than zero.
  • Daily spread manure must be solid. When is_daily_spreading is true, manure_type must be "solid".
  • Sets manure_type to "solid" in input/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

  • Go into the issue and modify the inputs to match the four cases and see if errors were thrown.

Input Changes

  • N/A

Output Changes

  • N/A

Filter

@matthew7838 matthew7838 self-assigned this Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on daily-spread-cross-validation-3097 branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on daily-spread-cross-validation-3097 branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on daily-spread-cross-validation-3097 branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@matthew7838
matthew7838 marked this pull request as ready for review July 28, 2026 17:05
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on daily-spread-cross-validation-3097 branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on daily-spread-cross-validation-3097 branch: 1135
Mypy errors on dev branch: 1135
No difference in error counts

]
},
{
"description": "manure_schedule_1 daily spread nitrogen or phosphorus spread amount must be greater than zero when spread_all_available_manure is false",

@elle-andreen elle-andreen Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the information reported to the user in the errors when the inputs violate the CV rules?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes

]
},
{
"description": "manure_schedule_1 daily spread manure_type must be solid because DailySpread storages hold solid manure",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: %

Mypy errors on daily-spread-cross-validation-3097 branch: 1135
Mypy errors on dev branch: 1135
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Some tests have failed.

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.

[Cross Validation][Crop and Soil] Implement new cross validations rules related to the additional daily spread manure schedule inputs

2 participants