Install importlib-metadata explicitly in Modal images#603
Closed
anth-volk wants to merge 1 commit into
Closed
Conversation
logfire >=4.7 imports importlib_metadata unconditionally on Python 3.13 but stopped receiving it transitively, so the freshly rebuilt gateway and simulation images crash on import logfire. The gateway ASGI factory died at startup, hanging every request past Modal's HTTP window (303 redirects), which failed all beta integration tests and blocked the production deploy of the observability PR (#594). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 3, 2026
Contributor
Author
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.
Fixes #602
Problem
The #594 merge deploy failed all beta integration tests and skipped production. Every gateway endpoint (including
/ping) hung past Modal's HTTP window and returned 303 redirects: the gateway ASGI factory crashes at startup onimport logfirewithModuleNotFoundError: No module named 'importlib_metadata'.The Modal images install
logfire>=3.0.0unpinned. #594's change to thepip_installlayer invalidated the cached image layer, and the fresh rebuild resolved logfire 4.37.0, which importsimportlib_metadataunconditionally on Python 3.13 without declaring it as a dependency (it previously arrived transitively via opentelemetry). Theuv.lockenvironment (logfire 4.6.0 + importlib-metadata 8.5.0) is unaffected, which is why unit tests passed while the deployed image crashed.Fix
Install
importlib-metadata>=8explicitly in both the gateway image and the shared base simulation image, and assert its presence in the image tests. This is robust across logfire versions rather than pinning around the upstream packaging bug.Note: this changes the base image's
pip_installlayer again, which invalidates the dataset prebuild layer. The layers are being prewarmed off the deploy path per the README (modal run src/modal/prewarm_app.py) so the post-merge deploy fast-forwards.Tests
uv run pytest tests/inprojects/policyengine-api-simulation: 325 passedmake format: clean🤖 Generated with Claude Code