Skip to content

feat(prototypes): read the latest debt view entirely through the DFO - #152

Merged
jm-rivera merged 1 commit into
devfrom
feat/prototype-debt-dfo-reads
Nov 16, 2026
Merged

jm-rivera merged 1 commit into
devfrom
feat/prototype-debt-dfo-reads

Conversation

@jm-rivera

Copy link
Copy Markdown
Contributor

The 2025 view of the debt-thresholds prototype now reads all its IDS data through the DFO. It previously took China's official split, IMF repurchases after the base year, private service, lending terms and concessionality from the World Bank's bulk files, although the DFO holds every one of them. The 2024 view still reads the archived December 2025 bulk files, since the DFO holds only the current release.

Changes

  • _data/pipeline/sources/pinned_specs.json gains 16 readings, each found by its IDS code: disbursements by creditor and bilateral service, principal and disbursements by creditor (for China's part), DT.AMT.DIMF.CD with the IMF as creditor (repurchases to 2031), DT.TDS.PRVT.CD, the eight terms series (DT.INR, DT.MAT, DT.GPA, DT.COM, official and private), DT.DOD.ALLC.CD and DT.GRE.DPPG. dfo_api.py maps them through DFO_KEYS and CHINA_KEYS; imf_flows now supplies only IMF disbursements.
  • run.py reads the 2025 view from fetch_dfo alone. merge_panels and cross_check go, along with the cross-check line in coverage.md.
  • config.py: a view with no ids_dir reads IDS through the DFO, and use_dfo is a property derived from it. release_dir goes.
  • panel.py adds check_actuals, the release check both sources now run: check_release for the bulk files, and fetch_dfo for the DFO.
  • valuation.py weights each year's grant element by its commitments (DT.COM.OFFT.CD plus DT.COM.PRVT.CD).
  • Data regenerated.

Notes for reviewers

  • With the bulk fill still in place, the DFO readings reproduced every output exactly. Dropping the fill exposed two gaps, both now closed. The imf_flows reading stops its repurchases at 2025, which is why DT.AMT.DIMF.CD is now pinned on its own. Private service was missing too, which made the creditor guard fail.
  • The bulk files report a grant element of 0 in years without new loans, and the DFO leaves those years out, so a simple mean differed between the two sources. Weighting by commitments gives both the same answer. It moves debtPV slightly for 58 countries in each view but changes no group: 7, 20 and 31 in 2025, and 54 of 58 matching FDL on 2024 data.
  • inputs.json data is unchanged. Its diff, and most of thresholds.json's, is provenance for the 16 new readings.

Testing: uvx --with pytest pytest tests (81 passed), ruff, ty check, pnpm test (31 passed), pnpm typecheck and pnpm check:data clean. Full data runs compared to the committed outputs at each step.

The 2025 view took China's official split, IMF repurchases after the
base year, private service, lending terms and concessionality from the
IDS bulk files, which the DFO holds as well. Sixteen more pinned
readings now carry them, so the 2025 view downloads no bulk files and
the DFO-against-bulk cross-check goes. The 2024 view still reads the
archived December 2025 files, which the DFO no longer holds.

Both sources share one release check, check_actuals in panel.py. The
grant element in present_value is now weighted by each year's
commitments: the bulk files report 0 in years without loans and the
DFO leaves those years out, and the weighting treats both alike. No
country changes group, and the 2024 rebuild still matches FDL for 54
of 58.
@jm-rivera
jm-rivera merged commit 0fd1e7c into dev Nov 16, 2026
8 checks passed
@jm-rivera
jm-rivera deleted the feat/prototype-debt-dfo-reads branch November 16, 2026 23:03
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.

1 participant