Skip to content

Use parent-keyed admin name mappings whatever the p-code's parent - #95

Merged
mcarans merged 1 commit into
mainfrom
parent_keyed_mappings
Sep 29, 2026
Merged

mcarans merged 1 commit into
mainfrom
parent_keyed_mappings

Conversation

@mcarans

@mcarans mcarans commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

AdminLevel.get_pcode ignored a mapping keyed by parent (eg. "ET07|Dawuro": "ET1104") unless the mapped p-code's parent equalled the key's parent. Such a mapping could not send a name listed under a pre-split region to its current p-code.

Now a parent-keyed mapping is used whatever the p-code's parent. Country ("ETH|...") and global mappings still require the p-code's parent to match the given parent.

Motivation

hdx-scraper-ipc: since hdx-python-pipelineutils 0.0.7, IPC "SNNP" exact matches ET07 as parent, so "Dawuro" (ET1104, under ET11 South West Ethiopia) goes unmatched (44 rows, 2020–21). With this change, "ET07|Dawuro": "ET1104" restores ET11/ET1104 (checked against IPC's test data: only those 44 rows change).

Existing configs affected

Across OCHA-DAP repos, the only parent-keyed mappings whose p-code is outside the key's parent are 8 in hapi-pipelines and hapi-pipelines-backup configs/core.yaml (eg. "ET07|SIDAMA": "ET1600", "TZ12|Mbozi": "TZ2606"). They have been ignored since they were added (2024-05-31, after the parent check in #42). The current hapi-pipelines does no name-based p-code lookups, and hapi-pipelines-backup cannot install country 4.2.x, so neither output changes.

Changes

  • adminlevel.py: parent-keyed mapping checked first in get_pcode
  • Test fixture "AF05|MyMapping4": "AF0401" and assertions
  • documentation/index.md: mapping rule described

A mapping keyed by parent (eg. "ET07|Dawuro": "ET1104") was ignored
unless the mapped p-code's parent equalled the key's parent, so it could
not map a name listed under a pre-split region to its current p-code.
Country and global mappings still require the parent to match.
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Test Results

36 tests  ±0   36 ✅ ±0   1m 19s ⏱️ -3s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 6530ed7. ± Comparison against base commit 1a91997.

♻️ This comment has been updated with latest results.

@coveralls

coveralls commented Sep 29, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 95.792% (+0.01%) from 95.779% — parent_keyed_mappings into main

@mcarans
mcarans merged commit c2a9c84 into main Sep 29, 2026
6 checks passed
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