Skip to content

Install importlib-metadata explicitly in Modal images#603

Closed
anth-volk wants to merge 1 commit into
mainfrom
fix/modal-image-importlib-metadata
Closed

Install importlib-metadata explicitly in Modal images#603
anth-volk wants to merge 1 commit into
mainfrom
fix/modal-image-importlib-metadata

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

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 on import logfire with ModuleNotFoundError: No module named 'importlib_metadata'.

The Modal images install logfire>=3.0.0 unpinned. #594's change to the pip_install layer invalidated the cached image layer, and the fresh rebuild resolved logfire 4.37.0, which imports importlib_metadata unconditionally on Python 3.13 without declaring it as a dependency (it previously arrived transitively via opentelemetry). The uv.lock environment (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>=8 explicitly 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_install layer 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/ in projects/policyengine-api-simulation: 325 passed
  • make format: clean

🤖 Generated with Claude Code

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>
@anth-volk

Copy link
Copy Markdown
Contributor Author

Superseded by the simulation service restructure (#609): this PR's commit (d98e87a) re-lands verbatim as commit 1 of that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Beta gateway crash-loops: logfire import fails with ModuleNotFoundError (importlib_metadata) in rebuilt Modal images

1 participant