Skip to content

Add UK geography asset resolution#373

Merged
anth-volk merged 5 commits into
mainfrom
codex/uk-geography-asset-resolution
May 21, 2026
Merged

Add UK geography asset resolution#373
anth-volk merged 5 commits into
mainfrom
codex/uk-geography-asset-resolution

Conversation

@anth-volk
Copy link
Copy Markdown
Contributor

@anth-volk anth-volk commented May 21, 2026

Fixes #372

Summary

Adds a shared UK geography asset resolver for constituency and local-authority outputs.

The resolver:

  • preserves explicit weight_matrix_path and lookup CSV path behavior;
  • rejects provided-but-missing explicit paths before any fallback strategy can run;
  • searches standard local/cache directories first;
  • downloads missing canonical files from the PolicyEngine UK GCS bucket by default;
  • supports download_missing_assets=False for local/cache-only canonical asset resolution;
  • exposes local and GCS strategy classes for tests and advanced callers.

This wires the resolver into compute_uk_constituency_impacts and compute_uk_local_authority_impacts, updates docs, and adds focused unit coverage. It also centralizes the canonical UK geography asset bucket and filenames so the output resolver and UK region registry use the same source of truth.

Testing

  • ruff check src/policyengine/data/__init__.py src/policyengine/data/uk_geography_assets.py src/policyengine/countries/uk/regions.py src/policyengine/outputs/uk_geography_assets.py src/policyengine/outputs/constituency_impact.py src/policyengine/outputs/local_authority_impact.py src/policyengine/outputs/__init__.py tests/test_uk_geography_assets.py tests/test_constituency_impact.py tests/test_local_authority_impact.py tests/test_uk_regions.py
  • ruff format --check src/policyengine/data/__init__.py src/policyengine/data/uk_geography_assets.py src/policyengine/countries/uk/regions.py src/policyengine/outputs/uk_geography_assets.py src/policyengine/outputs/constituency_impact.py src/policyengine/outputs/local_authority_impact.py src/policyengine/outputs/__init__.py tests/test_uk_geography_assets.py tests/test_constituency_impact.py tests/test_local_authority_impact.py tests/test_uk_regions.py
  • POLICYENGINE_SKIP_COUNTRY_IMPORTS=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest --noconftest tests/test_uk_geography_assets.py tests/test_constituency_impact.py tests/test_local_authority_impact.py tests/test_uk_regions.py -q (33 passed, 1 warning)

Note: the focused pytest run uses --noconftest locally because the top-level tests/conftest.py eagerly imports country fixtures, which makes these output-only tests collect slowly in this environment.

@anth-volk anth-volk marked this pull request as ready for review May 21, 2026 17:28
@anth-volk anth-volk merged commit d55977d into main May 21, 2026
12 checks passed
@anth-volk anth-volk deleted the codex/uk-geography-asset-resolution branch May 21, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve UK geography output assets locally or from GCS

1 participant