Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/scripts/update-policyengine-package.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
#
# Check PyPI for a newer policyengine.py package, update the simulation project
# pin, sync country package pins to that policyengine.py bundle, and open one
# pin, sync runtime package pins to that policyengine.py bundle, and open one
# bundle-level PR.
#
# Usage:
Expand Down Expand Up @@ -39,7 +39,8 @@ create_pr_body_file() {
echo
echo "Update policyengine.py from ${CURRENT} to ${LATEST} in the simulation API runtime."
echo
echo "This also syncs country package pins to the versions bundled by policyengine.py ${LATEST}:"
echo "This also syncs runtime package pins to the versions bundled by policyengine.py ${LATEST}:"
echo "- policyengine-core: ${BUNDLED_CORE_VERSION:-resolved from bundle during update}"
echo "- policyengine-us: ${BUNDLED_US_VERSION:-resolved from bundle during update}"
echo "- policyengine-uk: ${BUNDLED_UK_VERSION:-resolved from bundle during update}"
echo
Expand Down Expand Up @@ -160,26 +161,29 @@ BUNDLE_OUTPUT=$(
)
BUNDLED_US_VERSION=$(printf '%s\n' "$BUNDLE_OUTPUT" | awk -F= '$1 == "us_version" {print $2}')
BUNDLED_UK_VERSION=$(printf '%s\n' "$BUNDLE_OUTPUT" | awk -F= '$1 == "uk_version" {print $2}')
BUNDLED_CORE_VERSION=$(printf '%s\n' "$BUNDLE_OUTPUT" | awk -F= '$1 == "policyengine_core_version" {print $2}')

if [[ -z "$BUNDLED_US_VERSION" || -z "$BUNDLED_UK_VERSION" ]]; then
echo "ERROR: Could not resolve bundled country package versions." >&2
if [[ -z "$BUNDLED_CORE_VERSION" || -z "$BUNDLED_US_VERSION" || -z "$BUNDLED_UK_VERSION" ]]; then
echo "ERROR: Could not resolve bundled runtime package versions." >&2
echo "$BUNDLE_OUTPUT" >&2
exit 1
fi

echo "Bundled country pins:"
echo "Bundled runtime pins:"
echo " policyengine-core==${BUNDLED_CORE_VERSION}"
echo " policyengine-us==${BUNDLED_US_VERSION}"
echo " policyengine-uk==${BUNDLED_UK_VERSION}"

python3 - "$PYPROJECT" "$BUNDLED_US_VERSION" "$BUNDLED_UK_VERSION" <<'PY'
python3 - "$PYPROJECT" "$BUNDLED_CORE_VERSION" "$BUNDLED_US_VERSION" "$BUNDLED_UK_VERSION" <<'PY'
import re
import sys
from pathlib import Path

pyproject_path, us_version, uk_version = sys.argv[1:]
pyproject_path, core_version, us_version, uk_version = sys.argv[1:]
pyproject = Path(pyproject_path)
text = pyproject.read_text(encoding="utf-8")
pins = {
"policyengine-core": core_version,
"policyengine-us": us_version,
"policyengine-uk": uk_version,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def fake_repo(tmp_path: Path) -> Path:
"\n".join(
[
"[project]",
'dependencies = ["policyengine==4.0.0", "policyengine-us==1.0.0", "policyengine-uk==2.0.0"]',
'dependencies = ["policyengine==4.0.0", "policyengine-core==0.0.0", "policyengine-us==1.0.0", "policyengine-uk==2.0.0"]',
]
),
encoding="utf-8",
Expand All @@ -35,6 +35,10 @@ def fake_repo(tmp_path: Path) -> Path:
'version = "4.0.0"',
"",
"[[package]]",
'name = "policyengine-core"',
'version = "0.0.0"',
"",
"[[package]]",
'name = "policyengine-us"',
'version = "1.0.0"',
"",
Expand Down Expand Up @@ -124,6 +128,7 @@ def install_fake_uv(
fake_bin: Path,
*,
log: Path,
bundled_core_version: str = "999.999.999",
bundled_us_version: str = "1.1.0",
bundled_uk_version: str = "2.1.0",
) -> None:
Expand All @@ -135,7 +140,7 @@ def install_fake_uv(

if [[ "$1" == "run" && "$2" == "python" && "$3" == "-m" && "$4" == "src.modal.utils.extract_bundle_versions" ]]; then
echo "policyengine_version=4.1.0"
echo "policyengine_core_version=3.26.1"
echo "policyengine_core_version={bundled_core_version}"
echo "us_version={bundled_us_version}"
echo "us_data_version=1.10.0"
echo "uk_version={bundled_uk_version}"
Expand Down
6 changes: 3 additions & 3 deletions projects/policyengine-api-simulation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ dependencies = [
"pydantic-settings (>=2.7.1,<3.0.0)",
"opentelemetry-instrumentation-fastapi (>=0.51b0,<0.52)",
"policyengine-fastapi",
"policyengine==4.18.3",
"policyengine-core==3.27.1",
"policyengine==4.18.5",
"policyengine-core==3.28.0",
"policyengine-uk==2.89.2",
"policyengine-us==1.729.0",
"policyengine-us==1.745.0",
"tables>=3.10.2",
"modal>=0.73.0",
"logfire>=3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_update_policyengine_package_opens_pr_for_existing_branch_without_open_p
assert "--head auto/update-policyengine-4.1.0" in gh_calls


def test_update_policyengine_package_updates_py_and_bundled_country_pins(
def test_update_policyengine_package_updates_py_and_bundled_runtime_pins(
fake_bin: Path, fake_repo: Path, tmp_path: Path
) -> None:
git_log = tmp_path / "git.log"
Expand All @@ -149,6 +149,7 @@ def test_update_policyengine_package_updates_py_and_bundled_country_pins(
encoding="utf-8"
)
assert "policyengine==4.1.0" in pyproject_text
assert "policyengine-core==999.999.999" in pyproject_text
assert "policyengine-us==1.1.0" in pyproject_text
assert "policyengine-uk==2.1.0" in pyproject_text
uv_calls = uv_log.read_text(encoding="utf-8")
Expand Down
26 changes: 13 additions & 13 deletions projects/policyengine-api-simulation/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.