Repository navigation
Conversation
Federal statistical users asked how to reproduce a run. A TAXSIM-format output file records no versions, and PyPI does not keep every policyengine-us release, so a run has to record its versions when it runs. - `policyengine-taxsim --version` prints the policyengine-taxsim, policyengine-us and policyengine-core versions, the build stamp of the TAXSIM binary TaxsimRunner would run (read from the file without running it) and the Python version. - `--provenance PATH` on the stdin command and the policyengine, taxsim and compare subcommands writes a JSON sidecar: those versions, the binary's path and SHA-256, the options (as resolved), SHA-256, path and record count of the input and output, per-engine record counts, and every installed package version. stdout and output files are byte-identical with or without the flag; in stdin mode a pass-through for sys.stdout hashes every byte the run writes. The sidecar directory is created and probed for writability before the run. - TAXSIM progress and --logs diagnostics go to stderr, so a stdin run writes only TAXSIM-format output to stdout (pre-2021 records used to put three progress lines above the CSV header). - `taxsim --taxsim-path` works: the path is made absolute (it crashed on the str click passes), and an already-executable binary is not chmodded. - README "Recording versions" section and a note in the documentation page's Version pinning section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine_versions() now prints collect_versions() through
format_version_report() (the `policyengine-taxsim --version` report, with
the bundled TAXSIM binary's build and Python version) and returns the
existing three fields followed by taxsim_binary, taxsim_binary_build,
taxsim_binary_path, taxsim_binary_sha256, python_version and platform. With
a policyengine-taxsim that predates the provenance module it falls back to
importlib.metadata and says how to update.
policyengine_calculate_taxes() and compare_with_taxsim() take a provenance
path, checked before the run, that writes build_provenance() JSON (the
CLI's --provenance record) plus rPackageVersion and rVersion. Inputs and
outputs are hashed as the CSV pandas writes for them. The R package needs
reticulate 1.45.0+, the first release that converts pandas 3 data frames;
main's policyengine_calculate_taxes() fails on reticulate 1.44.1 with the
pandas 3 that setup_policyengine() installs. Adds testthat tests and a CI
job that runs them against a real policyengine-taxsim environment.
scripts/refresh_dashboard.py adds policyengineTaxsimVersion and
taxsimBinaryBuild to provenance_{year}.json and the summary metadata, from
collect_versions(taxsim_path=resources/taxsimtest/taxsimtest-linux.exe) run
in a child process before the batches. Existing keys are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Coordination note from #1418 (agreement with TAXSIM by release): no changes are needed here, but two things now depend on this PR's key names.
If any of these keys is renamed before merge, |
|
#1422 changes When this branch is rebased after #1422 lands:
Your test of |
Stacked on #1412. The first commit is #1412's (
--version,--provenance,policyengine_taxsim/core/provenance.py); review the second commit. I'll rebase ontomainonce #1412 merges.R wrapper
policyengine_versions()callscollect_versions()and printsformat_version_report(), the same report aspolicyengine-taxsim --version:policyengine_taxsim,policyengine_usandpolicyengine_corefirst, with the same "unknown" for a missing package, and addstaxsim_binary,taxsim_binary_build,taxsim_binary_path,taxsim_binary_sha256,python_versionandplatform(NA when unavailable). With a policyengine-taxsim installed before Add --version and an opt-in --provenance sidecar to the CLI #1412 it falls back to importlib.metadata and says to runsetup_policyengine(force = TRUE).policyengine_calculate_taxes(..., provenance = "run.json")andcompare_with_taxsim(..., provenance = "compare.json")write the recordbuild_provenance()builds for the CLI, plusrPackageVersionandrVersion. The path is checked (and parent folders created) before the run. Input and output are R data frames, so each is hashed as the CSV pandas writes for it (to_csv(index=False, lineterminator="\n")).policyengine_calculate_taxes()callsPolicyEngineRunnerdirectly, so its record showsengines: {policyengine: n, taxsim: 0};compare_with_taxsim()records the TAXSIM binary itsTaxsimRunnerran.policyengine_calculate_taxes()now imports the runners withconvert = FALSEso it has the pandas results to hash; it converts them withpy_to_r()as before.setup_policyengine()installs,policyengine_calculate_taxes()fails with "cannot coerce class 'pandas.DataFrame' to a data.frame" (reproduced locally); with 1.47.0 it works.rPackageVersiondistinguishes this code.tests/testthatsuite (11 tests, 68 expectations): unit tests need no Python; integration tests run against thepolicyengine-taxsimvirtualenv. New CI jobr-packagecreates that virtualenv from this checkout and runs the suite withPOLICYENGINETAXSIM_REQUIRE_PYTHON=true, so a missing environment fails instead of skipping.r-package/README.md, root README "Recording versions", and the docs page's R tab (r-version-pinblock) updated.Dashboard refresh
provenance_{year}.json(andsummary.metadata, which shares the dict) gainspolicyengineTaxsimVersionandtaxsimBinaryBuild, fromcollect_versions(taxsim_path=ROOT / "resources/taxsimtest/taxsimtest-linux.exe"). Existing keys and values are unchanged.collect_versions()runs in a child process (refresh_dashboard.py --versions PATH, like--worker), before the batches so a broken environment fails in seconds. Importing anything underpolicyengine_taxsimimports policyengine-us (~26 s; verified), and the coordinator is meant not to. A local 52-household smoke run wrote:Invariants and how they are tested
collect_versions()output (Hypothesis property test over versions/builds, plus example tests).policyengine*module while collecting versions (fresh-interpreter test), and the child reports this checkout's__version__and the Linux binary's embedded build.taxsimBinarySha256from the refresh'sdigest()equalscollect_versions()'s SHA-256 of the same binary; the R record's input hash equals an independent hashlib hash of the same CSV.policyengine_calculate_taxes()returns the same results with and withoutprovenance(integration test). Locally, main's version and this branch's returned identical results for 4 households (2021–2024; single, joint and separate filers) with basic and detailed output.rPackageVersionandrVersion(checked locally againstpolicyengine-taxsim policyengine --provenance).policyengine_versions()list's first three names and their "unknown" convention are unchanged.Tests run
pytest tests/test_dashboard_refresh.py: 15 passed (a bare env without hypothesis or policyengine-us runs 14 with the child-process test skipped, as the refresh workflow'sunitteststep does).testthat::test_local(): 11 tests, 68 expectations, 0 failed or skipped, with Python required.DocumentationContenttests: 13 passed; the new R-tab test fails on the old block.ruff format --check .clean.axiom: n/a: R wrapper, docs and dashboard-refresh tooling; no policy change.
🤖 Generated with Claude Code