From 7734c1293e7b74aa0b4f34669205c4d95a106de0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 6 Nov 2026 23:59:42 -0500 Subject: [PATCH 01/10] Rename Populace to Microcosm in prose and code --- README.md | 2 +- docs/bundles.md | 4 ++-- docs/countries.md | 4 ++-- .../runbooks/build-m-us-populace-certification.md | 8 ++++---- docs/engineering/skills/data-certification.md | 8 ++++---- docs/microsim.md | 8 ++++---- docs/regions.md | 6 +++--- docs/release-bundles.md | 4 ++-- src/policyengine/countries/us/data/places.py | 2 +- src/policyengine/countries/us/regions.py | 2 +- src/policyengine/provenance/certification.py | 8 ++++---- src/policyengine/tax_benefit_models/be/model.py | 4 ++-- src/policyengine/tax_benefit_models/us/legacy_inputs.py | 2 +- tests/test_certify_data_release.py | 4 ++-- tests/test_entity_utils.py | 2 +- tests/test_release_manifests.py | 4 ++-- tests/test_us_legacy_inputs_integration.py | 4 ++-- tests/test_us_regions.py | 2 +- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index b7da84050..79540b716 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Python package for tax-benefit microsimulation analysis. Run policy simulation Requires Python 3.11–3.14. -> **Results are estimates.** PolicyEngine simulates a large, evolving body of tax-benefit law (the US model alone encodes more than 95,000 parameters across 5,500+ variables) over survey microdata calibrated to administrative targets. Treat outputs as estimates, and validate them against the policies relevant to your analysis, the scope of the rules engine, and external or back-of-the-envelope calculations. You can inspect the certified US dataset's calibration at https://calibration-diagnostics.vercel.app/populace. +> **Results are estimates.** PolicyEngine simulates a large, evolving body of tax-benefit law (the US model alone encodes more than 95,000 parameters across 5,500+ variables) over survey microdata calibrated to administrative targets. Treat outputs as estimates, and validate them against the policies relevant to your analysis, the scope of the rules engine, and external or back-of-the-envelope calculations. You can inspect the certified US dataset's calibration at https://calibration-diagnostics.vercel.app/microcosm. ## Quick start diff --git a/docs/bundles.md b/docs/bundles.md index 55fff09be..acaf3ab39 100644 --- a/docs/bundles.md +++ b/docs/bundles.md @@ -206,7 +206,7 @@ python scripts/bundle.py certify-data \ --manifest-uri hf://dataset/policyengine/populace-uk-private@/releases//release_manifest.json ``` -For US Populace releases, certify the Populace release manifest directly: +For US Microcosm releases, certify the Microcosm release manifest directly: ```bash python scripts/bundle.py certify-data \ @@ -218,7 +218,7 @@ python scripts/bundle.py certify-data \ ``` US state and congressional-district regions scope one certified ACS-local -Populace dataset with row filters. Pass its non-default local-area release +Microcosm dataset with row filters. Pass its non-default local-area release manifest through `--regional-manifest-uri`; certification adds the pinned H5 artifact to `data_releases.us.datasets` and writes both regional path templates under `data_releases.us.region_datasets`. If a legacy release publishes derived diff --git a/docs/countries.md b/docs/countries.md index 256ac9077..1a1443bc9 100644 --- a/docs/countries.md +++ b/docs/countries.md @@ -32,12 +32,12 @@ Override in any output with `income_variable=`. | | Dataset | |---|---| -| US | Populace US 2024 (`populace_us_2024.h5`) | +| US | Microcosm US 2024 (`populace_us_2024.h5`) | | UK | Microcosm UK 2024-25 (`microcosm_uk_2024_25.h5`); constituency and local-authority regions use its local-area release (`microcosm_uk_2024_25_dense.h5`) | ## State / regional breakdown -US: Populace row scoping uses `state_fips` and `congressional_district_geoid`. +US: Microcosm row scoping uses `state_fips` and `congressional_district_geoid`. `state_code` remains the human-readable state input for custom households. US resource and poverty calculations also require observed `county_fips` or an explicit national or SPM-area choice; see [Households](households.md#spm-geography-and-measurement-selection). diff --git a/docs/engineering/runbooks/build-m-us-populace-certification.md b/docs/engineering/runbooks/build-m-us-populace-certification.md index c99190436..81849a25e 100644 --- a/docs/engineering/runbooks/build-m-us-populace-certification.md +++ b/docs/engineering/runbooks/build-m-us-populace-certification.md @@ -1,6 +1,6 @@ -# US Populace certification runbook +# US Microcosm certification runbook -Use this runbook to certify a new national US Populace release together with +Use this runbook to certify a new national US Microcosm release together with the shared ACS-local release used for state and congressional-district simulations. For now, state and district simulations use the national release instead; see the interim exception in Step 2. Read the @@ -25,7 +25,7 @@ interim exception in Step 2 holds). metadata and runs reachability `HEAD` checks against Hugging Face. - `HUGGING_FACE_TOKEN` (or `HF_TOKEN`) exported — required to regenerate the UK TRO in the `--include-tros` step and to run the UK data-release fetch in - the test suite. The US populace repo is public. + the test suite. The US microcosm repo is public. ## Step 1 — identify the releases @@ -93,7 +93,7 @@ PE_UPDATE_SNAPSHOTS=1 pytest tests/test_household_calculator_snapshot.py The certification command passes the immutable ACS-local release manifest with `--regional-manifest-uri`. Confirm all of the following: -- `default_dataset` remains the national Populace dataset; +- `default_dataset` remains the national Microcosm dataset; - the local-area artifact appears in `data_releases.us.datasets` with its repository type, immutable revision, and SHA-256; - `region_datasets.national` selects the national artifact; diff --git a/docs/engineering/skills/data-certification.md b/docs/engineering/skills/data-certification.md index a33684ef0..579798b43 100644 --- a/docs/engineering/skills/data-certification.md +++ b/docs/engineering/skills/data-certification.md @@ -313,7 +313,7 @@ their `_tiny` files. ### US -For US Populace certification, certify the Populace release manifest directly: +For US Microcosm certification, certify the Microcosm release manifest directly: ```bash python scripts/bundle.py certify-data --country us --data-producer populace \ @@ -323,7 +323,7 @@ python scripts/bundle.py certify-data --country us --data-producer populace \ ``` US state and congressional-district regions are row filters over one shared, -certified ACS-local Populace dataset. Its release manifest must declare +certified ACS-local Microcosm dataset. Its release manifest must declare `dataset_role: non_default_local_area`, `is_default: false`, no default datasets, and exactly one pinned H5 microdata artifact. Certification writes: @@ -338,7 +338,7 @@ datasets, and exactly one pinned H5 microdata artifact. Certification writes: The ACS-local artifact is a second entry in `data_releases.us.datasets`; it is not a dataset overlay and it never replaces the national `default_dataset`. -If the Populace release publishes derived `states/*.h5` or `districts/*.h5` +If the Microcosm release publishes derived `states/*.h5` or `districts/*.h5` files for compatibility checks, certification omits them from the runtime bundle. The country-wide default and ACS-local dataset are each single shared files; region registries select one and then filter its rows. @@ -370,7 +370,7 @@ A certification PR should normally change only: Hard failures (certification refuses): missing national default dataset, default dataset absent from artifacts, any artifact without a revision pin, unreachable certified dataset, missing required supplemental release files -(for example Populace-US `us_source_coverage.json`), a malformed shared +(for example Microcosm-US `us_source_coverage.json`), a malformed shared local-area release, area-coded national release or legacy per-state artifacts when `--regional-manifest-uri` is used, a regional release that does not serve the pinned model version, an unreachable regional artifact, a re-certification diff --git a/docs/microsim.md b/docs/microsim.md index b0aaf8988..d73fc262b 100644 --- a/docs/microsim.md +++ b/docs/microsim.md @@ -134,12 +134,12 @@ datasets = pe.us.ensure_datasets( dataset = datasets["populace_us_2024_2026"] ``` -The default US dataset is **Populace US 2024** — a Populace-built dataset +The default US dataset is **Microcosm US 2024** — a Microcosm-built dataset calibrated to IRS, CMS, SNAP, Census, and other administrative totals. The current UK certified default is **Microcosm UK 2024–25**, a Microcosm build calibrated to HMRC, DWP, OBR and other administrative totals; constituency and local-authority regions use its local-area release. **Enhanced FRS 2024–25** -(`enhanced_frs_2024_25`, policyengine-uk-data 1.58.1) and **Populace UK 2023** +(`enhanced_frs_2024_25`, policyengine-uk-data 1.58.1) and **Microcosm UK 2023** remain available as named, non-default bundle datasets. PolicyEngine.py obtains the repository type, immutable revision, and SHA-256 @@ -156,7 +156,7 @@ pe.us.load_datasets() # or pe.uk.load_datasets() Alongside the certified national default, the bundle registers a US dataset for finer geographic work: `populace_us_2024_acs_local`. It is a -Populace US 2024 build of roughly **1.6 million households** on an **ACS 2024 +Microcosm US 2024 build of roughly **1.6 million households** on an **ACS 2024 multispine**, with each household **PUMA-assigned** to a 119th-Congress congressional district, county, and state, and calibrated to **state administrative totals and state and congressional-district population**. Its @@ -387,7 +387,7 @@ See [Outputs](outputs.md) for the full catalog. ## Memory and performance -A full Populace US microsimulation uses roughly 4 GB of memory and takes 15-30 seconds on a laptop. For parameter sweeps, reuse the baseline: +A full Microcosm US microsimulation uses roughly 4 GB of memory and takes 15-30 seconds on a laptop. For parameter sweeps, reuse the baseline: ```python baseline = Simulation(dataset=dataset, tax_benefit_model_version=pe.us.model) diff --git a/docs/regions.md b/docs/regions.md index c86eb5f07..0ba28ba8f 100644 --- a/docs/regions.md +++ b/docs/regions.md @@ -24,7 +24,7 @@ ca_snap.run() ``` Each state is a region in the US registry. State regions load the ACS-local -Populace dataset declared by `region.dataset_path`, then scope its rows by +Microcosm dataset declared by `region.dataset_path`, then scope its rows by `state_fips`. They do not require separate state H5 files: ```python @@ -218,7 +218,7 @@ df.groupby("geo").apply(lambda g: (g["change"] * g["weight"]).sum() / g["weight" ## Scoping datasets to a region -For reforms defined only over a sub-national slice, pass a scoping strategy to `Simulation`. `RowFilterStrategy` keeps only matching households. `WeightReplacementStrategy` is legacy matrix infrastructure and is not used by the UK Populace constituency or local-authority registry. +For reforms defined only over a sub-national slice, pass a scoping strategy to `Simulation`. `RowFilterStrategy` keeps only matching households. `WeightReplacementStrategy` is legacy matrix infrastructure and is not used by the UK Microcosm constituency or local-authority registry. ```python from policyengine.core.scoping_strategy import RowFilterStrategy @@ -233,7 +233,7 @@ baseline = Simulation( ) ``` -Regions that filter (US states and congressional districts, UK countries, and any region with `region.requires_filter == True`) carry their own `scoping_strategy`. Pull it off the region object rather than reconstructing it. US place regions are present as hierarchy metadata, but current Populace datasets do not carry `place_fips`, so they do not expose runtime scoping yet: +Regions that filter (US states and congressional districts, UK countries, and any region with `region.requires_filter == True`) carry their own `scoping_strategy`. Pull it off the region object rather than reconstructing it. US place regions are present as hierarchy metadata, but current Microcosm datasets do not carry `place_fips`, so they do not expose runtime scoping yet: ```python ca = pe.us.model.region_registry.get("state/ca") diff --git a/docs/release-bundles.md b/docs/release-bundles.md index def3658d2..502e9584f 100644 --- a/docs/release-bundles.md +++ b/docs/release-bundles.md @@ -196,7 +196,7 @@ python scripts/bundle.py certify-data --country us \ --manifest-uri "hf://dataset/policyengine/populace-us@/releases//release_manifest.json" ``` -US Populace certification uses the Populace release manifest directly: +US Microcosm certification uses the Microcosm release manifest directly: ```bash python scripts/bundle.py certify-data --country us --data-producer populace \ @@ -205,7 +205,7 @@ python scripts/bundle.py certify-data --country us --data-producer populace \ --model-version "" ``` -That produces one US bundle manifest entry containing the Populace national +That produces one US bundle manifest entry containing the Microcosm national default dataset and the certified ACS-local regional dataset. State and congressional-district simulations use the latter with runtime row filters, so derived `states/*.h5` or `districts/*.h5` files are not vendored into diff --git a/src/policyengine/countries/us/data/places.py b/src/policyengine/countries/us/data/places.py index 5669e26be..27a44f4f8 100644 --- a/src/policyengine/countries/us/data/places.py +++ b/src/policyengine/countries/us/data/places.py @@ -5,7 +5,7 @@ """ # US cities/places with population over 100K (from Census data). -# These are registry metadata until Populace emits place-level row keys. +# These are registry metadata until Microcosm emits place-level row keys. # Total: 333 places US_PLACES: list[dict[str, str]] = [ { diff --git a/src/policyengine/countries/us/regions.py b/src/policyengine/countries/us/regions.py index 7f6ceb87c..71f02e9f2 100644 --- a/src/policyengine/countries/us/regions.py +++ b/src/policyengine/countries/us/regions.py @@ -100,7 +100,7 @@ def build_us_region_registry() -> RegionRegistry: ) ) - # 4. Place/city regions (hierarchy metadata only until Populace emits place_fips) + # 4. Place/city regions (hierarchy metadata only until Microcosm emits place_fips) for place in US_PLACES: state_abbrev = place["state"] fips = place["fips"] diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index 9578f3c58..e52cfa1ac 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -110,11 +110,11 @@ "https://github.com/PolicyEngine/policyengine.py/tree/uk-qualification-ledger" ) POPULACE_US_SOURCE_COVERAGE_FILE = "us_source_coverage.json" -# The Populace US producer publishes under `microcosm-data` since the +# The Microcosm US producer publishes under `microcosm-data` since the # source-enrichment releases; `populace-data` is its earlier name. Both denote -# the same producer, so every Populace-specific rule below must accept either. +# the same producer, so every Microcosm-specific rule below must accept either. POPULACE_DATA_PACKAGES = frozenset({"populace-data", "microcosm-data"}) -# The Hugging Face repos each country's Populace/Microcosm releases publish to. +# The Hugging Face repos each country's Microcosm releases publish to. POPULACE_RELEASE_REPOS = { "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", @@ -985,7 +985,7 @@ def merge_us_state_release_manifest( artifact_prefix: str = "states/", path_template: str = "states/{state_code}.h5", ) -> DataReleaseManifest: - """Add legacy US state artifacts to a primary Populace release manifest.""" + """Add legacy US state artifacts to a primary Microcosm release manifest.""" primary_payload = primary_manifest.model_dump(mode="json", exclude_none=True) merged_artifacts = primary_payload.setdefault("artifacts", {}) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index c4fe9e850..fe467a345 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -2,7 +2,7 @@ Unlike the US and UK model versions, Belgium runs on the Axiom rules engine: statutes encoded as RuleSpec YAML in TheAxiomFoundation/rulespec-be, -compiled and executed by ``axiom-rules-engine``, and driven over populace +compiled and executed by ``axiom-rules-engine``, and driven over Microcosm entity tables through the ``microcosm.frame`` Axiom adapter. There is no policyengine-core country package and no certified release manifest, so this version subclasses ``TaxBenefitModelVersion`` directly and stays outside the @@ -76,7 +76,7 @@ class AxiomBelgium(TaxBenefitModel): id: str = "axiom-rulespec-be" description: str = ( "Belgium tax rules encoded as RuleSpec (TheAxiomFoundation/rulespec-be), " - "executed by the Axiom rules engine over populace entity tables." + "executed by the Axiom rules engine over Microcosm entity tables." ) diff --git a/src/policyengine/tax_benefit_models/us/legacy_inputs.py b/src/policyengine/tax_benefit_models/us/legacy_inputs.py index 38fb02495..f108ccd54 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_inputs.py +++ b/src/policyengine/tax_benefit_models/us/legacy_inputs.py @@ -441,7 +441,7 @@ def stored_entity_tables( renames whose live input belongs to it. policyengine-us loads an entity-table H5 (the layout of the certified - Populace default) into a multi-year dataset whose ``datasets`` map each + Microcosm default) into a multi-year dataset whose ``datasets`` map each year to that year's entity DataFrames. Those keep every stored column, including the ones the engine skipped, so they are returned as they are. diff --git a/tests/test_certify_data_release.py b/tests/test_certify_data_release.py index e3069d32d..6da96eaa9 100644 --- a/tests/test_certify_data_release.py +++ b/tests/test_certify_data_release.py @@ -946,7 +946,7 @@ def test__given_vendored_bundle_manifest__then_tro_sidecar_binds_it(self): def _source_enrichment_manifest_payload() -> dict: """A `microcosm-data` release whose sidecars use the `evidence` kind. - This is the shape the Populace US producer publishes for source-enrichment + This is the shape the Microcosm US producer publishes for source-enrichment releases: the data package is named `microcosm-data` rather than `populace-data`, and release-directory sidecars are labelled `evidence` rather than `diagnostics`. @@ -966,7 +966,7 @@ def _source_enrichment_manifest_payload() -> dict: class TestSourceEnrichmentProducerRelease: - """The `microcosm-data` producer name must keep every Populace rule armed. + """The `microcosm-data` producer name must keep every Microcosm rule armed. A release published under the newer producer name previously fell through every `populace-data` guard, which both skipped the per-artifact diff --git a/tests/test_entity_utils.py b/tests/test_entity_utils.py index 17a1fc5a2..deb1dd615 100644 --- a/tests/test_entity_utils.py +++ b/tests/test_entity_utils.py @@ -161,7 +161,7 @@ def test__given_matching_value__then_returns_filtered_entities(self): def test__given_us_numeric_geography__then_filters_state_and_district( self, us_test_dataset ): - """Given: US data with Populace geography columns + """Given: US data with Microcosm geography columns When: Filtering by state FIPS and congressional district GEOID Then: Related entities are preserved for matching households only """ diff --git a/tests/test_release_manifests.py b/tests/test_release_manifests.py index abc8b1a2b..a4c6cca9d 100644 --- a/tests/test_release_manifests.py +++ b/tests/test_release_manifests.py @@ -61,7 +61,7 @@ US_RELEASE_MANIFEST_DATASET_URI = ( f"hf://policyengine/populace-us/populace_us_2024.h5@{US_DATA_RELEASE_REVISION}" ) -# Certified local-area dataset: a Populace US artifact published in its own +# Certified local-area dataset: a Microcosm US artifact published in its own # immutable release. It remains non-default nationally and is selected for # states and congressional districts. US_LOCAL_AREA_DATASET = "populace_us_2024_acs_local" @@ -157,7 +157,7 @@ def _response_with_json(payload: dict) -> MagicMock: def _legacy_us_country_manifest( version: str = "1.73.0", package_name: str = "policyengine-us-data" ) -> CountryReleaseManifest: - """Pin the legacy fixture independently of the installed Populace bundle.""" + """Pin the legacy fixture independently of the installed Microcosm bundle.""" return CountryReleaseManifest.model_validate( { "country_id": "us", diff --git a/tests/test_us_legacy_inputs_integration.py b/tests/test_us_legacy_inputs_integration.py index 182d39af9..89471146a 100644 --- a/tests/test_us_legacy_inputs_integration.py +++ b/tests/test_us_legacy_inputs_integration.py @@ -1,7 +1,7 @@ """The legacy WIC take-up draw reaches real policyengine-us simulations. Each test builds a tiny US household that stores its WIC take-up draw as -``would_claim_wic`` (the layout of the certified Populace default, see +``would_claim_wic`` (the layout of the certified Microcosm default, see PolicyEngine/microcosm#1026), loads it through one of the load paths, and checks that a WIC-eligible person whose stored draw is ``False`` gets no WIC, while the same person gets WIC when the mapping is switched off. @@ -105,7 +105,7 @@ def _in_memory_dataset(directory, frames=None) -> PolicyEngineUSDataset: def _write_entity_tables(path) -> str: - """Write the household in the certified Populace default's layout.""" + """Write the household in the certified Microcosm default's layout.""" with pd.HDFStore(path, mode="w") as store: for entity, frame in _frames().items(): store.put(entity, frame, format="table", data_columns=True) diff --git a/tests/test_us_regions.py b/tests/test_us_regions.py index 54f20cd60..67ccfb65e 100644 --- a/tests/test_us_regions.py +++ b/tests/test_us_regions.py @@ -186,7 +186,7 @@ def test__given_ca_first_district__then_has_correct_format(self): def test__given_at_large_district__then_filter_uses_zero_district_geoid(self): """Given: an at-large congressional district When: Checking its row filter - Then: It uses the Populace/Census SS00 district GEOID convention + Then: It uses the Microcosm/Census SS00 district GEOID convention """ # When ak_al = us_region_registry.get("congressional_district/AK-01") From 2cfd72a05b2a8ae7225ffd4e6f55e2ac3d381d55 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 00:02:24 -0500 Subject: [PATCH 02/10] Add a changelog fragment for the Microcosm rename Co-Authored-By: Claude Opus 5.5 --- changelog.d/microcosm-name-sweep-20261106.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/microcosm-name-sweep-20261106.changed.md diff --git a/changelog.d/microcosm-name-sweep-20261106.changed.md b/changelog.d/microcosm-name-sweep-20261106.changed.md new file mode 100644 index 000000000..6f873e5ca --- /dev/null +++ b/changelog.d/microcosm-name-sweep-20261106.changed.md @@ -0,0 +1 @@ +Name the microdata stack Microcosm throughout docs, comments and code. From ca1b1bf499329d6c223c417a4f2bc9715bb4d038 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 07:00:38 -0500 Subject: [PATCH 03/10] Keep the calibration dashboard's Vercel link until its policyengine.org route is live Public links go to policyengine.org, never a hosting address, and when the policyengine.org route isn't live the link is held rather than swapped for another hosting address. policyengine.org/us/calibration-diagnostics returns 404 today, so README.md keeps calibration-diagnostics.vercel.app/populace. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79540b716..b7da84050 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Python package for tax-benefit microsimulation analysis. Run policy simulation Requires Python 3.11–3.14. -> **Results are estimates.** PolicyEngine simulates a large, evolving body of tax-benefit law (the US model alone encodes more than 95,000 parameters across 5,500+ variables) over survey microdata calibrated to administrative targets. Treat outputs as estimates, and validate them against the policies relevant to your analysis, the scope of the rules engine, and external or back-of-the-envelope calculations. You can inspect the certified US dataset's calibration at https://calibration-diagnostics.vercel.app/microcosm. +> **Results are estimates.** PolicyEngine simulates a large, evolving body of tax-benefit law (the US model alone encodes more than 95,000 parameters across 5,500+ variables) over survey microdata calibrated to administrative targets. Treat outputs as estimates, and validate them against the policies relevant to your analysis, the scope of the rules engine, and external or back-of-the-envelope calculations. You can inspect the certified US dataset's calibration at https://calibration-diagnostics.vercel.app/populace. ## Quick start From 7b1f29fcaf5076cced1de93e8b094715e2bfcc7d Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 08:53:26 -0500 Subject: [PATCH 04/10] Finish renaming Populace to Microcosm --- docs/microsim.md | 2 +- docs/release-bundles.md | 2 +- examples/belgium_axiom_pilot.py | 20 +-- scripts/certify_data_release.py | 2 +- src/policyengine/provenance/certification.py | 38 +++-- .../tax_benefit_models/be/__init__.py | 9 +- .../tax_benefit_models/be/datasets.py | 7 +- .../tax_benefit_models/be/model.py | 10 +- .../us/legacy_spm/registry.py | 15 +- tests/fixtures/release_tros/README.md | 2 +- tests/test_be_axiom_pilot.py | 14 +- tests/test_certify_data_release.py | 38 ++--- tests/test_dataset_materialization.py | 4 +- tests/test_microcosm_compatibility.py | 136 ++++++++++++++++++ tests/test_release_manifests.py | 12 +- tests/test_us_legacy_inputs_integration.py | 14 +- tests/test_us_legacy_spm.py | 8 +- tests/test_us_legacy_spm_integration.py | 8 +- 18 files changed, 258 insertions(+), 83 deletions(-) create mode 100644 tests/test_microcosm_compatibility.py diff --git a/docs/microsim.md b/docs/microsim.md index d73fc262b..3873adae6 100644 --- a/docs/microsim.md +++ b/docs/microsim.md @@ -404,7 +404,7 @@ Smaller custom H5 datasets can be passed explicitly for testing: ```python datasets = pe.us.ensure_datasets( - datasets=["/path/to/smoke_test_populace_us_2024.h5"], + datasets=["/path/to/smoke_test_microcosm_us_2024.h5"], years=[2026], allow_unmanaged=True, ) diff --git a/docs/release-bundles.md b/docs/release-bundles.md index 502e9584f..b4f8199ec 100644 --- a/docs/release-bundles.md +++ b/docs/release-bundles.md @@ -164,7 +164,7 @@ It does not own final runtime bundle certification. ### Country data package -Examples: `populace-data`, `policyengine-uk-data` +Examples: `microcosm-data`, `policyengine-uk-data` The country data package owns: diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index f13941dc7..1e606d1b4 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -1,6 +1,6 @@ """Belgium population microsimulation through the Axiom rules engine. -Runs the calibrated populace-be pilot dataset (populace-us support records +Runs the calibrated Microcosm-BE pilot dataset (Microcosm-US support records reweighted to Statbel/SPF/ONSS/ONEM targets from PolicyEngine/ledger) through the rulespec-be composed worker pipeline, and scores the aggregates against Belgian administrative facts. @@ -19,7 +19,7 @@ Usage:: - POPULACE_BE_DATASET=.../populace_be_pilot_2026.h5 \\ + MICROCOSM_BE_DATASET=.../populace_be_pilot_2026.h5 \\ RULESPEC_BE_ROOT=.../rulespec-be \\ uv run python examples/belgium_axiom_pilot.py """ @@ -31,19 +31,23 @@ EMPLOYEE_SSC, PIT_BEFORE_WITHHOLDING, AxiomBelgiumPilot, - PopulaceBelgiumDataset, + MicrocosmBelgiumDataset, ) -DATASET = os.environ["POPULACE_BE_DATASET"] +DATASET = os.environ.get("MICROCOSM_BE_DATASET") +if DATASET is None: + DATASET = os.environ[ + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.16.1 + ] RULESPEC = os.environ.get("RULESPEC_BE_ROOT", "~/TheAxiomFoundation/rulespec-be") # Ledger facts (PolicyEngine/ledger, Belgian publisher packages) ONSS_WORKER_CONTRIBUTIONS_2024 = 20_836_582_673 SPF_PIT_BEFORE_WITHHOLDING_2023 = 62_840_116_134 -dataset = PopulaceBelgiumDataset( - name="populace-be-pilot", - description="populace-us support reweighted to Belgian ledger targets", +dataset = MicrocosmBelgiumDataset( + name="microcosm-be-pilot", + description="Microcosm-US support reweighted to Belgian ledger targets", filepath=DATASET, year=2026, ) @@ -57,7 +61,7 @@ ssc_net = person[EMPLOYEE_SSC].sum() pit = person[PIT_BEFORE_WITHHOLDING].sum() -print("Belgium pilot (Axiom engine over populace-be, worker slice)") +print("Belgium pilot (Axiom engine over Microcosm-BE, worker slice)") print( f" data vintage {output.year}; policy period {output.policy_period}; " f"model {model_version.version}" diff --git a/scripts/certify_data_release.py b/scripts/certify_data_release.py index 60b0c9b6c..d365c307b 100644 --- a/scripts/certify_data_release.py +++ b/scripts/certify_data_release.py @@ -48,7 +48,7 @@ def main(argv=None) -> int: "--data-producer", default=None, choices=["legacy", "populace"], - help="Data-producer strategy. Defaults to populace for UK, legacy otherwise.", + help="Data-producer strategy. Defaults to Microcosm for UK, legacy otherwise.", ) parser.add_argument( "--manifest-uri", diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index e52cfa1ac..add5fbc74 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -109,16 +109,25 @@ QUALIFICATION_LEDGER_URL = ( "https://github.com/PolicyEngine/policyengine.py/tree/uk-qualification-ledger" ) -POPULACE_US_SOURCE_COVERAGE_FILE = "us_source_coverage.json" +MICROCOSM_US_SOURCE_COVERAGE_FILE = "us_source_coverage.json" # The Microcosm US producer publishes under `microcosm-data` since the -# source-enrichment releases; `populace-data` is its earlier name. Both denote +# source-enrichment releases; both published package names below denote # the same producer, so every Microcosm-specific rule below must accept either. -POPULACE_DATA_PACKAGES = frozenset({"populace-data", "microcosm-data"}) +MICROCOSM_DATA_PACKAGES = frozenset({"populace-data", "microcosm-data"}) # The Hugging Face repos each country's Microcosm releases publish to. -POPULACE_RELEASE_REPOS = { +MICROCOSM_RELEASE_REPOS = { "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", } +POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.16.1 + MICROCOSM_US_SOURCE_COVERAGE_FILE +) +POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.16.1 + MICROCOSM_DATA_PACKAGES +) +POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.16.1 + MICROCOSM_RELEASE_REPOS +) # Region types a regional release serves. Their regions load the routed dataset # and keep row-filtering it on their own geography column. LOCAL_AREA_REGION_TYPES: dict[CertifiedCountry, tuple[str, ...]] = { @@ -948,10 +957,10 @@ def required_supplemental_release_files( ) -> tuple[str, ...]: if ( country == "us" - and manifest.data_package.name in POPULACE_DATA_PACKAGES + and manifest.data_package.name in MICROCOSM_DATA_PACKAGES and uri_parts["repo_id"] == "policyengine/populace-us" ): - return (POPULACE_US_SOURCE_COVERAGE_FILE,) + return (MICROCOSM_US_SOURCE_COVERAGE_FILE,) return () @@ -960,9 +969,9 @@ def should_validate_vendored_artifacts( manifest: DataReleaseManifest, uri_parts: dict, ) -> bool: - return manifest.data_package.name in POPULACE_DATA_PACKAGES and uri_parts[ + return manifest.data_package.name in MICROCOSM_DATA_PACKAGES and uri_parts[ "repo_id" - ] == POPULACE_RELEASE_REPOS.get(country) + ] == MICROCOSM_RELEASE_REPOS.get(country) def _state_code_from_path(path: str, artifact_prefix: str) -> Optional[str]: @@ -1359,7 +1368,7 @@ def build_country_manifest_payload( for name, artifact in manifest.artifacts.items(): if ( country == "us" - and manifest.data_package.name in POPULACE_DATA_PACKAGES + and manifest.data_package.name in MICROCOSM_DATA_PACKAGES and artifact.path.endswith(".h5") and ( artifact.path.startswith("states/") @@ -1388,7 +1397,7 @@ def build_country_manifest_payload( path_template = template.get("path_template") if ( country == "us" - and manifest.data_package.name in POPULACE_DATA_PACKAGES + and manifest.data_package.name in MICROCOSM_DATA_PACKAGES and region in {"state", "congressional_district"} and isinstance(path_template, str) and "{" in path_template @@ -1559,7 +1568,7 @@ def certify( ) -class PopulaceDataProducerCertificationStrategy(DataProducerCertificationStrategy): +class MicrocosmDataProducerCertificationStrategy(DataProducerCertificationStrategy): data_producer = "populace" def certify( @@ -1755,12 +1764,17 @@ def certify( ) +PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.16.1 + MicrocosmDataProducerCertificationStrategy +) + + def certification_strategy( country: str, data_producer: Optional[str] = None ) -> DataProducerCertificationStrategy: producer = data_producer or ("populace" if country == "uk" else "legacy") if producer == "populace": - return PopulaceDataProducerCertificationStrategy() + return MicrocosmDataProducerCertificationStrategy() if producer == "legacy": return LegacyDataProducerCertificationStrategy() raise CertificationError(f"Unknown data-producer {producer!r}.") diff --git a/src/policyengine/tax_benefit_models/be/__init__.py b/src/policyengine/tax_benefit_models/be/__init__.py index 74044832d..1ff95c263 100644 --- a/src/policyengine/tax_benefit_models/be/__init__.py +++ b/src/policyengine/tax_benefit_models/be/__init__.py @@ -7,7 +7,7 @@ and ``model.py`` for scope and source-install requirements. """ -from .datasets import BEYearData, PopulaceBelgiumDataset +from .datasets import BEYearData, MicrocosmBelgiumDataset from .model import ( EMPLOYEE_SSC, PIT_BEFORE_WITHHOLDING, @@ -17,13 +17,18 @@ be_model, ) +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 + MicrocosmBelgiumDataset +) + __all__ = [ "AxiomBelgium", "AxiomBelgiumPilot", "BEYearData", "EMPLOYEE_SSC", "PIT_BEFORE_WITHHOLDING", - "PopulaceBelgiumDataset", + "MicrocosmBelgiumDataset", + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 "REMUNERATION", "be_model", ] diff --git a/src/policyengine/tax_benefit_models/be/datasets.py b/src/policyengine/tax_benefit_models/be/datasets.py index 04bb40d06..6797f3657 100644 --- a/src/policyengine/tax_benefit_models/be/datasets.py +++ b/src/policyengine/tax_benefit_models/be/datasets.py @@ -88,7 +88,7 @@ def entity_data(self) -> dict[str, MicroDataFrame]: return {"person": self.person, "household": self.household} -class PopulaceBelgiumDataset(Dataset): +class MicrocosmBelgiumDataset(Dataset): """Belgium pilot dataset loaded from a Microcosm-BE HDF5 artifact. ``year`` identifies the input dataset vintage. ``policy_period`` is set on @@ -188,3 +188,8 @@ def save(self) -> None: self._POLICY_PERIOD_ATTRIBUTE, int(self.policy_period), ) + + +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 + MicrocosmBelgiumDataset +) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index fe467a345..f662d4f6a 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -46,10 +46,14 @@ from .datasets import ( BEYearData, - PopulaceBelgiumDataset, + MicrocosmBelgiumDataset, _person_with_household_weights, ) +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 + MicrocosmBelgiumDataset +) + if TYPE_CHECKING: from policyengine.core.simulation import Simulation @@ -126,7 +130,7 @@ def run(self, simulation: "Simulation") -> "Simulation": ) dataset = simulation.dataset - assert isinstance(dataset, PopulaceBelgiumDataset) + assert isinstance(dataset, MicrocosmBelgiumDataset) if dataset.data is None: dataset.load() assert dataset.data is not None @@ -186,7 +190,7 @@ def run(self, simulation: "Simulation") -> "Simulation": }, ] - simulation.output_dataset = PopulaceBelgiumDataset( + simulation.output_dataset = MicrocosmBelgiumDataset( id=simulation.id, name=dataset.name, description=dataset.description, diff --git a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py index 4806066ee..dc268892e 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py +++ b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py @@ -62,7 +62,7 @@ class LegacySPMSource(BaseModel): #: residents without declaring SPM scope, and it was built a few hours before #: PolicyEngine/microcosm#959, so its ASEC/PUF records lack the independence #: role that the national release carries for the same records. -POPULACE_US_2024_ACS_LOCAL_BUILD_O = LegacySPMSource( +MICROCOSM_US_2024_ACS_LOCAL_BUILD_O = LegacySPMSource( name=( "populace_us_2024_acs_local@" "populace-us-2024-buildo-acs-local-767312d60-20260923T074941Z" @@ -82,7 +82,7 @@ class LegacySPMSource(BaseModel): #: the measurement under Census's ACS household-population rule, as Build O's #: are. Remove the entry once a release carries the scope natively #: (PolicyEngine/policyengine-us#9462). -POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = LegacySPMSource( +MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 = LegacySPMSource( name=( "populace_us_2024_acs_local@" "populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z" @@ -91,9 +91,16 @@ class LegacySPMSource(BaseModel): spm_universe_rule="acs_household_population", ) +POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.16.1 + MICROCOSM_US_2024_ACS_LOCAL_BUILD_O +) +POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.16.1 + MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 +) + LEGACY_SPM_SOURCES: tuple[LegacySPMSource, ...] = ( - POPULACE_US_2024_ACS_LOCAL_BUILD_O, - POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263, + MICROCOSM_US_2024_ACS_LOCAL_BUILD_O, + MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263, ) diff --git a/tests/fixtures/release_tros/README.md b/tests/fixtures/release_tros/README.md index f64ee4bb6..f1bd29f0c 100644 --- a/tests/fixtures/release_tros/README.md +++ b/tests/fixtures/release_tros/README.md @@ -7,7 +7,7 @@ generator. They do not certify a new canonical SPM release. PolicyEngine/policyengine.py commit `3c3b4f6442f4a5adc47274734d71a6ca10103b43`, under `src/policyengine/data/bundle/`. -- `us-release_manifest.json`: published Populace release +- `us-release_manifest.json`: published Microcosm release `populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z`, at `https://huggingface.co/datasets/policyengine/populace-us/resolve/populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z/releases/populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z/release_manifest.json`. Its raw SHA256 is diff --git a/tests/test_be_axiom_pilot.py b/tests/test_be_axiom_pilot.py index b75aec797..1e5d5f465 100644 --- a/tests/test_be_axiom_pilot.py +++ b/tests/test_be_axiom_pilot.py @@ -25,7 +25,7 @@ REMUNERATION, AxiomBelgiumPilot, BEYearData, - PopulaceBelgiumDataset, + MicrocosmBelgiumDataset, ) from policyengine.tax_benefit_models.be import model as be_model_module @@ -155,7 +155,7 @@ def pilot_dataset(tmp_path): weights="household_weight", ) path = tmp_path / "microcosm_be_test.h5" - PopulaceBelgiumDataset( + MicrocosmBelgiumDataset( name="microcosm-be-test", description="four-person nonuniform-weight fixture", filepath=str(path), @@ -164,7 +164,7 @@ def pilot_dataset(tmp_path): data=BEYearData(person=person, household=household), ).save() # Exercise load(), including metadata and _time_period, during the run. - return PopulaceBelgiumDataset( + return MicrocosmBelgiumDataset( name="microcosm-be-test", description="four-person nonuniform-weight fixture", filepath=str(path), @@ -295,7 +295,7 @@ def test_output_metadata_round_trips_only_after_a_distinct_path_is_chosen( output.filepath = str(output_path) output.save() - reloaded = PopulaceBelgiumDataset( + reloaded = MicrocosmBelgiumDataset( name=output.name, description=output.description, filepath=str(output_path), @@ -309,7 +309,7 @@ def test_output_metadata_round_trips_only_after_a_distinct_path_is_chosen( def test_dataset_rejects_a_mislabeled_hdf5_period(pilot_dataset): - mislabeled = PopulaceBelgiumDataset( + mislabeled = MicrocosmBelgiumDataset( name=pilot_dataset.name, description=pilot_dataset.description, filepath=pilot_dataset.filepath, @@ -481,7 +481,7 @@ def test_dataset_rejects_a_mismatched_legacy_person_weight(tmp_path): time_period=2026, ).save(path) - dataset = PopulaceBelgiumDataset( + dataset = MicrocosmBelgiumDataset( name="legacy-mismatch", description="invalid redundant person weights", filepath=str(path), @@ -524,7 +524,7 @@ def test_real_source_stack_computes_the_worker_slice(pilot_dataset): @pytest.fixture def in_memory_pilot_dataset(): - return PopulaceBelgiumDataset( + return MicrocosmBelgiumDataset( name="in-memory-pilot", description="two-person household-authoritative weight fixture", year=2026, diff --git a/tests/test_certify_data_release.py b/tests/test_certify_data_release.py index 6da96eaa9..b3bc472b7 100644 --- a/tests/test_certify_data_release.py +++ b/tests/test_certify_data_release.py @@ -132,7 +132,7 @@ def _release_manifest_payload() -> dict: } -def _populace_manifest_payload_without_regions() -> dict: +def _microcosm_manifest_payload_without_regions() -> dict: payload = _release_manifest_payload() payload["metadata"] = {} payload["artifacts"].pop("states/AK") @@ -385,7 +385,7 @@ def test__given_manifest__then_pins_data_package_and_default(self): assert payload["model_package"]["sha256"] == "d" * 64 assert payload["model_package"]["wheel_url"] == "https://example/wheel" - def test__given_populace_area_h5_artifact__then_omits_it_from_runtime_bundle(self): + def test__given_microcosm_area_h5_artifact__then_omits_it_from_runtime_bundle(self): payload = self._payload() assert "states/AK" not in payload["datasets"] @@ -406,7 +406,7 @@ def test__given_release_scoped_diagnostics__then_rewrites_paths(self): f"releases/{TAG}/us_source_coverage.json" ) - def test__given_populace_region_templates__then_only_national_is_carried_through( + def test__given_microcosm_region_templates__then_only_national_is_carried_through( self, ): payload = self._payload() @@ -415,13 +415,13 @@ def test__given_populace_region_templates__then_only_national_is_carried_through "national": {"path_template": "populace_us_2024.h5"} } - def test__given_populace_manifest_without_regions__then_adds_national_template( + def test__given_microcosm_manifest_without_regions__then_adds_national_template( self, ): payload = build_country_manifest_payload( country="us", manifest=DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ), uri_parts=parse_manifest_uri(MANIFEST_URI), policyengine_version="9.9.9", @@ -452,7 +452,7 @@ def test__given_build_provenance__then_certification_carries_it(self): class TestMergeUSStateReleaseManifest: def test__given_state_manifest__then_does_not_vendor_state_region_artifacts(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) states = DataReleaseManifest.model_validate(_state_release_manifest_payload()) @@ -474,7 +474,7 @@ def test__given_state_manifest__then_does_not_vendor_state_region_artifacts(self def test__given_missing_state_artifact__then_raises(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) states = DataReleaseManifest.model_validate( _state_release_manifest_payload(missing={"CA"}) @@ -485,7 +485,7 @@ def test__given_missing_state_artifact__then_raises(self): def test__given_malformed_state_path__then_raises(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) states = DataReleaseManifest.model_validate( _state_release_manifest_payload(malformed={"CA": "state/CA.h5"}) @@ -496,7 +496,7 @@ def test__given_malformed_state_path__then_raises(self): def test__given_state_without_hash__then_raises(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) states = DataReleaseManifest.model_validate( _state_release_manifest_payload(without_hash={"CA"}) @@ -507,7 +507,7 @@ def test__given_state_without_hash__then_raises(self): def test__given_duplicate_state_artifact__then_warns_and_ignores_duplicate(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) state_payload = _state_release_manifest_payload() state_payload["artifacts"]["states/CA_duplicate"] = { @@ -529,7 +529,7 @@ def test__given_duplicate_state_artifact__then_warns_and_ignores_duplicate(self) class TestMergeUSLocalAreaReleaseManifest: def test__given_typed_local_area_release__then_certifies_shared_dataset(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) regional = DataReleaseManifest.model_validate( _local_area_release_manifest_payload() @@ -581,7 +581,7 @@ def test__given_invalid_release_role__then_rejects_it( message, ): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) regional_payload = _local_area_release_manifest_payload() regional_payload[field] = value @@ -592,7 +592,7 @@ def test__given_invalid_release_role__then_rejects_it( def test__given_more_than_one_microdata_artifact__then_rejects_it(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) regional_payload = _local_area_release_manifest_payload() regional_payload["artifacts"]["second"] = { @@ -606,7 +606,7 @@ def test__given_more_than_one_microdata_artifact__then_rejects_it(self): def test__given_legacy_regional_release__then_uses_state_merge(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) states = DataReleaseManifest.model_validate(_state_release_manifest_payload()) @@ -619,7 +619,7 @@ def test__given_legacy_regional_release__then_uses_state_merge(self): def test__given_unknown_regional_role__then_rejects_it(self): primary = DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ) regional_payload = _local_area_release_manifest_payload() regional_payload["dataset_role"] = "unknown" @@ -630,7 +630,7 @@ def test__given_unknown_regional_role__then_rejects_it(self): class TestCertifyDataRelease: - def test__given_fetched_populace_manifest__then_updates_bundle_manifest( + def test__given_fetched_microcosm_manifest__then_updates_bundle_manifest( self, tmp_path ): bundle_path = tmp_path / "manifest.json" @@ -694,7 +694,7 @@ def test__given_us_local_area_manifest__then_certifies_shared_regional_dataset( primary_response = MagicMock() primary_response.status_code = 200 primary_response.content = json.dumps( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ).encode() regional_response = MagicMock() regional_response.status_code = 200 @@ -827,7 +827,7 @@ def fake_main(argv: list[str]) -> int: "--skip-artifact-check", ] - def test__given_missing_populace_us_source_coverage__then_raises(self, tmp_path): + def test__given_missing_microcosm_us_source_coverage__then_raises(self, tmp_path): response = MagicMock() response.status_code = 200 response.content = json.dumps(_release_manifest_payload()).encode() @@ -1336,7 +1336,7 @@ def test__given_us_area_coded_national__then_rejects_it(self): merge_area_coded_national_release_manifest( "us", DataReleaseManifest.model_validate( - _populace_manifest_payload_without_regions() + _microcosm_manifest_payload_without_regions() ), DataReleaseManifest.model_validate(_efrs_release_payload()), ) diff --git a/tests/test_dataset_materialization.py b/tests/test_dataset_materialization.py index 5180ebd88..f7dfa04fa 100644 --- a/tests/test_dataset_materialization.py +++ b/tests/test_dataset_materialization.py @@ -77,7 +77,7 @@ def test_resolve_bundle_dataset_uses_cross_package_overlay(tmp_path): assert dataset.revision == "populace-release" -def test_bundled_uk_populace_dataset_uses_dataset_repository_url(): +def test_bundled_uk_microcosm_dataset_uses_dataset_repository_url(): dataset = _resolve_bundle_dataset("uk", "populace_uk_2023") url = https_dataset_uri( @@ -163,7 +163,7 @@ def test_country_data_package_uses_model_repository_url(tmp_path): ) -def test_populace_package_uses_dataset_repository_url(tmp_path): +def test_microcosm_package_uses_dataset_repository_url(tmp_path): session = _Session(_Response(b"populace-data")) manifest = _manifest_with_hash( _sha256(b"populace-data"), diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py new file mode 100644 index 000000000..b96af55cf --- /dev/null +++ b/tests/test_microcosm_compatibility.py @@ -0,0 +1,136 @@ +"""Public Microcosm names retain their previous import aliases.""" + +import runpy +from importlib import import_module +from pathlib import Path +from types import SimpleNamespace +from unittest.mock import Mock + +import numpy as np +import pytest + +from policyengine.provenance.certification import ( + MicrocosmDataProducerCertificationStrategy, + certification_strategy, +) + + +@pytest.mark.parametrize( + "module_name,current_name,legacy_name", + [ + ( + "policyengine.tax_benefit_models.be", + "MicrocosmBelgiumDataset", + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.tax_benefit_models.be.datasets", + "MicrocosmBelgiumDataset", + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.tax_benefit_models.be.model", + "MicrocosmBelgiumDataset", + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.provenance.certification", + "MicrocosmDataProducerCertificationStrategy", + "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.provenance.certification", + "MICROCOSM_US_SOURCE_COVERAGE_FILE", + "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.provenance.certification", + "MICROCOSM_DATA_PACKAGES", + "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.provenance.certification", + "MICROCOSM_RELEASE_REPOS", + "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.tax_benefit_models.us.legacy_spm.registry", + "MICROCOSM_US_2024_ACS_LOCAL_BUILD_O", + "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.16.1 + ), + ( + "policyengine.tax_benefit_models.us.legacy_spm.registry", + "MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263", + "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.16.1 + ), + ], +) +def test_previous_public_names_resolve_to_current_objects( + module_name, current_name, legacy_name +): + module = import_module(module_name) + + assert getattr(module, legacy_name) is getattr(module, current_name) + + +@pytest.mark.parametrize( + "country,data_producer", + [("uk", None), ("uk", "populace"), ("us", "populace")], +) +def test_current_certification_strategy_preserves_the_published_producer( + country, data_producer +): + strategy = certification_strategy(country, data_producer) + + assert type(strategy) is MicrocosmDataProducerCertificationStrategy + assert strategy.data_producer == "populace" + + +@pytest.mark.parametrize( + "current_path,legacy_path,expected_path", + [ + ("current.h5", None, "current.h5"), + (None, "legacy.h5", "legacy.h5"), + ("current.h5", "legacy.h5", "current.h5"), + ], +) +def test_belgium_example_accepts_both_dataset_environment_names( + monkeypatch, current_path, legacy_path, expected_path +): + be = import_module("policyengine.tax_benefit_models.be") + simulation_module = import_module("policyengine.core.simulation") + legacy_env_name = ( + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.16.1 + ) + for name, value in ( + ("MICROCOSM_BE_DATASET", current_path), + (legacy_env_name, legacy_path), + ): + if value is None: + monkeypatch.delenv(name, raising=False) + else: + monkeypatch.setenv(name, value) + monkeypatch.setenv("RULESPEC_BE_ROOT", "test-rules") + dataset_type = Mock() + model_type = Mock(return_value=SimpleNamespace(version="test-model")) + output = SimpleNamespace( + year=2026, + policy_period=2025, + data=SimpleNamespace( + person={ + be.EMPLOYEE_SSC: np.asarray([0.0]), + be.PIT_BEFORE_WITHHOLDING: np.asarray([0.0]), + } + ), + ) + simulation = Mock(output_dataset=output) + monkeypatch.setattr(be, "MicrocosmBelgiumDataset", dataset_type) + monkeypatch.setattr(be, "AxiomBelgiumPilot", model_type) + monkeypatch.setattr(simulation_module, "Simulation", Mock(return_value=simulation)) + + runpy.run_path( + Path(__file__).resolve().parents[1] / "examples/belgium_axiom_pilot.py" + ) + + assert dataset_type.call_args.kwargs["filepath"] == expected_path + simulation.run.assert_called_once_with() diff --git a/tests/test_release_manifests.py b/tests/test_release_manifests.py index a4c6cca9d..448aae0d9 100644 --- a/tests/test_release_manifests.py +++ b/tests/test_release_manifests.py @@ -89,10 +89,10 @@ "hf://policyengine/policyengine-uk-data-private/frs_2024_25.h5@1.58.1" ) # The prior certified default, kept resolvable via dataset_overlays. -UK_POPULACE_RELEASE_ID = "populace-uk-2023-dd68c73-4aa4b14-20260619T023711Z" -UK_POPULACE_DATASET_URI = ( +UK_MICROCOSM_RELEASE_ID = "populace-uk-2023-dd68c73-4aa4b14-20260619T023711Z" +UK_MICROCOSM_DATASET_URI = ( f"hf://policyengine/populace-uk-private/populace_uk_2023.h5" - f"@{UK_POPULACE_RELEASE_ID}" + f"@{UK_MICROCOSM_RELEASE_ID}" ) UK_CERTIFICATION_SOURCE = "policyengine.py bundle certification" UK_CERTIFIED_DATASET_URI = ( @@ -363,7 +363,7 @@ def test__given_uk_legacy_dataset_names__then_resolves_bundled_aliases(self): ) assert ( resolve_dataset_reference("uk", "populace_uk_2023") - == UK_POPULACE_DATASET_URI + == UK_MICROCOSM_DATASET_URI ) assert ( resolve_dataset_reference("uk", "enhanced_frs_2024_25") @@ -377,7 +377,7 @@ def test__given_explicit_url__then_resolution_is_noop(self): assert resolve_dataset_reference("us", url) == url def test__given_existing_local_path__then_resolution_is_noop(self, tmp_path): - dataset = tmp_path / "smoke_test_populace_us_2024.h5" + dataset = tmp_path / "smoke_test_microcosm_us_2024.h5" dataset.write_bytes(b"") assert resolve_dataset_reference("us", str(dataset)) == str(dataset) @@ -500,7 +500,7 @@ def test__given_explicit_uri__then_managed_resolution_requires_opt_in(self): ) def test__given_local_path__then_managed_resolution_requires_opt_in(self, tmp_path): - dataset = tmp_path / "smoke_test_populace_us_2024.h5" + dataset = tmp_path / "smoke_test_microcosm_us_2024.h5" dataset.write_bytes(b"") try: diff --git a/tests/test_us_legacy_inputs_integration.py b/tests/test_us_legacy_inputs_integration.py index 89471146a..23a445123 100644 --- a/tests/test_us_legacy_inputs_integration.py +++ b/tests/test_us_legacy_inputs_integration.py @@ -161,7 +161,7 @@ def mapped_run(tmp_path_factory): def mapped_managed(tmp_path_factory): """Load path 2 over the household's entity-table file, mapping on.""" path = _write_entity_tables( - tmp_path_factory.mktemp("mapped_managed") / "populace_layout.h5" + tmp_path_factory.mktemp("mapped_managed") / "microcosm_layout.h5" ) return pe.us.managed_microsimulation(dataset=path, allow_unmanaged=True) @@ -432,7 +432,7 @@ def test_managed_without_the_mapping_gives_every_eligible_person_wic( tmp_path, monkeypatch ): monkeypatch.setattr(legacy_inputs, "LEGACY_INPUT_RENAMES", {}) - path = _write_entity_tables(tmp_path / "populace_layout.h5") + path = _write_entity_tables(tmp_path / "microcosm_layout.h5") microsim = pe.us.managed_microsimulation(dataset=path, allow_unmanaged=True) eligible = microsim.calculate("is_wic_eligible", MONTHS[0]).values @@ -445,7 +445,7 @@ def test_managed_without_the_mapping_gives_every_eligible_person_wic( def test_managed_reform_maps_its_baseline_too(tmp_path): - path = _write_entity_tables(tmp_path / "populace_layout.h5") + path = _write_entity_tables(tmp_path / "microcosm_layout.h5") microsim = pe.us.managed_microsimulation( dataset=path, allow_unmanaged=True, @@ -482,7 +482,7 @@ def test_managed_core_h5_with_a_part_year_draw_is_refused(tmp_path): def engine_microsim(tmp_path_factory): """A real managed Microsimulation the property below maps draws onto.""" path = _write_entity_tables( - tmp_path_factory.mktemp("engine_microsim") / "populace_layout.h5" + tmp_path_factory.mktemp("engine_microsim") / "microcosm_layout.h5" ) return pe.us.managed_microsimulation(dataset=path, allow_unmanaged=True) @@ -545,7 +545,7 @@ def test_both_load_paths_give_the_same_take_up_and_wic(mapped_run, mapped_manage def _create_year_file(directory): """Cut the household's entity-table file into a year file.""" - source = _write_entity_tables(directory / "populace_layout.h5") + source = _write_entity_tables(directory / "microcosm_layout.h5") created = create_datasets( datasets=[source], years=[YEAR], @@ -771,7 +771,7 @@ def test_ensure_datasets_regenerates_a_year_file_with_only_the_renames_record( def test_create_datasets_stamps_each_year_file_after_saving_it(tmp_path): - source = _write_entity_tables(tmp_path / "populace_layout.h5") + source = _write_entity_tables(tmp_path / "microcosm_layout.h5") events = [] save = PolicyEngineUSDataset.save stamp = us_datasets.write_year_file_stamp @@ -807,7 +807,7 @@ def recording_stamp(path, value): def test_a_year_file_whose_stamp_was_never_written_is_out_of_date(tmp_path): - source = _write_entity_tables(tmp_path / "populace_layout.h5") + source = _write_entity_tables(tmp_path / "microcosm_layout.h5") def stop(path, value): raise RuntimeError("stopped before stamping") diff --git a/tests/test_us_legacy_spm.py b/tests/test_us_legacy_spm.py index 7654cee5d..3a78c5622 100644 --- a/tests/test_us_legacy_spm.py +++ b/tests/test_us_legacy_spm.py @@ -39,17 +39,17 @@ independence_roles, ) from policyengine.tax_benefit_models.us.legacy_spm.registry import ( - POPULACE_US_2024_ACS_LOCAL_BUILD_O, - POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263, + MICROCOSM_US_2024_ACS_LOCAL_BUILD_O, + MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263, ) from policyengine.tax_benefit_models.us.legacy_spm.universe import ( classify_acs_household_population, ) ACS = "acs_2024_1yr" -BUILD_O = POPULACE_US_2024_ACS_LOCAL_BUILD_O +BUILD_O = MICROCOSM_US_2024_ACS_LOCAL_BUILD_O #: The bundle's certified ACS-local file: scope rule only, roles stored. -REBUILD = POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 +REBUILD = MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 def _tables(): diff --git a/tests/test_us_legacy_spm_integration.py b/tests/test_us_legacy_spm_integration.py index 22c3b85ca..7d4c8c776 100644 --- a/tests/test_us_legacy_spm_integration.py +++ b/tests/test_us_legacy_spm_integration.py @@ -69,15 +69,15 @@ SPM_MEASUREMENT_VARIABLES, ) from policyengine.tax_benefit_models.us.legacy_spm.registry import ( # noqa: E402 - POPULACE_US_2024_ACS_LOCAL_BUILD_O, - POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263, + MICROCOSM_US_2024_ACS_LOCAL_BUILD_O, + MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263, ) from policyengine.tax_benefit_models.us.model import PolicyEngineUSLatest # noqa: E402 # The ``us`` package's ``model`` attribute is the model version, not the module. us_model = importlib.import_module("policyengine.tax_benefit_models.us.model") -BUILD_O = POPULACE_US_2024_ACS_LOCAL_BUILD_O +BUILD_O = MICROCOSM_US_2024_ACS_LOCAL_BUILD_O LIST_PIN = BUILD_O.independence_list YEAR = 2026 ACS = "acs_2024_1yr" @@ -792,7 +792,7 @@ def test_other_sources_get_no_declarations(tmp_path): # --- The microcosm#1263 rebuild: scope rule, roles stored ------------------- -REBUILD = POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 +REBUILD = MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 #: The roles the rebuilt source stores: ACS head, ASEC head and the ASEC teen #: who heads their own SPM unit. REBUILD_ROLES = [True, False, False, False, True, True] From 06d7897e085c8b8f0c9b6653e95d06dd44221abb Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 14:12:12 -0500 Subject: [PATCH 05/10] Make the changelog fragment describe only this PR The generic fragment said the stack was renamed "throughout docs, comments and code", which claims more than this diff does. Co-Authored-By: Claude Opus 5.5 --- changelog.d/microcosm-name-sweep-20261106.changed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/microcosm-name-sweep-20261106.changed.md b/changelog.d/microcosm-name-sweep-20261106.changed.md index 6f873e5ca..a39bf684d 100644 --- a/changelog.d/microcosm-name-sweep-20261106.changed.md +++ b/changelog.d/microcosm-name-sweep-20261106.changed.md @@ -1 +1 @@ -Name the microdata stack Microcosm throughout docs, comments and code. +Give the Belgian dataset class, the data-producer certification strategy and the certification and legacy-SPM constants Microcosm names, keeping the previous names as aliases through 6.16.1. From 6a1d89f67d2fd15afd5bd522885182e7772322f0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 9 Nov 2026 14:01:49 -0500 Subject: [PATCH 06/10] Keep the previous names as aliases through 6.17.0 Main released 6.16.1 without this change, and its pending added fragment makes the next release 6.17.0, so the aliases first ship there. Move every "remove after" marker and the changelog fragment to 6.17.0. Co-Authored-By: Claude Opus 5.5 --- .../microcosm-name-sweep-20261106.changed.md | 2 +- examples/belgium_axiom_pilot.py | 2 +- src/policyengine/provenance/certification.py | 8 ++++---- .../tax_benefit_models/be/__init__.py | 4 ++-- .../tax_benefit_models/be/datasets.py | 2 +- .../tax_benefit_models/be/model.py | 2 +- .../us/legacy_spm/registry.py | 4 ++-- tests/test_microcosm_compatibility.py | 20 +++++++++---------- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/changelog.d/microcosm-name-sweep-20261106.changed.md b/changelog.d/microcosm-name-sweep-20261106.changed.md index a39bf684d..803256847 100644 --- a/changelog.d/microcosm-name-sweep-20261106.changed.md +++ b/changelog.d/microcosm-name-sweep-20261106.changed.md @@ -1 +1 @@ -Give the Belgian dataset class, the data-producer certification strategy and the certification and legacy-SPM constants Microcosm names, keeping the previous names as aliases through 6.16.1. +Give the Belgian dataset class, the data-producer certification strategy and the certification and legacy-SPM constants Microcosm names, keeping the previous names as aliases through 6.17.0. diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index 1e606d1b4..a65e5a801 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -37,7 +37,7 @@ DATASET = os.environ.get("MICROCOSM_BE_DATASET") if DATASET is None: DATASET = os.environ[ - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.16.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.17.0 ] RULESPEC = os.environ.get("RULESPEC_BE_ROOT", "~/TheAxiomFoundation/rulespec-be") diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index add5fbc74..a7c3f293a 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -119,13 +119,13 @@ "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", } -POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.16.1 +POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.17.0 MICROCOSM_US_SOURCE_COVERAGE_FILE ) -POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.16.1 +POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.17.0 MICROCOSM_DATA_PACKAGES ) -POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.16.1 +POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.17.0 MICROCOSM_RELEASE_REPOS ) # Region types a regional release serves. Their regions load the routed dataset @@ -1764,7 +1764,7 @@ def certify( ) -PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.16.1 +PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.17.0 MicrocosmDataProducerCertificationStrategy ) diff --git a/src/policyengine/tax_benefit_models/be/__init__.py b/src/policyengine/tax_benefit_models/be/__init__.py index 1ff95c263..7d81599d5 100644 --- a/src/policyengine/tax_benefit_models/be/__init__.py +++ b/src/policyengine/tax_benefit_models/be/__init__.py @@ -17,7 +17,7 @@ be_model, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 MicrocosmBelgiumDataset ) @@ -28,7 +28,7 @@ "EMPLOYEE_SSC", "PIT_BEFORE_WITHHOLDING", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 "REMUNERATION", "be_model", ] diff --git a/src/policyengine/tax_benefit_models/be/datasets.py b/src/policyengine/tax_benefit_models/be/datasets.py index 6797f3657..86110d645 100644 --- a/src/policyengine/tax_benefit_models/be/datasets.py +++ b/src/policyengine/tax_benefit_models/be/datasets.py @@ -190,6 +190,6 @@ def save(self) -> None: ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index f662d4f6a..0a224680e 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -50,7 +50,7 @@ _person_with_household_weights, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.16.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py index dc268892e..97c9eef41 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py +++ b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py @@ -91,10 +91,10 @@ class LegacySPMSource(BaseModel): spm_universe_rule="acs_household_population", ) -POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.16.1 +POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.17.0 MICROCOSM_US_2024_ACS_LOCAL_BUILD_O ) -POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.16.1 +POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.17.0 MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 ) diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py index b96af55cf..df9b06bc6 100644 --- a/tests/test_microcosm_compatibility.py +++ b/tests/test_microcosm_compatibility.py @@ -21,47 +21,47 @@ ( "policyengine.tax_benefit_models.be", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.tax_benefit_models.be.datasets", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.tax_benefit_models.be.model", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.16.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.provenance.certification", "MicrocosmDataProducerCertificationStrategy", - "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.16.1 + "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.provenance.certification", "MICROCOSM_US_SOURCE_COVERAGE_FILE", - "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.16.1 + "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.provenance.certification", "MICROCOSM_DATA_PACKAGES", - "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.16.1 + "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.provenance.certification", "MICROCOSM_RELEASE_REPOS", - "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.16.1 + "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_BUILD_O", - "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.16.1 + "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.17.0 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263", - "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.16.1 + "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.17.0 ), ], ) @@ -100,7 +100,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( be = import_module("policyengine.tax_benefit_models.be") simulation_module = import_module("policyengine.core.simulation") legacy_env_name = ( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.16.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.17.0 ) for name, value in ( ("MICROCOSM_BE_DATASET", current_path), From 1c5c61aa63df50a6194826c0a6c77480dea4ebaa Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 9 Nov 2026 14:44:02 -0500 Subject: [PATCH 07/10] Exit with the new variable's name when the Belgian example lacks a dataset - examples/belgium_axiom_pilot.py exits with a message naming MICROCOSM_BE_DATASET when neither dataset variable is set, instead of a KeyError naming the former one; a new test covers it. - The certification CLI help names the producer value it accepts. - The runbook names the US release repository by its id. - The 2023 UK test constants say so in their names. - The changelog fragment no longer names a release. Co-Authored-By: Claude Opus 5.5 --- .../microcosm-name-sweep-20261106.changed.md | 2 +- .../runbooks/build-m-us-populace-certification.md | 2 +- docs/regions.md | 2 +- examples/belgium_axiom_pilot.py | 8 ++++++-- scripts/certify_data_release.py | 2 +- tests/test_microcosm_compatibility.py | 13 +++++++++++++ tests/test_release_manifests.py | 8 ++++---- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/changelog.d/microcosm-name-sweep-20261106.changed.md b/changelog.d/microcosm-name-sweep-20261106.changed.md index 803256847..11cbab8f6 100644 --- a/changelog.d/microcosm-name-sweep-20261106.changed.md +++ b/changelog.d/microcosm-name-sweep-20261106.changed.md @@ -1 +1 @@ -Give the Belgian dataset class, the data-producer certification strategy and the certification and legacy-SPM constants Microcosm names, keeping the previous names as aliases through 6.17.0. +Give the Belgian dataset class, the data-producer certification strategy and the certification and legacy-SPM constants Microcosm names, keeping the previous names as aliases. diff --git a/docs/engineering/runbooks/build-m-us-populace-certification.md b/docs/engineering/runbooks/build-m-us-populace-certification.md index 81849a25e..c69f77986 100644 --- a/docs/engineering/runbooks/build-m-us-populace-certification.md +++ b/docs/engineering/runbooks/build-m-us-populace-certification.md @@ -25,7 +25,7 @@ interim exception in Step 2 holds). metadata and runs reachability `HEAD` checks against Hugging Face. - `HUGGING_FACE_TOKEN` (or `HF_TOKEN`) exported — required to regenerate the UK TRO in the `--include-tros` step and to run the UK data-release fetch in - the test suite. The US microcosm repo is public. + the test suite. The US release repo, `policyengine/populace-us`, is public. ## Step 1 — identify the releases diff --git a/docs/regions.md b/docs/regions.md index 0ba28ba8f..b1c8eea9d 100644 --- a/docs/regions.md +++ b/docs/regions.md @@ -218,7 +218,7 @@ df.groupby("geo").apply(lambda g: (g["change"] * g["weight"]).sum() / g["weight" ## Scoping datasets to a region -For reforms defined only over a sub-national slice, pass a scoping strategy to `Simulation`. `RowFilterStrategy` keeps only matching households. `WeightReplacementStrategy` is legacy matrix infrastructure and is not used by the UK Microcosm constituency or local-authority registry. +For reforms defined only over a sub-national slice, pass a scoping strategy to `Simulation`. `RowFilterStrategy` keeps only matching households. `WeightReplacementStrategy` is legacy matrix infrastructure; neither the UK Microcosm constituency registry nor its local-authority registry uses it. ```python from policyengine.core.scoping_strategy import RowFilterStrategy diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index a65e5a801..cf7875e31 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -36,9 +36,13 @@ DATASET = os.environ.get("MICROCOSM_BE_DATASET") if DATASET is None: - DATASET = os.environ[ + DATASET = os.environ.get( "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.17.0 - ] + ) +if DATASET is None: + raise SystemExit( + "Set MICROCOSM_BE_DATASET to the Microcosm-BE pilot dataset's .h5 path." + ) RULESPEC = os.environ.get("RULESPEC_BE_ROOT", "~/TheAxiomFoundation/rulespec-be") # Ledger facts (PolicyEngine/ledger, Belgian publisher packages) diff --git a/scripts/certify_data_release.py b/scripts/certify_data_release.py index d365c307b..60b0c9b6c 100644 --- a/scripts/certify_data_release.py +++ b/scripts/certify_data_release.py @@ -48,7 +48,7 @@ def main(argv=None) -> int: "--data-producer", default=None, choices=["legacy", "populace"], - help="Data-producer strategy. Defaults to Microcosm for UK, legacy otherwise.", + help="Data-producer strategy. Defaults to populace for UK, legacy otherwise.", ) parser.add_argument( "--manifest-uri", diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py index df9b06bc6..53d2ac39d 100644 --- a/tests/test_microcosm_compatibility.py +++ b/tests/test_microcosm_compatibility.py @@ -134,3 +134,16 @@ def test_belgium_example_accepts_both_dataset_environment_names( assert dataset_type.call_args.kwargs["filepath"] == expected_path simulation.run.assert_called_once_with() + + +def test_belgium_example_names_the_new_variable_when_neither_is_set(monkeypatch): + for name in ( + "MICROCOSM_BE_DATASET", + "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.17.0 + ): + monkeypatch.delenv(name, raising=False) + + with pytest.raises(SystemExit, match="MICROCOSM_BE_DATASET"): + runpy.run_path( + Path(__file__).resolve().parents[1] / "examples/belgium_axiom_pilot.py" + ) diff --git a/tests/test_release_manifests.py b/tests/test_release_manifests.py index 4b36619aa..19245fb68 100644 --- a/tests/test_release_manifests.py +++ b/tests/test_release_manifests.py @@ -89,10 +89,10 @@ "hf://policyengine/policyengine-uk-data-private/frs_2024_25.h5@1.58.1" ) # The prior certified default, kept resolvable via dataset_overlays. -UK_MICROCOSM_RELEASE_ID = "populace-uk-2023-dd68c73-4aa4b14-20260619T023711Z" -UK_MICROCOSM_DATASET_URI = ( +UK_MICROCOSM_2023_RELEASE_ID = "populace-uk-2023-dd68c73-4aa4b14-20260619T023711Z" +UK_MICROCOSM_2023_DATASET_URI = ( f"hf://policyengine/populace-uk-private/populace_uk_2023.h5" - f"@{UK_MICROCOSM_RELEASE_ID}" + f"@{UK_MICROCOSM_2023_RELEASE_ID}" ) UK_CERTIFICATION_SOURCE = "policyengine.py bundle certification" UK_CERTIFIED_DATASET_URI = ( @@ -363,7 +363,7 @@ def test__given_uk_legacy_dataset_names__then_resolves_bundled_aliases(self): ) assert ( resolve_dataset_reference("uk", "populace_uk_2023") - == UK_MICROCOSM_DATASET_URI + == UK_MICROCOSM_2023_DATASET_URI ) assert ( resolve_dataset_reference("uk", "enhanced_frs_2024_25") From 6f624ab3576e609e4d12f88bc9b6ddeee0e961e8 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 15 Nov 2026 22:34:51 -0500 Subject: [PATCH 08/10] Mark the aliases for removal after 6.19.1, the release that first ships them Main released 6.17.0 through 6.19.0 since the markers named 6.17.0, and its changelog.d now holds only this PR's patch fragment, so .github/bump_version.py cuts 6.19.1 from it. Co-Authored-By: Claude Opus 5.5 --- examples/belgium_axiom_pilot.py | 2 +- src/policyengine/provenance/certification.py | 8 +++---- .../tax_benefit_models/be/__init__.py | 4 ++-- .../tax_benefit_models/be/datasets.py | 2 +- .../tax_benefit_models/be/model.py | 2 +- .../us/legacy_spm/registry.py | 4 ++-- tests/test_microcosm_compatibility.py | 22 +++++++++---------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index cf7875e31..47ebfb49b 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -37,7 +37,7 @@ DATASET = os.environ.get("MICROCOSM_BE_DATASET") if DATASET is None: DATASET = os.environ.get( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.17.0 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.19.1 ) if DATASET is None: raise SystemExit( diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index a7c3f293a..9fe8f8165 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -119,13 +119,13 @@ "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", } -POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.17.0 +POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.19.1 MICROCOSM_US_SOURCE_COVERAGE_FILE ) -POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.17.0 +POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.19.1 MICROCOSM_DATA_PACKAGES ) -POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.17.0 +POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.19.1 MICROCOSM_RELEASE_REPOS ) # Region types a regional release serves. Their regions load the routed dataset @@ -1764,7 +1764,7 @@ def certify( ) -PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.17.0 +PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.19.1 MicrocosmDataProducerCertificationStrategy ) diff --git a/src/policyengine/tax_benefit_models/be/__init__.py b/src/policyengine/tax_benefit_models/be/__init__.py index 7d81599d5..ceaf765dc 100644 --- a/src/policyengine/tax_benefit_models/be/__init__.py +++ b/src/policyengine/tax_benefit_models/be/__init__.py @@ -17,7 +17,7 @@ be_model, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 MicrocosmBelgiumDataset ) @@ -28,7 +28,7 @@ "EMPLOYEE_SSC", "PIT_BEFORE_WITHHOLDING", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 "REMUNERATION", "be_model", ] diff --git a/src/policyengine/tax_benefit_models/be/datasets.py b/src/policyengine/tax_benefit_models/be/datasets.py index 86110d645..20501fcf7 100644 --- a/src/policyengine/tax_benefit_models/be/datasets.py +++ b/src/policyengine/tax_benefit_models/be/datasets.py @@ -190,6 +190,6 @@ def save(self) -> None: ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index 0a224680e..75dec4e82 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -50,7 +50,7 @@ _person_with_household_weights, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.17.0 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py index 97c9eef41..c22ad88d7 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py +++ b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py @@ -91,10 +91,10 @@ class LegacySPMSource(BaseModel): spm_universe_rule="acs_household_population", ) -POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.17.0 +POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.19.1 MICROCOSM_US_2024_ACS_LOCAL_BUILD_O ) -POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.17.0 +POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.19.1 MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 ) diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py index 53d2ac39d..44fde3c8d 100644 --- a/tests/test_microcosm_compatibility.py +++ b/tests/test_microcosm_compatibility.py @@ -21,47 +21,47 @@ ( "policyengine.tax_benefit_models.be", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.tax_benefit_models.be.datasets", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.tax_benefit_models.be.model", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.17.0 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.provenance.certification", "MicrocosmDataProducerCertificationStrategy", - "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.17.0 + "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.provenance.certification", "MICROCOSM_US_SOURCE_COVERAGE_FILE", - "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.17.0 + "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.provenance.certification", "MICROCOSM_DATA_PACKAGES", - "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.17.0 + "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.provenance.certification", "MICROCOSM_RELEASE_REPOS", - "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.17.0 + "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_BUILD_O", - "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.17.0 + "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.19.1 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263", - "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.17.0 + "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.19.1 ), ], ) @@ -100,7 +100,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( be = import_module("policyengine.tax_benefit_models.be") simulation_module = import_module("policyengine.core.simulation") legacy_env_name = ( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.17.0 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.19.1 ) for name, value in ( ("MICROCOSM_BE_DATASET", current_path), @@ -139,7 +139,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( def test_belgium_example_names_the_new_variable_when_neither_is_set(monkeypatch): for name in ( "MICROCOSM_BE_DATASET", - "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.17.0 + "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.19.1 ): monkeypatch.delenv(name, raising=False) From 3547c9fb931bdae513d6a4ec4281e4b3ac1e171e Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 11:23:32 -0500 Subject: [PATCH 09/10] Mark the compat aliases for removal after 6.20.1 Main released 6.20.0 before this PR merged, so the PR's patch fragment cuts 6.20.1, the first release that ships the aliases. The 22 markers move from 6.19.1 to 6.20.1; nothing else changes. Co-Authored-By: Claude Opus 5.5 --- examples/belgium_axiom_pilot.py | 2 +- src/policyengine/provenance/certification.py | 8 +++---- .../tax_benefit_models/be/__init__.py | 4 ++-- .../tax_benefit_models/be/datasets.py | 2 +- .../tax_benefit_models/be/model.py | 2 +- .../us/legacy_spm/registry.py | 4 ++-- tests/test_microcosm_compatibility.py | 22 +++++++++---------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index 47ebfb49b..17383bbb7 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -37,7 +37,7 @@ DATASET = os.environ.get("MICROCOSM_BE_DATASET") if DATASET is None: DATASET = os.environ.get( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.19.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.1 ) if DATASET is None: raise SystemExit( diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index ab9163d32..0d1eedc2b 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -119,13 +119,13 @@ "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", } -POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.19.1 +POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.20.1 MICROCOSM_US_SOURCE_COVERAGE_FILE ) -POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.19.1 +POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.20.1 MICROCOSM_DATA_PACKAGES ) -POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.19.1 +POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.20.1 MICROCOSM_RELEASE_REPOS ) # Region types a regional release serves. Their regions load the routed dataset @@ -1761,7 +1761,7 @@ def certify( ) -PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.19.1 +PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.20.1 MicrocosmDataProducerCertificationStrategy ) diff --git a/src/policyengine/tax_benefit_models/be/__init__.py b/src/policyengine/tax_benefit_models/be/__init__.py index ceaf765dc..1f06b434c 100644 --- a/src/policyengine/tax_benefit_models/be/__init__.py +++ b/src/policyengine/tax_benefit_models/be/__init__.py @@ -17,7 +17,7 @@ be_model, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 MicrocosmBelgiumDataset ) @@ -28,7 +28,7 @@ "EMPLOYEE_SSC", "PIT_BEFORE_WITHHOLDING", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 "REMUNERATION", "be_model", ] diff --git a/src/policyengine/tax_benefit_models/be/datasets.py b/src/policyengine/tax_benefit_models/be/datasets.py index 20501fcf7..b709f388a 100644 --- a/src/policyengine/tax_benefit_models/be/datasets.py +++ b/src/policyengine/tax_benefit_models/be/datasets.py @@ -190,6 +190,6 @@ def save(self) -> None: ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index 75dec4e82..d9f35880a 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -50,7 +50,7 @@ _person_with_household_weights, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.19.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py index c22ad88d7..4d6e9130e 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py +++ b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py @@ -91,10 +91,10 @@ class LegacySPMSource(BaseModel): spm_universe_rule="acs_household_population", ) -POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.19.1 +POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.20.1 MICROCOSM_US_2024_ACS_LOCAL_BUILD_O ) -POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.19.1 +POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.20.1 MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 ) diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py index 44fde3c8d..40bfd2352 100644 --- a/tests/test_microcosm_compatibility.py +++ b/tests/test_microcosm_compatibility.py @@ -21,47 +21,47 @@ ( "policyengine.tax_benefit_models.be", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.tax_benefit_models.be.datasets", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.tax_benefit_models.be.model", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.19.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.provenance.certification", "MicrocosmDataProducerCertificationStrategy", - "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.19.1 + "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.provenance.certification", "MICROCOSM_US_SOURCE_COVERAGE_FILE", - "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.19.1 + "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.provenance.certification", "MICROCOSM_DATA_PACKAGES", - "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.19.1 + "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.provenance.certification", "MICROCOSM_RELEASE_REPOS", - "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.19.1 + "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_BUILD_O", - "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.19.1 + "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.20.1 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263", - "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.19.1 + "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.20.1 ), ], ) @@ -100,7 +100,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( be = import_module("policyengine.tax_benefit_models.be") simulation_module = import_module("policyengine.core.simulation") legacy_env_name = ( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.19.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.1 ) for name, value in ( ("MICROCOSM_BE_DATASET", current_path), @@ -139,7 +139,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( def test_belgium_example_names_the_new_variable_when_neither_is_set(monkeypatch): for name in ( "MICROCOSM_BE_DATASET", - "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.19.1 + "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.20.1 ): monkeypatch.delenv(name, raising=False) From 0d4ed6d3dcea3e582ff84a3678de8b6388484218 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 15:24:45 -0500 Subject: [PATCH 10/10] Mark the compat aliases for removal after 6.20.2 Main released 6.20.1 from #759's fragment before this PR merged, so the PR's patch fragment now cuts 6.20.2, the first release that ships the aliases. The 22 markers move from 6.20.1 to 6.20.2; nothing else changes. Co-Authored-By: Claude Opus 5.5 --- examples/belgium_axiom_pilot.py | 2 +- src/policyengine/provenance/certification.py | 8 +++---- .../tax_benefit_models/be/__init__.py | 4 ++-- .../tax_benefit_models/be/datasets.py | 2 +- .../tax_benefit_models/be/model.py | 2 +- .../us/legacy_spm/registry.py | 4 ++-- tests/test_microcosm_compatibility.py | 22 +++++++++---------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/belgium_axiom_pilot.py b/examples/belgium_axiom_pilot.py index 17383bbb7..5c77fa576 100644 --- a/examples/belgium_axiom_pilot.py +++ b/examples/belgium_axiom_pilot.py @@ -37,7 +37,7 @@ DATASET = os.environ.get("MICROCOSM_BE_DATASET") if DATASET is None: DATASET = os.environ.get( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.2 ) if DATASET is None: raise SystemExit( diff --git a/src/policyengine/provenance/certification.py b/src/policyengine/provenance/certification.py index 0d1eedc2b..72a278903 100644 --- a/src/policyengine/provenance/certification.py +++ b/src/policyengine/provenance/certification.py @@ -119,13 +119,13 @@ "us": "policyengine/populace-us", "uk": "policyengine/populace-uk-private", } -POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.20.1 +POPULACE_US_SOURCE_COVERAGE_FILE = ( # compat: populace alias, remove after 6.20.2 MICROCOSM_US_SOURCE_COVERAGE_FILE ) -POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.20.1 +POPULACE_DATA_PACKAGES = ( # compat: populace alias, remove after 6.20.2 MICROCOSM_DATA_PACKAGES ) -POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.20.1 +POPULACE_RELEASE_REPOS = ( # compat: populace alias, remove after 6.20.2 MICROCOSM_RELEASE_REPOS ) # Region types a regional release serves. Their regions load the routed dataset @@ -1761,7 +1761,7 @@ def certify( ) -PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.20.1 +PopulaceDataProducerCertificationStrategy = ( # compat: populace alias, remove after 6.20.2 MicrocosmDataProducerCertificationStrategy ) diff --git a/src/policyengine/tax_benefit_models/be/__init__.py b/src/policyengine/tax_benefit_models/be/__init__.py index 1f06b434c..4ab6be709 100644 --- a/src/policyengine/tax_benefit_models/be/__init__.py +++ b/src/policyengine/tax_benefit_models/be/__init__.py @@ -17,7 +17,7 @@ be_model, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.2 MicrocosmBelgiumDataset ) @@ -28,7 +28,7 @@ "EMPLOYEE_SSC", "PIT_BEFORE_WITHHOLDING", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.2 "REMUNERATION", "be_model", ] diff --git a/src/policyengine/tax_benefit_models/be/datasets.py b/src/policyengine/tax_benefit_models/be/datasets.py index b709f388a..c1b4f1832 100644 --- a/src/policyengine/tax_benefit_models/be/datasets.py +++ b/src/policyengine/tax_benefit_models/be/datasets.py @@ -190,6 +190,6 @@ def save(self) -> None: ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.2 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/be/model.py b/src/policyengine/tax_benefit_models/be/model.py index d9f35880a..ea41009a2 100644 --- a/src/policyengine/tax_benefit_models/be/model.py +++ b/src/policyengine/tax_benefit_models/be/model.py @@ -50,7 +50,7 @@ _person_with_household_weights, ) -PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.1 +PopulaceBelgiumDataset = ( # compat: populace alias, remove after 6.20.2 MicrocosmBelgiumDataset ) diff --git a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py index 4d6e9130e..39b2be7c1 100644 --- a/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py +++ b/src/policyengine/tax_benefit_models/us/legacy_spm/registry.py @@ -91,10 +91,10 @@ class LegacySPMSource(BaseModel): spm_universe_rule="acs_household_population", ) -POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.20.1 +POPULACE_US_2024_ACS_LOCAL_BUILD_O = ( # compat: populace alias, remove after 6.20.2 MICROCOSM_US_2024_ACS_LOCAL_BUILD_O ) -POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.20.1 +POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263 = ( # compat: populace alias, remove after 6.20.2 MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263 ) diff --git a/tests/test_microcosm_compatibility.py b/tests/test_microcosm_compatibility.py index 40bfd2352..89f96a7ec 100644 --- a/tests/test_microcosm_compatibility.py +++ b/tests/test_microcosm_compatibility.py @@ -21,47 +21,47 @@ ( "policyengine.tax_benefit_models.be", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.tax_benefit_models.be.datasets", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.tax_benefit_models.be.model", "MicrocosmBelgiumDataset", - "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.1 + "PopulaceBelgiumDataset", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.provenance.certification", "MicrocosmDataProducerCertificationStrategy", - "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.20.1 + "PopulaceDataProducerCertificationStrategy", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.provenance.certification", "MICROCOSM_US_SOURCE_COVERAGE_FILE", - "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.20.1 + "POPULACE_US_SOURCE_COVERAGE_FILE", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.provenance.certification", "MICROCOSM_DATA_PACKAGES", - "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.20.1 + "POPULACE_DATA_PACKAGES", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.provenance.certification", "MICROCOSM_RELEASE_REPOS", - "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.20.1 + "POPULACE_RELEASE_REPOS", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_BUILD_O", - "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.20.1 + "POPULACE_US_2024_ACS_LOCAL_BUILD_O", # compat: populace alias, remove after 6.20.2 ), ( "policyengine.tax_benefit_models.us.legacy_spm.registry", "MICROCOSM_US_2024_ACS_LOCAL_MICROCOSM_1263", - "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.20.1 + "POPULACE_US_2024_ACS_LOCAL_MICROCOSM_1263", # compat: populace alias, remove after 6.20.2 ), ], ) @@ -100,7 +100,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( be = import_module("policyengine.tax_benefit_models.be") simulation_module = import_module("policyengine.core.simulation") legacy_env_name = ( - "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.1 + "POPULACE_BE_DATASET" # compat: populace alias, remove after 6.20.2 ) for name, value in ( ("MICROCOSM_BE_DATASET", current_path), @@ -139,7 +139,7 @@ def test_belgium_example_accepts_both_dataset_environment_names( def test_belgium_example_names_the_new_variable_when_neither_is_set(monkeypatch): for name in ( "MICROCOSM_BE_DATASET", - "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.20.1 + "POPULACE_BE_DATASET", # compat: populace alias, remove after 6.20.2 ): monkeypatch.delenv(name, raising=False)