Skip to content

Commit 73f5e2e

Browse files
authored
Merge pull request #428 from PolicyEngine/codex/policyengine-0x-simulation
[codex] Prepare simulation service for policyengine 0.13.0
2 parents 83b1299 + c28d0b7 commit 73f5e2e

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

projects/policyengine-api-simulation/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies = [
1616
"pydantic-settings (>=2.7.1,<3.0.0)",
1717
"opentelemetry-instrumentation-fastapi (>=0.51b0,<0.52)",
1818
"policyengine-fastapi",
19-
"policyengine==0.12.1",
19+
"policyengine==0.13.0",
2020
"policyengine-core>=3.23.5",
2121
"policyengine-uk>=2.22.8",
2222
"policyengine-us>=1.370.2",

projects/policyengine-api-simulation/src/modal/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_app_name(us_version: str, uk_version: str) -> str:
4747
.pip_install(
4848
f"policyengine-us=={US_VERSION}",
4949
f"policyengine-uk=={UK_VERSION}",
50-
"policyengine>=0.10.1,<1",
50+
"policyengine==0.13.0",
5151
"tables>=3.10.2",
5252
"logfire",
5353
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Regression tests for the policyengine dependency version configuration."""
2+
3+
import re
4+
import tomllib
5+
from pathlib import Path
6+
7+
REPO_ROOT = Path(__file__).parent.parent
8+
PYPROJECT_PATH = REPO_ROOT / "pyproject.toml"
9+
MODAL_APP_PATH = REPO_ROOT / "src" / "modal" / "app.py"
10+
POLICYENGINE_DEPENDENCY_PREFIX = "policyengine=="
11+
12+
13+
def _load_toml(path: Path) -> dict:
14+
with path.open("rb") as file:
15+
return tomllib.load(file)
16+
17+
18+
def _get_pyproject_policyengine_dependency(pyproject: dict) -> str:
19+
dependencies = pyproject["project"]["dependencies"]
20+
return next(
21+
dep for dep in dependencies if dep.startswith(POLICYENGINE_DEPENDENCY_PREFIX)
22+
)
23+
24+
25+
def _get_modal_policyengine_dependency(modal_source: str) -> str:
26+
match = re.search(
27+
r'"(policyengine==[^"]+)"',
28+
modal_source,
29+
)
30+
assert match is not None, "Modal app should install a pinned policyengine version"
31+
return match.group(1)
32+
33+
34+
def test_policyengine_dependency_version_is_pinned_consistently():
35+
pyproject = _load_toml(PYPROJECT_PATH)
36+
pyproject_dependency = _get_pyproject_policyengine_dependency(pyproject)
37+
modal_dependency = _get_modal_policyengine_dependency(MODAL_APP_PATH.read_text())
38+
39+
assert pyproject_dependency.startswith(POLICYENGINE_DEPENDENCY_PREFIX)
40+
assert modal_dependency == pyproject_dependency

0 commit comments

Comments
 (0)