Skip to content

Conversation

@garobrik
Copy link
Member

@garobrik garobrik commented Jul 30, 2025

Description

Add snapshot tests, which capture the exact output of the soil ID algorithm at a commit and compare it to new output when the code changes.

Checklist

  • Corresponding issue has been opened
  • New tests added

Related Issues

Fixes #297

Verification steps

Snapshot tests should pass in CI.

garobrik and others added 6 commits September 18, 2025 16:39
- Add ORDER BY clauses to all critical SQL queries to ensure consistent row ordering
  * soil_id/db.py: get_hwsd2_profile_data, get_WRB_descriptions queries
  * soil_id/utils.py: muhorzdataQry, mucompdataQry queries
  * soil_id/us_soil.py: ESDcompdataQry query
- Fix conditional probability sorting with stable tie-breakers in utils.py
- Change groupby operations from sort=False to sort=True for deterministic grouping
- Add defensive checks in soil_sim.py to handle missing groups gracefully
- Fix component naming logic to properly handle duplicate soil names

These changes ensure the algorithm produces identical results across multiple runs for the same geographic location, resolving snapshot test failures caused by inconsistent soil component ordering and selection.

Fixes non-deterministic issues in:
- Global soil identification (Afghanistan, Kenya, Philippines test locations)
- US soil identification (Washington, Oregon test locations)
- Soil simulation and ranking algorithms

Database queries now return rows in predictable order, eliminating race conditions that caused different soil types to be selected between algorithm runs.
@garobrik garobrik merged commit e85afc6 into main Sep 19, 2025
4 checks passed
@garobrik garobrik deleted the feat/snapshot-tests branch September 19, 2025 00:27
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.

feat: snapshot tests for main algorithm output

3 participants