Problem
API v1's staging integration/deploy flow exposed a simulation API failure when it attempted to call the budget-window batch worker. The parent Modal worker crashed during import before it could run the batch orchestration.
API v1 failing job:
https://github.com/PolicyEngine/policyengine-api/actions/runs/25388257599/job/74461134035
Observed simulation API traceback:
ModuleNotFoundError: No module named 'fastapi'
The failure path was:
run_budget_window_batch
-> src.modal.budget_window_batch
-> src.modal.budget_window_context
-> src.modal.gateway.models
-> src.modal.gateway.__init__
-> src.modal.gateway.endpoints
-> fastapi
The versioned simulation Modal image intentionally installs the heavy simulation dependencies, not the FastAPI gateway dependency set. Importing src.modal.gateway.models should therefore not execute gateway endpoint imports or require fastapi.
Expected behavior
- Budget-window parent batch workers can import the request/response models inside the simulation image.
- Gateway package imports are side-effect free for model-only consumers.
- Post-deploy simulation integration tests exercise the budget-window submit and poll structure so this does not regress.
Proposed fix
- Stop re-exporting gateway endpoints/models from
src.modal.gateway.__init__.
- Add a regression test that importing
src.modal.gateway.models does not import FastAPI endpoints.
- Add a staging integration test that submits and polls a two-year budget-window batch through the deployed simulation gateway.
Problem
API v1's staging integration/deploy flow exposed a simulation API failure when it attempted to call the budget-window batch worker. The parent Modal worker crashed during import before it could run the batch orchestration.
API v1 failing job:
https://github.com/PolicyEngine/policyengine-api/actions/runs/25388257599/job/74461134035
Observed simulation API traceback:
The failure path was:
The versioned simulation Modal image intentionally installs the heavy simulation dependencies, not the FastAPI gateway dependency set. Importing
src.modal.gateway.modelsshould therefore not execute gateway endpoint imports or requirefastapi.Expected behavior
Proposed fix
src.modal.gateway.__init__.src.modal.gateway.modelsdoes not import FastAPI endpoints.