Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1543.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed Modal gateway imports so routing metadata does not pull worker-only dependencies into the lightweight gateway image.
2 changes: 1 addition & 1 deletion policyengine_household_api/decorators/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ModalResolvedChannel,
VariableUsageSummary,
)
from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
REQUESTED_VERSION_ENVIRON_KEY,
RESOLVED_CHANNEL_ENVIRON_KEY,
)
Expand Down
2 changes: 1 addition & 1 deletion policyengine_household_api/modal_release/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
empty_manifest,
validate_manifest,
)
from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
MODAL_ROUTING_PAYLOAD_KEY,
modal_routing_payload,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from typing import Any

from policyengine_household_api.models.analytics import ModalResolvedChannel


MODAL_ROUTING_PAYLOAD_KEY = "modal_routing"
REQUESTED_VERSION_ENVIRON_KEY = "policyengine.requested_version"
RESOLVED_CHANNEL_ENVIRON_KEY = "policyengine.resolved_channel"
# Keep this literal in sync with the app's channel values manually. Importing
# the shared enum here pulls heavy, unnecessary dependencies into the Modal
# gateway image and has broken production gateway startup.
RESOLVED_CHANNEL_VALUES = {"current", "frontier"}


def modal_routing_payload(
Expand All @@ -30,9 +32,7 @@ def routing_environ_overrides(payload: dict[str, Any]) -> dict[str, str]:
resolved_channel = routing.get("resolved_channel")
if not isinstance(requested_version, str) or not requested_version:
return {}
if resolved_channel not in {
channel.value for channel in ModalResolvedChannel
}:
if resolved_channel not in RESOLVED_CHANNEL_VALUES:
return {}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any

from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
routing_environ_overrides,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/endpoints/test_household.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from policyengine_household_api.constants import COUNTRY_PACKAGE_VERSIONS
from policyengine_household_api.endpoints.household import _validate_axes
from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
REQUESTED_VERSION_ENVIRON_KEY,
RESOLVED_CHANNEL_ENVIRON_KEY,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/modal_release/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from policyengine_household_api.modal_release.manifest import (
MANIFEST_SCHEMA_VERSION,
)
from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
MODAL_ROUTING_PAYLOAD_KEY,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/modal_release/test_worker_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from policyengine_household_api.modal_release.worker_dispatch import (
dispatch_to_flask_app,
)
from policyengine_household_api.utils.modal_routing_metadata import (
from policyengine_household_api.modal_release.routing_metadata import (
MODAL_ROUTING_PAYLOAD_KEY,
REQUESTED_VERSION_ENVIRON_KEY,
RESOLVED_CHANNEL_ENVIRON_KEY,
Expand Down
Loading