Skip to content

feat(farmer_demo): seed large commercial farm with idle land for CEL demo (#1119) - #323

Open
emjay0921 wants to merge 4 commits into
19.0from
fix/1119-seed-large-idle-farm
Open

feat(farmer_demo): seed large commercial farm with idle land for CEL demo (#1119)#323
emjay0921 wants to merge 4 commits into
19.0from
fix/1119-seed-large-idle-farm

Conversation

@emjay0921

Copy link
Copy Markdown
Contributor

Why is this change needed?

Docs Scenario 5 (Climate Resilience) STEP 4 contrasts the qualifying smallholder against EC1 — a large commercial farm (50 ha, idle) to show the CEL r.is_group == true and is_smallholder and farm_size_idle > 0 rejecting it on is_smallholder even though it has idle land. No demo farm had both is_smallholder = False (size above the 5 ha threshold) and farm_size_idle > 0, so this exclusion couldn't be demonstrated (OP#1119).

How was the change implemented?

  • Added blueprint bp_22_ec1_large_commercial_idle to FARMER_BLUEPRINTS: a 50 ha crop farm (count: 1) with idle_pct: 0.1 (≈5 ha fallow) and all program eligibility False (it's the deliberate rejection example). 50 ha > 5 ha threshold ⇒ is_smallholder = False, and farm_size_idle > 0.
  • The blueprint generator already supports idle_pct, so no generator changes were needed. EC1 is volume-generated, matching the docs (USE_CASES Story 9 / EC1).

New unit tests

  • test_1119_ec1_large_commercial_not_smallholder_with_idle — generates the EC1 blueprint and asserts farm_total_size > smallholder threshold, is_smallholder == False, and farm_size_idle > 0.

Unit tests executed by the author

spp_farmer_registry_demo suite: 0 failed, 0 error(s) of 133 tests (fresh DB, --stop-after-init). The ~730 farm-count range tests remain green with the +1 farm.

How to test manually

  1. Run the farmer demo data generator (with volume farms enabled).
  2. Registry → Groups, filter/sort by farm size → open the 50 ha farm (EC1): confirm not a smallholder and idle/fallow land > 0.
  3. Open Programs → Climate Resilience → Eligibility and confirm this farm is not eligible (fails is_smallholder), while a smallholder with idle land qualifies.

Related links

https://projects.acn.fr/work_packages/1119

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.78%. Comparing base (8532fa4) to head (e3452d8).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #323      +/-   ##
==========================================
- Coverage   72.24%   66.78%   -5.46%     
==========================================
  Files         419      100     -319     
  Lines       29813     9789   -20024     
==========================================
- Hits        21539     6538   -15001     
+ Misses       8274     3251    -5023     
Flag Coverage Δ
spp_analytics ?
spp_api_v2_change_request ?
spp_api_v2_cycles ?
spp_api_v2_data ?
spp_api_v2_entitlements ?
spp_api_v2_gis ?
spp_api_v2_programs ?
spp_api_v2_service_points ?
spp_attachment_av_scan ?
spp_base_common 91.07% <ø> (ø)
spp_change_request_v2 ?
spp_claim_169 ?
spp_cr_type_assign_program ?
spp_dci ?
spp_dci_client ?
spp_dci_client_compliance ?
spp_dci_client_crvs ?
spp_dci_client_dr ?
spp_dci_demo ?
spp_drims ?
spp_drims_sl_demo ?
spp_farmer_registry_cr ?
spp_farmer_registry_demo 61.06% <ø> (ø)
spp_grm_cel ?
spp_key_management ?
spp_mis_demo_v2 ?
spp_oauth ?
spp_programs 65.27% <ø> (ø)
spp_registry 87.22% <ø> (+0.07%) ⬆️
spp_security 69.56% <ø> (ø)
spp_starter_sp_mis ?
spp_studio_change_requests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...p_farmer_registry_demo/models/farmer_blueprints.py 100.00% <ø> (ø)

... and 320 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emjay0921
emjay0921 marked this pull request as draft July 27, 2026 08:27
@emjay0921
emjay0921 marked this pull request as ready for review August 13, 2026 05:41

@gonzalesedwin1123 gonzalesedwin1123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean, minimal, and it delivers exactly what the docs promised. What I verified:

  • idle_pct is a supported blueprint key (seeded_farm_generator.py:449), already used by two existing blueprints — so "no generator changes needed" is true.
  • The test's threshold lookup (spp.farmer.smallholder_threshold, default "5.0") exactly mirrors the real is_smallholder compute (spp_farmer_registry/models/farm.py:165), so the test tracks the actual logic rather than a copy of it.
  • docs/USE_CASES.md Story 9 already describes EC1 as implemented here — the data now matches the pre-existing docs, which is the right direction.
  • The test asserts through the real generator (generate_all_farms([ec1])), not the blueprint dict.
  • The blueprint matches its neighbours' schema, and all-False eligibility fits the deliberate rejection example.

Two items:

1. Blocker — version bump

Per the convention Edwin ruled on (see #391): bump + HISTORY in the PR, with the number assigned at merge-time rebase. Note this module now has a three-PR ordering — #412 already carries 19.0.2.1.2, so this and #322 take .3/.4 in whichever order they merge.

2. Minor — the USE_CASES inventory is now stale

docs/USE_CASES.md says "Total blueprints: 21. Total farms: ~730." and its blueprint table has no EC1 row — this PR makes both undercount. Please add the EC1 row and bump the totals (22 / ~731). Small, but that document is the reason this blueprint exists, so it should agree with it.

With those two, this is an approve.

Version bump with its changelog entry, per the convention that bumps land in
the PR. The module now has three PRs in flight, so the concrete number is a
merge-time reconciliation: #412 carries .2, this takes .4 and #322 takes .3.

USE_CASES.md is the document this blueprint exists to serve, and it had no EC1
row while its totals still read 21 blueprints and ~730 farms — both undercounts
as soon as this lands. The row is added and the totals now read 22 and ~731.
@emjay0921

Copy link
Copy Markdown
Contributor Author

Thanks — both done. Pushed as 33045f68.

1. Version bump — 19.0.2.1.4 with its HISTORY line, taking .4 against #412's .2 and #322's .3 as you set out.

2. The stale inventory — fixed. USE_CASES.md now carries an EC1 row in the blueprint table (1 farm, rural, crop, 50 ha, 20–30 years' experience, male head, 2 members) and the totals read 22 blueprints / ~731 farms. You are right that this is the document the blueprint exists to serve, so it disagreeing with the data was the wrong way round.

spp_farmer_registry_demo suite: 133 tests, 0 failed.

#412 landed the same module's 19.0.2.1.2, so the manifest version and the top of
the changelog both conflicted. Resolved by keeping this branch's 19.0.2.1.4 and
both changelog entries, newest first; README.rst and the description page are
generated from readme/, so they were rebuilt rather than merged by hand.
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.

2 participants