Skip to content

Update API v1 to PolicyEngine.py 6.2.1 - #3855

Open
anth-volk wants to merge 10 commits into
masterfrom
feat/policyengine-6-1-2-api
Open

anth-volk wants to merge 10 commits into
masterfrom
feat/policyengine-6-1-2-api

Conversation

@anth-volk

@anth-volk anth-volk commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Install policyengine[models]==6.2.1, which selects PolicyEngine Core 3.32.10, PolicyEngine US 2.2.1, PolicyEngine UK 2.102.3, and spm-calculator 1.0.0.
  • Validate that the simulation registry maps the PolicyEngine.py, US, and UK versions to one worker application with matching Supplemental Poverty Measure settings.
  • Update the automatic PolicyEngine.py dependency workflow to change the single bundle requirement, relock dependencies, verify all five installed distributions against the bundle manifest, and report the certified US and UK data releases.
  • Update API request, result, cache, and catalog fixtures for the PolicyEngine.py 6 contract.

This supersedes #3837 as a clean implementation from current master. It does not reuse the implementation logic or commits from #3837.

PolicyEngine.py 6 behavior covered here

PolicyEngine.py 6.2.1 identifies the exact Supplemental Poverty Measure forecast file and default scenario used by the installed US model. API v1 resolves those settings before submitting an economy calculation. It rejects a worker that reports different settings, and it validates the forecast, scenario, year, and geography information in completed results before caching them.

The bundle also changes the installed public model catalog. The compatibility test now records 7,104 variables, 29,170 parameter nodes, 103,853 parameters, and 1,193,400 parameter values.

Simulation API relationship

PolicyEngine/policyengine-sim-api#703 contains the corresponding worker update to PolicyEngine.py 6.2.1. The two PRs can be reviewed independently. This PR does not merge or deploy #703, and opening this PR does not roll out either service.

Until a compatible worker is deployed, API v1 returns SPM_CONFIGURATION_UNAVAILABLE for affected US economy requests instead of submitting them to an incompatible worker. The live worker compatibility check may therefore remain unsuccessful while #703 is only a PR.

Commits

  1. Prepare reusable PolicyEngine.py 6 Supplemental Poverty Measure fixtures.
  2. Update the API and generic Docker image to PolicyEngine.py 6.
  3. Add installed-bundle and simulation-worker compatibility validation.
  4. Update the automatic PolicyEngine.py dependency workflow.
  5. Update dependent fixtures, expected responses, and catalog counts.
  6. Document the package bundle, data releases, and compatibility behavior.
  7. Update and relock the final bundle to PolicyEngine.py 6.2.1.

Testing

  • uv lock --check
  • Verified installed versions: PolicyEngine.py 6.2.1, Core 3.32.10, US 2.2.1, UK 2.102.3, and spm-calculator 1.0.0
  • Ruff formatting and lint checks for the API, tests, and updater helper
  • Focused bundle and catalog tests: 12 passed, 1 skipped
  • Full suite: 2,311 passed, 94 skipped

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.68%. Comparing base (0ebfc08) to head (4ad5036).

Files with missing lines Patch % Lines
policyengine_api/worker_spm_release.py 75.86% 10 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3855       +/-   ##
===========================================
+ Coverage   45.76%   87.68%   +41.92%     
===========================================
  Files         182      198       +16     
  Lines       10812    12010     +1198     
  Branches     1837     2106      +269     
===========================================
+ Hits         4948    10531     +5583     
+ Misses       5456      901     -4555     
- Partials      408      578      +170     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…-1-2-api

# Conflicts:
#	tests/unit/routes/test_calculate_error_statuses.py
#	tests/unit/services/test_economy_service.py
@anth-volk

Copy link
Copy Markdown
Collaborator Author

CI follow-up completed in commits 736c26c3 and dd5a0ac7.

  • Applied Ruff formatting to the four reported test modules.
  • Confirmed the existing changelog fragment already passed; no changelog edit was needed.
  • Removed the live simulation compatibility job as a prerequisite for the API test and container-build jobs. The compatibility check remains visible.
  • Merged current master and resolved the v6 SPM test fixtures against the newly merged observability and cache behavior.

Validation:

  • Local full suite: 2,311 passed, 94 skipped.
  • Hosted lint, changelog, API tests, environment tests, both container builds, both database migration checks, cross-database integration tests, type checking, quality checks, and Codecov checks pass.

The only remaining unsuccessful check is the live simulation compatibility check because the deployed simulation service does not yet advertise PolicyEngine.py 6.1.2. No service was deployed or merged as part of this fix.

@juaristi22

Copy link
Copy Markdown
Collaborator

@anth-volk, could this PR and PolicyEngine/policyengine-sim-api#703 target policyengine.py 6.2.0 instead of 6.1.2 before they merge?

A UK household calculator I'm building needs the duties added in policyengine-uk 2.102.0 (PolicyEngine/policyengine-uk#1876: alcohol, tobacco, vehicle excise and road fuel gas). API v1 runs policyengine-uk 2.90.2 today, and 6.1.2 still selects 2.90.2. 6.2.0 was released on 29 Sep at 18:02 UTC, after this PR was opened, and selects 2.102.3 (PolicyEngine/policyengine.py#536).

What moves between 6.1.2 and 6.2.0. Only policyengine-uk, from 2.90.2 to 2.102.3. Core 3.32.5, US 2.2.1, spm-calculator 1.0.0 and both certified data releases (populace-us-2024-spm-20260915, policyengine-uk-data-1.56.16) stay the same, and the release's only other change is a docs note (PolicyEngine/policyengine.py#534). Here I'd expect it to need the two pins, a re-lock, the package table in docs/canonical-spm.md and new counts in test_v2_catalog_installed.py, since 2.102.3 adds variables.

What else it changes. 6.2.0 moves every UK result the API serves, household and economy, onto 2.102.3. Its changelog lists the absolute poverty line rebased to FYE 2025, which raises UK absolute poverty in 2026-27 on the certified enhanced FRS by about 4 points overall and 7 points for children after housing costs, and relative poverty measured on the median over individuals (PolicyEngine/policyengine-uk#1865). Versions 2.102.1 and 2.102.2 also fix Class 4 National Insurance.

If you and Max would rather land the v6 migration on 6.1.2 first, when would 6.2.0 follow? No bot PR will open for it: every policyengine-release dispatch from 6.0.0 to 6.2.0 failed at uv lock in both repos on the direct spm-calculator==0.3.1 pin (6.2.0 runs: policyengine-api, policyengine-sim-api). Once this PR and PolicyEngine/policyengine-sim-api#703 merge, both updaters would need a manual run with version 6.2.0.

@anth-volk anth-volk changed the title Update API v1 to PolicyEngine 6.1.2 Update API v1 to PolicyEngine.py 6.2.1 Sep 30, 2026
…-1-2-api

# Conflicts:
#	pyproject.toml
#	tests/unit/test_cloud_run_deploy_scripts.py

This branch had an error being deployed

1 failed deployment
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