Skip to content

[Cross Validation] Added cross validation rules for the SC module#2916

Open
matthew7838 wants to merge 43 commits intodevfrom
crop-field-xvalidation
Open

[Cross Validation] Added cross validation rules for the SC module#2916
matthew7838 wants to merge 43 commits intodevfrom
crop-field-xvalidation

Conversation

@matthew7838
Copy link
Copy Markdown
Collaborator

@matthew7838 matthew7838 commented Mar 31, 2026

Added cross-validation rules for the Crop and Soil module.

Context

Issue(s) closed by this pull request: closes #2885 #2886

What

  • Added rules in two files, crop_and_soil_cross_validation.json and field_cross_validation.json.
  • Added extra function in DataValidator called _evaluate_equal_data_length to check the length of list-type inputs.
  • Updated the unit tests, and fixed current failing tests on dev.

Why

We currently lacks module specific cross validation rules.

How

Added the rules and the function that are general enough.

Test plan

  • Run with updated unit tests.
  • Run with the new cross-validation files.

Input Changes

Output Changes

  • N/A

Filter

@github-actions
Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on crop-field-xvalidation branch: 1195
Mypy errors on dev branch: 1195
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

🚨 Please update the changelog. This PR cannot be merged until changelog.md is updated.
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

@matthew7838 matthew7838 self-assigned this Apr 1, 2026
@github-actions github-actions bot force-pushed the crop-field-xvalidation branch from 3d4371d to 040785d Compare April 6, 2026 06:42
@github-actions github-actions bot force-pushed the crop-field-xvalidation branch from 040785d to c8ecd97 Compare April 6, 2026 06:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Current Coverage: %

Mypy errors on crop-field-xvalidation branch: 1205
Mypy errors on dev branch: 1205
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

🚨 Please update the changelog. This PR cannot be merged until changelog.md is updated.
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.
🚨 Flake8 linting errors were found. Please fix the linting issues.
🚨 Some tests have failed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Current Coverage: %

Mypy errors on crop-field-xvalidation branch: 1205
Mypy errors on dev branch: 1205
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

🚨 Please update the changelog. This PR cannot be merged until changelog.md is updated.
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.
🚨 Flake8 linting errors were found. Please fix the linting issues.
🚨 Some tests have failed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Current Coverage: %

Mypy errors on crop-field-xvalidation branch: 1205
Mypy errors on dev branch: 1205
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

🚨 Please update the changelog. This PR cannot be merged until changelog.md is updated.
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.
🚨 Flake8 linting errors were found. Please fix the linting issues.
🚨 Some tests have failed.

Copy link
Copy Markdown
Collaborator

@allisterakun allisterakun left a comment

Choose a reason for hiding this comment

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

Great job, Matthew! All these rules are valid, but I have just added some suggestions for improvements.

Comment thread input/metadata/cross_validation/crop_and_soil_cross_validation.json Outdated
Comment thread input/metadata/cross_validation/crop_and_soil_cross_validation.json Outdated
Comment thread input/metadata/cross_validation/field_cross_validation.json Outdated
Comment thread input/metadata/cross_validation/field_cross_validation.json Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Current Coverage: 99%

Mypy errors on crop-field-xvalidation branch: 1191
Mypy errors on dev branch: 1191
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Current Coverage: %

Mypy errors on crop-field-xvalidation branch: 1191
Mypy errors on dev branch: 1191
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.
🚨 Some tests have failed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Current Coverage: 99%

Mypy errors on crop-field-xvalidation branch: 1191
Mypy errors on dev branch: 1191
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.
🚨 Flake8 linting errors were found. Please fix the linting issues.

"description": "alfalfa_silage temperature and harvest index bounds",
"target_and_save": {
"variables": {
"alfalfa_silage_minimum_temperature": "crop_configurations.crop_configurations.0.minimum_temperature",
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.

We do something like this with at least one of the animal-related cv rules and I think basing a rule on the specific index of an item within a list seems really unreliable and problematic and hard to accommodate for new users setting up their own crop config files or even tweaking the example one. I think #2700 could hopefully help with something like this because really this rule is specific to alfalfa silage, not crop config item 0.

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.

Do you think we should merge this first and come back to fix it when #2700 is done? Or should we wait for it?

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.

Maybe we can discuss at WT today

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.

I actually think the way this should be done is to refactor the input file (and of course then the way the input file is processed/read by both IM and in the C&S module) to be a dict of dicts with crop_name as the key:

e.g.

{
  "crop_configurations": {
    "alfalfa_silage": {
      "plant_category": "perennial_legume",
      "is_nitrogen_fixer": true,
      ...
    },
    "alfalfa_baleage": {
      "plant_category": "perennial_legume",
      "is_nitrogen_fixer": true,
      ...
    }
  }
}

This would prevent accidental duplication and make these rules more concrete. We can discuss at WT but just wanted to share my initial thoughts. This would likely need to be a separate issue since it would involve changes in the metadata and in how this data is processed in C&S module.

@github-actions github-actions bot force-pushed the crop-field-xvalidation branch from d69ba2b to 9a99a5a Compare April 7, 2026 13:45
@github-actions github-actions bot force-pushed the crop-field-xvalidation branch from 9a99a5a to 516e03a Compare April 7, 2026 13:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Current Coverage: 99%

Mypy errors on crop-field-xvalidation branch: 1191
Mypy errors on dev branch: 1191
No difference in error counts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

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.

[XV] Compose CrossValidation Rules for Crop Data

4 participants