Skip to content

Saved UK outputs are reused after their year file is re-cut #606

Open

Description

@MaxGhenis

Problem

A saved UK simulation output is checked only for a recorded data year. MicrosimulationModelVersion.load() (src/policyengine/tax_benefit_models/common/model_version.py) calls uk.datasets._year_file_records_data_year and nothing else.

#601 (issue #600) stamps every UK year file with the source dataset it was cut from, the policyengine-core and policyengine-uk versions that cut it, its year and a format revision (uk.datasets.YEAR_FILE_STAMP_H5_DATASET), and ensure_datasets re-cuts a year file whose stamp is out of date. Nothing ties a saved output to that stamp. So when a year file is re-cut, because the bundle re-pinned the dataset, the local source was edited or policyengine-uk was upgraded, Simulation.ensure() and Simulation.load() still reuse outputs calculated from the old year file.

#594 (issue #592) closes the same gap for US outputs: a run records an output stamp holding the input year file's stamp, save() writes it after the tables, and load() refuses an output whose stamp is out of date.

Fix

Mirror #594 for the UK:

  • A UK dataset read from a year file, or returned by create_datasets, keeps the file's stamp.
  • A UK Simulation.run() records an output stamp holding that stamp and an output format revision.
  • save() writes the output stamp after the tables, in its own H5 dataset.
  • Simulation.load() refuses, and Simulation.ensure() recalculates, an output whose stamp is not this release's, or which was calculated from a year file other than the simulation's dataset holds now, or from one cut under another year-file revision or other package versions.

Stacked on #601.

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