Skip to content

Budget-window batch worker fails importing gateway models in Modal simulation image #476

@anth-volk

Description

@anth-volk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions