Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

US year-file cuts can pair one cut's tables with another's stamp, and the stamp lacks the year

Abierto
#607 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
data

Línea de trabajo

Start in tax_benefit_models.us.datasets.create_datasets and compare it with the UK path that #601 changed, which uses policyengine.provenance.year_file_stamp.temporary_year_file and publish_year_file. Port that write-to-temp, re-check, stamp, os.replace flow to the US create path, and add "year" to the stamp by raising legacy_inputs.YEAR_FILE_STAMP_REVISION to 3 and passing the year into year_file_stamp_problem. Update docs/microsim.md "Year files". The work is done when a failed or interleaved cut leaves existing year files intact and a copied year file fails the check.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

tax_benefit_models.us.datasets.create_datasets writes each US year file at its final path and stamps it afterwards (#593). Two problems follow.

Interleaved cuts mix one cut's tables with another's stamp. Two processes cutting the same year files in one data folder can interleave:

  1. P1 saves the tables of pop_year_2026.h5.
  2. P2 saves its own tables there, then stamps them.
  3. P1 stamps the file.

The file then holds P2's tables under P1's stamp. Every later ensure_datasets in P1's environment takes the file as current and reuses it. This happens, for example, when two sources share a name (two pop.h5 files) or when two environments with different package versions share a data folder.

A failed cut destroys good year files. When the source changes mid-cut (DatasetMaterializationError), or any later step fails, the year files already at those paths have been overwritten and left unstamped.

The stamp lacks the year. A year file copied or renamed to another year's name passes the check and is taken for that year.

The independent review of #601 found the first two problems for UK year files. #601 fixed them there with policyengine.provenance.year_file_stamp.temporary_year_file / publish_year_file, and added the year to the UK stamp.

Fix

Port #601's approach to the US create path:

  • Write each year file, with its tables and renames record, to a hidden temporary file beside its path.
  • Re-check the source, then stamp each temporary file and os.replace it onto its path.
  • Remove the temporaries in a finally.
  • Record "year" in the US stamp. This raises legacy_inputs.YEAR_FILE_STAMP_REVISION to 3, and year_file_stamp_problem takes the year.
  • Saved outputs that record a year-file stamp (#594) follow the revision.
  • Update docs/microsim.md "Year files", where the "takes no lock" limit changes.
Lenguaje dominante
Python
Estrellas
8
Forks
10
Merge medio
19 h 40 min
PR fusionados (30 d)
37

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PolicyEngine/policyengine.py

Todos los issues de PolicyEngine/policyengine.py

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.