Normalise country/ni and country/northern_ireland before the economy cache lookup
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 policyengine_api/services/economy_service.py 开始,阅读 _with_normalized_region,并结合 constants.py 中的 _setup_region 和 UK_REGION_REGISTRY_CODES,了解缓存键和模拟负载如何使用地区名称。添加所要求的测试,证明北爱尔兰的两种名称会解析到同一个缓存键,同时确保已保存的记录和现有 URL 继续正常工作;测试通过且两个请求共享同一个缓存条目即为完成。
由索引模型根据 Issue 内容生成。
描述
Problem
A UK request for Northern Ireland can arrive as country/ni (the UK metadata name, which the app sends) or as country/northern_ireland (the name in policyengine.py's UK region registry). The API maps the name only when it builds the simulation API payload, in EconomyService._setup_region (policyengine_api/services/economy_service.py, via UK_REGION_REGISTRY_CODES in constants.py). _with_normalized_region normalises US regions only, so the economy cache key is built from the region as requested.
As a result, the same Northern Ireland run (national or breakdown=local_areas) gets two cache entries and can be computed twice, once for each name. This came up in the review of #4024 (point 2).
Impact
Small today: the app always sends country/ni. It matters for any client that uses the registry name, and it doubles the cost of a Northern Ireland run when both names are used.
Proposed fix
Normalise UK regions before the cache lookup, in the same place as the US normalisation: map country/northern_ireland to one canonical name (or map both to the registry name), so both names share one cache entry. Keep saved records and existing URLs working. Add a test that both names resolve to the same cache key.
🤖 Generated with Claude Code
- 主要语言
- Python
- 星标
- 18
- 派生
- 33
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 53
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine-api 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
PolicyEngine/policyengine-api#3911 ·
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
PolicyEngine/policyengine-api#3910 ·
维护者通常 3 天内回复
-
Return a 400 for economy years the simulation service's model cannot project可能已有人在做 @anth-volk 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
PolicyEngine/policyengine-api#4093 ·
维护者通常 3 天内回复
-
Document UK breakdown results' withheld area codes, and stop serving breakdowns cached without them可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 43/100
PolicyEngine/policyengine-api#4091 ·
维护者通常 3 天内回复
-
Telemetry error report splits a simulation worker failure between its exception and the recorded copy可能已有人在做 @anth-volk 于 1 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 20/100
PolicyEngine/policyengine-api#4088 ·
维护者通常 3 天内回复
查看 PolicyEngine/policyengine-api 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
MIT-LCP/wfdb-python#590 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
pollen-robotics/reachy_mini#1517 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
NRLMMD-GEOIPS/pluginify#41 ·
-
难度 2/5 1-3 小时 新手友好度 67/100
scverse/spatialdata#1293 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
UKGovernmentBEIS/inspect_evals#2788 ·
维护者通常 1 天内回复