From 446b482c13d820378d53ac4db767ed7c6883dedd Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 23 May 2025 16:22:51 +0100 Subject: [PATCH] Pass data and country package versions to APIv2 Fixes #2500 --- .../jobs/calculate_economy_simulation_job.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/policyengine_api/jobs/calculate_economy_simulation_job.py b/policyengine_api/jobs/calculate_economy_simulation_job.py index 67a10fa19..91e7478ef 100644 --- a/policyengine_api/jobs/calculate_economy_simulation_job.py +++ b/policyengine_api/jobs/calculate_economy_simulation_job.py @@ -158,6 +158,23 @@ def run( comment = lambda x: set_comment_on_job(x, *identifiers) comment("Computing baseline") + # Get the current dataset version + + version_file = download_huggingface_dataset( + repo_name=f"policyengine/policyengine-{country_id}-data", + repo_filename="version.json", + ) + with open(version_file, "r") as f: + version = json.load(f).get("version") + + data_versions = { + dataset.split("/")[-1]: version + } + + country_package_versions = { + f"policyengine-{country_id}": COUNTRY_PACKAGE_VERSIONS[country_id] + } + # If comparing against API v2, start job if check_against_api_v2: @@ -172,6 +189,8 @@ def run( "baseline_policy_id": baseline_policy_id, "time_period": time_period, "dataset": dataset, + "package_versions": country_package_versions, + "data_versions": data_versions, "v1_country_package_version": COUNTRY_PACKAGE_VERSIONS[ country_id ],