From fe947642019455cbcd7822d28a1f741734f040c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 1 Dec 2026 01:45:40 +0000 Subject: [PATCH 1/4] Update PolicyEngine bundle to 6.20.4 --- ...date-policyengine-bundle-6.20.4.changed.md | 1 + docker/Dockerfile | 2 +- pyproject.toml | 2 +- uv.lock | 20 +++++++++---------- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 changelog.d/update-policyengine-bundle-6.20.4.changed.md diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md new file mode 100644 index 000000000..ebbd6fbd2 --- /dev/null +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -0,0 +1 @@ +Update the PolicyEngine bundle to 6.20.4. diff --git a/docker/Dockerfile b/docker/Dockerfile index 0152908eb..8bd039ae1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ FROM python:3.12 # Match the API bundle in pyproject.toml; the bundle updater changes both pins. # The models extra pins the complete certified runtime package set. -RUN pip install "policyengine[models]==6.20.0" ipython +RUN pip install "policyengine[models]==6.20.4" ipython diff --git a/pyproject.toml b/pyproject.toml index 07e523472..3357b52a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ # versions certified by this PolicyEngine bundle. Cloud Run installs the # complete frozen environment from uv.lock; the generic image installs # this requirement directly. - "policyengine[models]==6.20.0", + "policyengine[models]==6.20.4", # The simulation service's generated client, which builds the requests of # the detailed-save API's household calculation, simulation and report # routes (policyengine_api.libs.simulation_service_operations). The pin is diff --git a/uv.lock b/uv.lock index c2d455330..6cfa13d5c 100644 --- a/uv.lock +++ b/uv.lock @@ -2954,7 +2954,7 @@ wheels = [ [[package]] name = "policyengine" -version = "6.20.0" +version = "6.20.4" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "h5py" }, @@ -2966,9 +2966,9 @@ dependencies = [ { name = "pydantic" }, { name = "requests" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/14/e8/4373c716f428ed885392ff1776dc1be1f9e9a3a6f7608afcc1f39d683546/policyengine-6.20.0.tar.gz", hash = "sha256:65dad563d92c17485c5943b2bb8114d8f16cd49c977acbce6412cd8b8bcfadfd", size = 1863269, upload-time = "2026-11-16T16:21:45.756Z" } +sdist = { url = "https://files.pythonhosted.org/packages/32/77/e2970d5839f497d6fefd06aeef99774859ca2f30bb5ee1691dfb458a7e2c/policyengine-6.20.4.tar.gz", hash = "sha256:4f253587872230fd55e8c045622ccd913ada304c1ead9b60dbc33cf4315685cf", size = 1868173, upload-time = "2026-12-01T01:43:30.923Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/64/b6/9ebed9a78c755c25893a20c924bc6952100bc3376608511fbcdb065145c3/policyengine-6.20.0-py3-none-any.whl", hash = "sha256:cc2da1b7448ae229294090318140bfe39440e8899415b8e465459c7e89bb7135", size = 774390, upload-time = "2026-11-16T16:21:43.414Z" }, + { url = "https://files.pythonhosted.org/packages/fc/92/02d046bf927873476ebf3e54e3efd23acd7270b221bca00d972f69086312/policyengine-6.20.4-py3-none-any.whl", hash = "sha256:0b93ec55feab0edfde61dcf27ecb81c68e1f7a271bd328a0ddf0e92f54933301", size = 775042, upload-time = "2026-12-01T01:43:28.788Z" }, ] [package.optional-dependencies] @@ -3073,7 +3073,7 @@ requires-dist = [ { name = "mypy", marker = "extra == 'dev'", specifier = ">=1.15,<2" }, { name = "openai" }, { name = "packaging", specifier = ">=24,<27" }, - { name = "policyengine", extras = ["models"], specifier = "==6.20.0" }, + { name = "policyengine", extras = ["models"], specifier = "==6.20.4" }, { name = "policyengine-api-simulation-client", specifier = "==0.20261127.430" }, { name = "policyengine-observability", extras = ["flask", "google", "httpx", "otlp-grpc"], specifier = ">=3.0.3,<4" }, { name = "psycopg", extras = ["binary"], specifier = ">=3.3,<4" }, @@ -3116,7 +3116,7 @@ wheels = [ [[package]] name = "policyengine-core" -version = "3.33.3" +version = "3.34.10" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "dpath" }, @@ -3136,9 +3136,9 @@ dependencies = [ { name = "standard-imghdr" }, { name = "wheel" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/17/af/e8449e8a488468e5ce28b6b9066a2372e05bc7971ad9a441eb4e6efbb740/policyengine_core-3.33.3.tar.gz", hash = "sha256:7da78ae9cc7b1d6833dc30651a0a4775edd2d5e205a73bbafcc0b15c988c880e", size = 693203, upload-time = "2026-10-12T20:53:17.299Z" } +sdist = { url = "https://files.pythonhosted.org/packages/39/15/8526adf38be5c96324f458886a2622704daec39b7e487899a7e922e299eb/policyengine_core-3.34.10.tar.gz", hash = "sha256:d232ddc415c3fa65bad31c0be25ff0f2c5826a5ae4cae10a47e6cd0a2102931d", size = 779988, upload-time = "2026-11-08T01:59:34.917Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c8/d6/253cc99d853e36996f264138f4f8a2c662047da3eda8e37ddf39959397fc/policyengine_core-3.33.3-py3-none-any.whl", hash = "sha256:5847d9938412095fe9848c2ce535838a7dc8fac9238d8fd9e6c9d0a0648e0888", size = 301905, upload-time = "2026-10-12T20:53:15.706Z" }, + { url = "https://files.pythonhosted.org/packages/ef/2e/b92cc4271bd5d02cc7830201316514cef91128861074cc5e06d6ac3c3dd2/policyengine_core-3.34.10-py3-none-any.whl", hash = "sha256:5045ed5e4d157eefab22bd285c8ba09e107f5c3a5a61e380fc2a85163259982a", size = 311145, upload-time = "2026-11-08T01:59:32.984Z" }, ] [[package]] @@ -3169,7 +3169,7 @@ otlp-grpc = [ [[package]] name = "policyengine-uk" -version = "2.174.1" +version = "2.179.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "microdf-python" }, @@ -3177,9 +3177,9 @@ dependencies = [ { name = "pydantic" }, { name = "tables" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/be/3a/fbf290895263fd4f8394f76fe1694e90e2c7b8b51a5a18f45f9bda16a4e2/policyengine_uk-2.174.1.tar.gz", hash = "sha256:c8302686c4d7c6fa92fb87febe1ad8130b7a0dd7987d5b14104384bd171f2245", size = 4434552, upload-time = "2026-11-04T07:36:05.319Z" } +sdist = { url = "https://files.pythonhosted.org/packages/69/45/9bfc794973d685c5da6c09d3b84b2445ffbfc16fc28bfd96772f8457aee0/policyengine_uk-2.179.2.tar.gz", hash = "sha256:56a99e8e3a48d2ebf5ee5f4383e5b5671b3c3b3b84f668cabc7b560f83bfd44e", size = 5294795, upload-time = "2026-11-18T15:41:54.502Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/35/ed/5ea303be2fd38da4e5f9b9a3fd012a5f9454fd5ef66a1df26c3267fb57a8/policyengine_uk-2.174.1-py3-none-any.whl", hash = "sha256:1d4d17c74bd5b853a148e9c44b080490dd0393725fe18b2b82ec55eecdb9bb58", size = 6313656, upload-time = "2026-11-04T07:36:02.964Z" }, + { url = "https://files.pythonhosted.org/packages/c6/55/84a5f328cff944fae92dc64d49ca139fe51b0f06b0217063ff87e3ea9779/policyengine_uk-2.179.2-py3-none-any.whl", hash = "sha256:a1da93b521408fd4aee7e85f6550d33fb392f0291bcab0eaba631533e3cc0836", size = 7416601, upload-time = "2026-11-18T15:41:51.547Z" }, ] [[package]] From 5e42fa56e32b66edccb8f56c00c61c80c467a938 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:18:32 +0400 Subject: [PATCH 2/4] Test that API v1 runs on a .py release with the stable inequality sort API v1's economy requests send its installed .py version as policyengine_version, and the simulation service runs each request on the app it deployed for that version; the /v2/ routes read that version's catalog. Releases before 6.20.4 rank households with equal incomes with numpy's default sort, whose order depends on the CPU. This test fails on the 6.20.0 pin. Co-Authored-By: Claude Opus 5.5 --- tests/unit/test_constants.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index ccf292307..aefef36f3 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -1,8 +1,10 @@ +import importlib.metadata import json import subprocess import sys import pytest +from packaging.version import Version from policyengine_api.constants import ( COUNTRY_PACKAGE_VERSIONS, @@ -39,6 +41,11 @@ def find_spec(self, fullname, path=None, target=None): sys.meta_path.insert(0, BlockPolicyEngineImports()) """ +# The first .py release whose inequality outputs (the Gini coefficient and +# the top 10%, top 1% and bottom 50% income shares) rank households with equal +# incomes in the order of their rows (PolicyEngine/policyengine.py#777). +FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT = Version("6.20.4") + class TestBundleDatasetDisplayLabels: @pytest.mark.parametrize( @@ -300,6 +307,22 @@ def test__load_policyengine_bundle_rejects_non_object_manifest( with pytest.raises(TypeError, match="must be a JSON object"): _load_policyengine_bundle() + def test__requests_name_a_release_that_sorts_incomes_stably(self): + """API v1's reports run on a .py release with the stable inequality sort. + + Economy requests send ``POLICYENGINE_VERSION`` as + ``policyengine_version``, and the simulation service runs each request + on the app it deployed for that version. The /v2/ routes read the + catalog of the installed distribution's version. Before 6.20.4, .py + ranked households with equal incomes with numpy's default sort, whose + order depends on the CPU, so the same report could give different top + income shares on different hosts. + """ + installed_version = importlib.metadata.version("policyengine") + + assert installed_version == POLICYENGINE_VERSION + assert Version(installed_version) >= FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT + def test__uses_policyengine_bundle_versions_for_us_uk_and_core(self): expected_versions = self._expected_bundle_versions() assert expected_versions["policyengine"] == POLICYENGINE_VERSION From fdcc790a3d675bb2f02e5734920fc1e3a9cabff6 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:20:49 +0400 Subject: [PATCH 3/4] Describe what the 6.20.4 bundle brings in The changelog fragment names the stable inequality sort and the policyengine-uk, policyengine-core and UK data release changes from 6.20.1 to 6.20.3. The dynamic parameters' docstring names the installed policyengine-uk version, whose gov.dynamic. folder is unchanged. Co-Authored-By: Claude Opus 5.5 --- changelog.d/update-policyengine-bundle-6.20.4.changed.md | 2 +- policyengine_api/dynamic_parameters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md index ebbd6fbd2..6625b17cb 100644 --- a/changelog.d/update-policyengine-bundle-6.20.4.changed.md +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.4. +Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata, UK economy results and the /v2/ model catalog. diff --git a/policyengine_api/dynamic_parameters.py b/policyengine_api/dynamic_parameters.py index aa1344242..00a62a097 100644 --- a/policyengine_api/dynamic_parameters.py +++ b/policyengine_api/dynamic_parameters.py @@ -6,7 +6,7 @@ behavioural responses, model settings and data assumptions, which a report applies alongside a policy. Parameters a country package adds later under these prefixes belong to dynamics with no code change. In policyengine-uk -2.174.1, ``gov.dynamic.`` holds one parameter, +2.179.2, ``gov.dynamic.`` holds one parameter, ``gov.dynamic.obr_labour_supply_assumptions``, a yes/no switch. The rule is used in these places: From 6b242d62f3dee9d229fbc1fcb5f63732d20b0fb5 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:47:51 +0400 Subject: [PATCH 4/4] Name the US effect and keep the dynamic parameters' docstring current The changelog fragment says policyengine-core's reform and caching fixes may also change some US household results, and that the /v2/ model catalog gets a 6.20.4 version for both countries. The docstring states the range of policyengine-uk versions it was checked against, so the next bundle update doesn't make it wrong. Co-Authored-By: Claude Opus 5.5 --- changelog.d/update-policyengine-bundle-6.20.4.changed.md | 2 +- policyengine_api/dynamic_parameters.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.d/update-policyengine-bundle-6.20.4.changed.md b/changelog.d/update-policyengine-bundle-6.20.4.changed.md index 6625b17cb..a53945b07 100644 --- a/changelog.d/update-policyengine-bundle-6.20.4.changed.md +++ b/changelog.d/update-policyengine-bundle-6.20.4.changed.md @@ -1 +1 @@ -Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata, UK economy results and the /v2/ model catalog. +Update the PolicyEngine bundle to 6.20.4. Its inequality outputs rank households with equal incomes in the order of their rows, so a report gives the same Gini coefficient and income shares on every host. It also brings in 6.20.1 to 6.20.3: policyengine-uk 2.179.2, policyengine-core 3.34.10 and a new certified UK data release, which change UK household calculations, UK metadata and UK economy results. policyengine-core's reform and caching fixes may also change some US household results, and the /v2/ model catalog gets a 6.20.4 version for both countries. diff --git a/policyengine_api/dynamic_parameters.py b/policyengine_api/dynamic_parameters.py index 00a62a097..6b28d4705 100644 --- a/policyengine_api/dynamic_parameters.py +++ b/policyengine_api/dynamic_parameters.py @@ -5,8 +5,8 @@ tree (C1 · 35, Q1) and the UK's ``gov.dynamic.`` (C1 · 46, Q6). These are behavioural responses, model settings and data assumptions, which a report applies alongside a policy. Parameters a country package adds later under -these prefixes belong to dynamics with no code change. In policyengine-uk -2.179.2, ``gov.dynamic.`` holds one parameter, +these prefixes belong to dynamics with no code change. From policyengine-uk +2.174.1 to at least 2.179.2, ``gov.dynamic.`` holds one parameter, ``gov.dynamic.obr_labour_supply_assumptions``, a yes/no switch. The rule is used in these places: