Skip to content

Implicit country discovery selects packages lacking DATASETS or Microsimulation #681

Backlog

Description

@MaxGhenis

Reported from the PolicyEngine/policyengine-nz#36 review (20261203-001739-nzhub-rev-pe-nz-36-r1):

policyengine_core.scripts.detect_country_package() (policyengine_core/scripts/__init__.py:74-100) selects the first installed policyengine* package that exports CountryTaxBenefitSystem, falling back to policyengine_core.country_template.

Two Core entry points rely on detect_country_package() without checking the additional package attributes they require:

  1. policyengine_core/scripts/run_data.py:27-35 reads importlib.import_module(country_package).DATASETS. policyengine_us, policyengine_uk, and policyengine_nz (with Export CountryTaxBenefitSystem so the Core CLI can load the NZ model policyengine-nz#36) export CountryTaxBenefitSystem without DATASETS, so policyengine-core data datasets list without -c raises AttributeError.
  2. policyengine_core/tools/dependency_map.py:454-475,512-520 reads package.Microsimulation in "microdata" and "both" modes. policyengine_nz has no Microsimulation, so implicit discovery selects an incompatible package for those modes.

Fix: require DATASETS when run_data.py resolves a default country package (retaining the country_template fallback), and check for Microsimulation when dependency_map.py resolves a default for "microdata" or "both".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions