Define each country's years once and refuse society-wide requests for other years

Đang mở
#4,211 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@anth-volk đang làm issue này rồi.

Từ ngày 5/11/2026.

  • #4212 của @anth-volk — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
54/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend, databases

Hướng nghiên cứu

Read policyengine_api/country.py, policyengine_api/economy_years.py, and policyengine_api/data/v2/catalog/extraction.py to trace the current year lists, then inspect the economy routes and assert_country_matches to find request validation and catalog publication behavior. Check the existing route and catalog tests before making changes. Done means the shared country year lists drive metadata and extraction, unavailable economy years return 400 with DATASET_YEAR_UNAVAILABLE before stored results or simulation calls, and publication updates only time periods while still rejecting other differences.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

The maintainer decided on 4–5 November 2026 that:

  • US 2022 and 2023 are dropped everywhere. Household and society-wide calculations share one list of years per country, starting in 2024 for the US.
  • Each country's years are defined once, as constants in the Public API: US 2024–2035, UK 2024–2032.
  • A society-wide (economy) request for a year outside its country's list is refused with a 400, including when a result for that year is already stored.
  • Household calculations are not refused; only the menus stop offering those years.

Today the years are defined in three places:

  • /{country}/metadata's economy_options.time_period for the US is a hand-written list in policyengine_api/country.py, 2035 down to 2022.
  • The UK years come from uk_economy_years in policyengine_api/economy_years.py, from the installed policyengine-uk's projection end.
  • The v2 catalog has its own copy, METADATA_TIME_PERIODS in policyengine_api/data/v2/catalog/extraction.py: US 2035 to 2022, and UK 2024 to 2030, which is out of date.

The economy routes accept any four-digit year and pass it to the simulation service, and answer a stored result for it.

Catalog publication also fails when a stored catalog version's time periods (metadata_time_periods) differ from the staged ones (assert_country_matches), so changing the catalog's years would stop the next release's publication for an already-stored PolicyEngine.py version.

Change

  • Define each country's years once and use them for /{country}/metadata and catalog extraction.
  • Answer a society-wide request for any other year with 400 and the code DATASET_YEAR_UNAVAILABLE, before any stored result is read or anything is sent to the simulation service.
  • Make catalog publication replace a stored version's time periods with the staged ones, with a log entry, instead of failing. Every other column and table keeps failing on a difference.
Ngôn ngữ chính
Python
Star
18
Fork
33
Merge trung bình
2 ngày 18 giờ
Pull request đã merge (30 ngày)
105

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PolicyEngine/policyengine-api

Tất cả issue của PolicyEngine/policyengine-api

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.