Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…umps The image now installs uv.lock as it is (Image.uv_sync, uv sync --frozen) instead of nine hand-copied pins, so it is the environment CI tests by construction. tests/test_modal_pins.py checks that the image is built by one uv_sync with no extras and that nothing else installs packages; the FAQ test and the faq-numbers script read the model versions from uv.lock. .github/dependabot.yml relocks the PolicyEngine packages each Monday, in one PR for policyengine-us with core and one for policyengine-uk. The FAQ numbers job on that PR uploads the FAQ's answers at the new versions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
image-from-uv-lock
branch
from
November 29, 2026 03:56
1397aa6 to
17edfcf
Compare
Fixes from the first review of the uv.lock image: - faqNumbers.json records policyengine-core as well as the two models, and test_faq_numbers requires exactly those three, so a core release alone makes CI ask for a new file. The writer parses uv.lock as TOML (Bun's parser) instead of matching lines. - test_modal_pins follows the image fastapi_app is decorated with: one name, assigned once, built from debian_slim by a chain that only runs one pinned uv_sync on the repository root, sets the environment and adds local files. It catches a sync on an unused image, a different decorator image, dockerfile_commands, a reassignment and a missing uv_version. - The README, modal_app.py, dependabot.yml and the workflow comments no longer promise more than the code does: Dependabot checks weekly and opens a PR only when a release is out, relocking can move other packages, the image skips the dev extra, and the deploy job's Modal client is not the one uv.lock pins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_modal_pins requires uv_sync's uv_version to name a release and refuses UV_ variables in the image's env, which could change what the sync installs. - The FAQ writer reads uv.lock before calling the API, so a lock missing a model fails at once. - The README, dependabot.yml and modal_app.py say Dependabot opens one PR per group with a new release unless that group's PR is open, and the README notes the image skips the dev extra. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 2 found that the first uv_sync deploy would move production from a fresh 2026-11-29 resolve to uv.lock's year-old transitive packages, 11 of them inside published advisories (certifi, anyio, urllib3, fsspec, msgpack and others), and that the image would put the lock's modal closure ahead of the dependencies Modal pins for its mounted client. - pyproject: modal moves to the dev extra (modal>=1.1). The image skips it; tests/test_giving_season.py still gets it from CI's --extra dev. - uv.lock: every package in the project's runtime closure except the ten old pip_install pins relocked with uv 0.11.7. The image's packages now match all 85 in production's pip layer (deploy run 46221122775) at the same versions; the PolicyEngine models, numpy, pandas, scipy, fastapi, pydantic, pyyaml and spm-calculator are unchanged, and so are black, isort, hypothesis and pytest-cov. - test_modal_pins: counts every binding of the image name, rejects ** options on app.function and app.cls, rejects PATH, VIRTUAL_ENV and PYTHONHOME in env steps, and checks that the image's closure installs what the API imports and not modal. The docstring says it catches mistakes, not evasion. - Dependabot: one group for policyengine-us, -uk and -core, so one PR and one faqNumbers.json carry a bump. README, the dependabot.yml header and modal_app.py now say only what the config does and what GitHub's docs state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3: - test_modal_pins.py counts bindings of the image in the module's scope only (adding except-as, match captures, del and global), checks only calls on the module's modal.App, and rejects name= there, which could register a second fastapi_app. It also requires one fastapi_app. - image_packages() follows environment markers for the image's platform (CPython 3.13, x86-64 Linux), so it matches the 94 packages the scratch deploy installed. It handles extras that name themselves, requires each package locked once, and a new test requires no extra default groups. - dependabot.yml: core's allow rule sets dependency-type "indirect", since only the models depend on it (untested). - README: Dependabot targets the three packages, but its relock can move what a new release needs; eligibility and the post-FAQ-commit and supersede behaviour, which are untested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- bindings() follows each scope: a function or class that declares the name global counts, a read-only global doesn't, and argument and return annotations (evaluated at def time before Python 3.14) count. - fastapi_app must be bound once, so a second def inside an if or try fails. - Every .function/.cls call the module's scope evaluates is checked, whatever its receiver, so an alias of app is covered; a call on the app or an alias elsewhere, a bare app.function, and a default image on the App fail. A literal name= other than "fastapi_app" is allowed, as are an annotated app or image and uv_sync(frozen=True). - debian_slim's python_version must match IMAGE_PLATFORM, and a lock marker on any variable the test doesn't model (patch version, kernel, extra) fails instead of taking the host's value. - dependabot.yml: core's rule uses dependency-type "all", which matches whether or not pyproject.toml names core (untested). - README: core's range, the cooldown's scope, the untested list, and the 85 packages of production's pip layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alerts were turned on for the repository on 2026-11-29 (decision d3556). Security updates stay off because the allow list would limit them to the three PolicyEngine packages; an alert on another package is fixed by relocking that package in its own PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: modal_app.py keeps this branch's uv_sync image (main only moved the pip pin it removes); faqNumbers.json takes main's figures with this branch's three-model version block at policyengine-us 2.156.4. uv.lock and pyproject.toml merged cleanly, and `uv lock --check` passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Merged main into this branch at a3e27b3, after #108 (policyengine-us 2.156.4) landed as 911a039.
|
This was referenced Dec 1, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main merged in on November 30 at a3e27b3, after #108 moved policyengine-us to 2.156.4 (911a039). This PR's own diff is unchanged apart from that version: the uv image now installs policyengine-us 2.156.4, with policyengine-uk 2.134.6, policyengine-core 3.38.0 and numpy 2.1.3 as before. The November 29 readings below were taken at 2.154.3.
Rebased onto main after #100 merged (87edfe4) and was checked live on November 29. It will not merge before December 2, so that the change to how the live image is built does not land during Giving Tuesday.
What this changes
The Modal image installs
uv.lock.modal_app.pybuilds the image withImage.uv_sync(uv_version="0.11.7")instead of ten hand-copiedpip_installpins. With Modal 1.3.0.post1 and 1.6.4 alike, that runsuv sync --frozen --no-install-workspace --compile-bytecodeonpyproject.tomlanduv.lockwhen the image is built. What each place installs:devgroup (httpx, isort), atuv.lock's versions. Not the project itself (its code is added as files) and not the dev extra.uv sync --locked --extra dev): the same, plus the dev extra and the project.uv sync --locked): the same packages as the image, plus the project.pip install "modal>=1.1"(1.6.4 on November 29). That client builds the image, and Modal mounts it into the container at run time.modal moves to the dev extra. With modal in the image, the mounted client imported protobuf, grpclib and aiohttp from the lock's copies. Without it, the client uses Modal's own copies (
/__modal/deps), as production does today.tests/test_giving_season.pyimportsmodal_app, so CI's test job still installs modal.uv.lockis relocked. The old image resolved its unpinned packages afresh at each build, so production ran newer versions thanuv.lock's. At e726832 the image would have installed 18 packages with GitHub advisories. Twelve came with the API's dependencies: certifi and anyio (critical); urllib3, fsspec, msgpack, wheel and starlette (high); and filelock, idna, requests, pytest and python-dotenv (medium). Six came with modal: aiohttp, protobuf and cbor2 (high), and multidict, h2 and hpack (medium). Production's pip layer has none of those versions except starlette 0.50.0. The relock (uv 0.11.7) passed--upgrade-packagefor every package in the API's dependency tree except the ten old pins (the PolicyEngine models, spm-calculator, numpy, pandas, scipy, fastapi, pydantic and pyyaml). Inuv.lock, 57 packages moved, five were added and one (six) was removed. The other packages kept their versions: the ten pins; 24 more of the image's packages, among them census, openpyxl, pydantic-core and starlette; the Windows-only colorama; and, apart from platformdirs, the 26 packages only CI's test job installs from the lock (the dev extra's black, hypothesis, pytest-cov and modal, and what they need). Five of those 26 have advisories: aiohttp, black, cbor2, multidict and protobuf. The image's packages now include all 85 in production's pip layer (deploy run 46221122775) at the same versions, plus nine: uvicorn and its standard extras, isort, packaging and wheel. (Production also has packaging 26.0 and wheel 0.46.3 in the base image's site-packages; the image's venv has 26.4 and 0.48.0.) Of the image's packages (not counting the copies Modal mounts for its client, as in production), only starlette 0.50.0 has an advisory; fastapi 0.124.2 requires starlette below 0.51, and Deploy, CI and dependency gaps around the Modal image (from #101's reviews) #102 tracks it.Dependabot proposes model bumps.
.github/dependabot.ymlchecks weekly on Mondays, withlockfile-only, and allows policyengine-us, policyengine-uk and policyengine-core in one group, so a bump comes as one PR (limit 1). Only the models depend on core. A comment in dependabot-core'sJob#allowed_update?says GitHub's service defaults a rule's type to direct, which that method then excludes indirect dependencies from, so core's entry setsdependency-type: "all"; that matches core whether or notpyproject.tomlnames it. Dependabot picks only releases that uv can resolve withinpyproject.toml's ranges (for core, the models' requirements). The docs say it waits 3 days after a release by default; in dependabot-core that cooldown chooses the three packages' versions, and the relock command it then runs takes no cooldown option. It targets those three packages, but its relock (uv lock --upgrade-packagein its uv updater) can also move packages a new release needs. Untested here:"all"or the earlier"indirect");Nothing relocks the other packages on a schedule. Dependabot alerts are on from 2026-11-29; security updates stay off, since GitHub's options reference says the allow list applies to them too, which would limit them to the three PolicyEngine packages.
Tests.
tests/test_modal_pins.pyfollows the image thatfastapi_appis decorated with.fastapi_appmust be defined once, and that image must be:del,except ... as,matchcaptures and walruses in annotations, or in a function or class that declares itglobal. Names local to a function, class, lambda or comprehension don't count;modal.Image.debian_slim, for the Python version the test evaluates markers with, by a chain that only syncs the lock, sets the environment (noUV_variables,PATH,VIRTUAL_ENVorPYTHONHOME) and the working directory, and adds local files;uv_sync, frozen, with uv pinned to a release and no extras or groups.Every
.functionor.clscall that the module's scope evaluates, whatever its receiver, and any made on amodal.Appor a name for one, must be at the top level, and if it names an image it must name that one. None may take**options, which could pass another image, or aname=other than a literal that isn't"fastapi_app". The app may not set a default image, andapp.functionmay not be used without being called. None of the installer methods it lists may appear.The packages the image's sync installs, worked out from
uv.lockfor CPython 3.13 on x86-64 Linux (following environment markers and extras), must include what the API imports and must not include modal. For this lock that set is the 94 packages the scratch deploy installed. A marker on a variable the test doesn't model (the patch version, the kernel, an extra) fails the test rather than taking the value of the machine running it. Today's lock uses onlysys_platform,platform_machineandplatform_python_implementation. x86-64 is inferred (Modal's source says images it pulls from a registry must be built for linux/amd64; the scratch logs don't print the machine), and bothplatform_machinemarkers in the lock give the same answer on aarch64.[tool.uv] default-groupsmust be unset or["dev"], anduv.lockmust lock each package once.Its docstring says it catches mistakes, not code written to get around it. Across rounds 2 to 4 it fails on 64 mutants of
modal_app.pyand 11 ofuv.lockorpyproject.toml, and passes 20 harmless edits and the unchanged files.tests/test_faq_numbers.pyandfrontend/scripts/write-faq-numbers.tsread the model versions fromuv.lockas TOML.faqNumbers.jsonrecords policyengine-core as well as the two models, and the test requires exactly those three.Review
Rounds 1 and 2 reviewed the whole change; rounds 3 and 4 were scoped to the earlier findings. Round 4 found every P1 closed. Its verdict line said REQUEST_CHANGES because of three new P2s: an alias of
app, a walrus in an annotation, and marker variables the test filled in from the host. Under the review rule the levels decide, and P2s from a scoped round are fixed or filed without another round. b2397d8 and 72dd80b fix those P2s and most P3s from round 4 and an in-session check; 96c237c updates the README for the alerts setting. No independent reviewer has read those three commits. They were checked in-session with the mutants above, an in-session harness of about 60 more cases, the local tests and CI. #102 lists the P3s left open.How a model bump lands
uv.lock, for a release of one of the three packages that is at least 3 days old (its default cooldown) and that uv can resolve withinpyproject.toml's ranges. A package the relock moves along with it isn't held to the cooldown.FAQ numbersjob uploadsfaqNumbers.jsonat the new versions. The FAQ test fails until that file is committed.Who does step 3, and who refreshes the other locked packages, is queued for Max as decision d3552.
Risks
The first deploy uses the new image definition. Modal may reuse the layers the scratch deploy below built. The interpreter stays CPython 3.13.3, and the 85 packages production's pip layer installed keep their versions. The container's Python moves to
/.uv/.venv, whichuv_syncputs first onPATH.PYTHONPATH=/rootand the added source directories stay as they were. After the deploy I will check:/api/healthand itssimulation_workerscount;The comparison is the current
pip_installimage, read on November 29 after Update policyengine-us to 2.154.3 #100 deployed. It showedsimulation_workers4. Three bursts of eight/api/calculaterequests at once took 70.0, 24.2 and 23.2 s. The first followed checks in which HI and MN still returned pre-Update policyengine-us to 2.154.3 #100 answers. It answered 204 requests (four for every state and DC) with no failures. Container memory (cgroupmemory.usage_in_bytes) was 5,449 MiB after 102 requests and 5,498 MiB after 204. The app process and forkserver were at 1,376 and 1,386 MiB resident.A scratch deploy of c6d6a41 worked. Since then, dff23e9, b2397d8, 72dd80b and 96c237c change only the tests, README and Dependabot config;
modal_app.py,pyproject.tomlanduv.lockare the same, so the image is too. It was deployed asgivecalc-uvsync-scratchwith Modal 1.6.4, with no warm container and without the hourly job that writes to production's autoscaler, then stopped.uv sync --frozen(94 packages, no modal)./.uv/.venv/bin/python3.13.3. It imported modal 1.6.4 and synchronicity from/pkg; protobuf 6.31.1, grpclib 0.4.8 and aiohttp 3.12.7 from/__modal/deps; and policyengine-us 2.154.3, core 3.38.0 and uk 2.134.6 from the venv./api/savingsor/api/uk/savings, 24 to/api/calculate).A revert restores the
pip_installdefinition. A fresh build of it resolves the unpinned packages afresh, so it may not match today's image exactly. Untested here:modal app rollback givecalc, which Modal's CLI help says redeploys the previous version and resets the app to its state at that deployment. The next push to main deploys over either.🤖 Generated with Claude Code