You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lsms_library/harmony.py is a CLI cross-country consistency check that predates the Country API. It directly reads the legacy var/food_expenditures.parquet, var/food_prices.parquet, and var/household_characteristics.parquet for a given country, then uses local_tools.add_markets_from_other_features (whose only call site is harmony.py itself) to attach a market index via the obsolete other_features infrastructure (per CLAUDE.md).
Verified zero callers anywhere in the repo: notebooks, tests, scripts, docs, makefiles all clean. The helper it imports (add_markets_from_other_features) is similarly orphan.
Cascade
The legacy parquets harmony reads are produced by per-country food_prices_quantities_and_expenditures.py scripts. They currently exist in 12 countries: Afghanistan, Burkina_Faso, Cambodia, CotedIvoire, Ethiopia, GhanaLSS, GhanaSPS, Guatemala, Malawi, Panama, Senegal, Tanzania.
For 11 of these, the framework's _FOOD_DERIVED path in country.py:2541-2571 shadows the legacy outputs — Country(X).food_expenditures() / .food_prices() / .food_quantities() derive from food_acquired via transformations.food_*_from_acquired rather than reading the legacy parquets. The legacy script's outputs are written but never read by the Country API.
Uganda is the exception: derivation fails because food_acquired lacks a single Expenditure column (split into value_home/away/own/inkind). Per CLAUDE.md, blocked on #169 (canonical food_acquired columns).
Proposed direction
Modern equivalent of harmony's checks, Country-API-based. Sketch:
Country(X).consistency_check() (or top-level lsms_library.harmony.audit(country)) calls Country(X).food_expenditures(), .food_prices(), .household_characteristics(), runs the same index-orientation / market-attachment / label-overlap assertions, raises clearly on failure.
All inputs go through _finalize_result (kinship expansion, canonical spelling, id_walk), so the audit operates on the canonical API form rather than the raw legacy parquet form.
Once the modern equivalent exists, retire the per-country food_prices_quantities_and_expenditures.py (12 files, ~290 lines), the corresponding Makefile rules, the orphan local_tools.add_markets_from_other_features helper, and lsms_library/harmony.py itself. Leave Uganda alone until Design: food_acquired canonical columns (+ cascade to food_prices, food_quantities) #169 lands.
First step
A linked PR does Phase 1 for Malawi only — removes Malawi's instance of the legacy script (whose outputs are already shadowed), trims dead helpers in Malawi/_/malawi.py, and updates the Makefile / CONTENTS.org accordingly. Treats Malawi as the proof-of-concept for the cross-country pattern.
Background
lsms_library/harmony.pyis a CLI cross-country consistency check that predates the Country API. It directly reads the legacyvar/food_expenditures.parquet,var/food_prices.parquet, andvar/household_characteristics.parquetfor a given country, then useslocal_tools.add_markets_from_other_features(whose only call site isharmony.pyitself) to attach a market index via the obsoleteother_featuresinfrastructure (per CLAUDE.md).Verified zero callers anywhere in the repo: notebooks, tests, scripts, docs, makefiles all clean. The helper it imports (
add_markets_from_other_features) is similarly orphan.Cascade
The legacy parquets
harmonyreads are produced by per-countryfood_prices_quantities_and_expenditures.pyscripts. They currently exist in 12 countries: Afghanistan, Burkina_Faso, Cambodia, CotedIvoire, Ethiopia, GhanaLSS, GhanaSPS, Guatemala, Malawi, Panama, Senegal, Tanzania.For 11 of these, the framework's
_FOOD_DERIVEDpath incountry.py:2541-2571shadows the legacy outputs —Country(X).food_expenditures()/.food_prices()/.food_quantities()derive fromfood_acquiredviatransformations.food_*_from_acquiredrather than reading the legacy parquets. The legacy script's outputs are written but never read by the Country API.Uganda is the exception: derivation fails because
food_acquiredlacks a singleExpenditurecolumn (split intovalue_home/away/own/inkind). Per CLAUDE.md, blocked on #169 (canonical food_acquired columns).Proposed direction
Country(X).consistency_check()(or top-levellsms_library.harmony.audit(country)) callsCountry(X).food_expenditures(),.food_prices(),.household_characteristics(), runs the same index-orientation / market-attachment / label-overlap assertions, raises clearly on failure._finalize_result(kinship expansion, canonical spelling,id_walk), so the audit operates on the canonical API form rather than the raw legacy parquet form.food_prices_quantities_and_expenditures.py(12 files, ~290 lines), the corresponding Makefile rules, the orphanlocal_tools.add_markets_from_other_featureshelper, andlsms_library/harmony.pyitself. Leave Uganda alone until Design: food_acquired canonical columns (+ cascade to food_prices, food_quantities) #169 lands.First step
A linked PR does Phase 1 for Malawi only — removes Malawi's instance of the legacy script (whose outputs are already shadowed), trims dead helpers in
Malawi/_/malawi.py, and updates the Makefile / CONTENTS.org accordingly. Treats Malawi as the proof-of-concept for the cross-country pattern.Related