Skip to content

Commit 334ab22

Browse files
authored
Merge pull request #3068 from PolicyEngine/feat/enable-modal-by-default
feat: Enable Modal simulation API by default
2 parents 4b961bd + 3f04db8 commit 334ab22

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: minor
2+
changes:
3+
changed:
4+
- Enable Modal simulation API by default instead of GCP Workflows

policyengine_api/libs/simulation_api_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919

2020
def get_simulation_api() -> (
21-
Union["SimulationAPI", "SimulationAPIModal"] # noqa: F821
22-
):
21+
Union["SimulationAPI", "SimulationAPIModal"]
22+
): # noqa: F821
2323
"""
2424
Get the appropriate simulation API client based on environment configuration.
2525
@@ -37,7 +37,7 @@ def get_simulation_api() -> (
3737
If GCP client is requested but GOOGLE_APPLICATION_CREDENTIALS is not set.
3838
"""
3939
use_modal = (
40-
os.environ.get("USE_MODAL_SIMULATION_API", "false").lower() == "true"
40+
os.environ.get("USE_MODAL_SIMULATION_API", "true").lower() == "true"
4141
)
4242

4343
if use_modal:

tests/unit/libs/test_simulation_api_factory.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,36 +120,29 @@ def test__given_use_modal_env_false__then_returns_gcp_api(
120120
# Then
121121
assert isinstance(api, SimulationAPI)
122122

123-
def test__given_use_modal_env_not_set__then_returns_gcp_api(
123+
def test__given_use_modal_env_not_set__then_returns_modal_api(
124124
self,
125125
mock_factory_logger,
126126
):
127-
# Given
127+
# Given - default is now Modal when env var is not set
128128
import os
129129

130130
env_copy = dict(os.environ)
131131
env_copy.pop("USE_MODAL_SIMULATION_API", None)
132-
env_copy["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/creds.json"
133132

134133
with patch.dict("os.environ", env_copy, clear=True):
135-
with patch(
136-
"policyengine_api.libs.simulation_api.executions_v1.ExecutionsClient"
137-
):
138-
with patch(
139-
"policyengine_api.libs.simulation_api.workflows_v1.WorkflowsClient"
140-
):
141-
from policyengine_api.libs.simulation_api_factory import (
142-
get_simulation_api,
143-
)
144-
from policyengine_api.libs.simulation_api import (
145-
SimulationAPI,
146-
)
134+
from policyengine_api.libs.simulation_api_factory import (
135+
get_simulation_api,
136+
)
137+
from policyengine_api.libs.simulation_api_modal import (
138+
SimulationAPIModal,
139+
)
147140

148-
# When
149-
api = get_simulation_api()
141+
# When
142+
api = get_simulation_api()
150143

151-
# Then
152-
assert isinstance(api, SimulationAPI)
144+
# Then
145+
assert isinstance(api, SimulationAPIModal)
153146

154147
def test__given_use_modal_env_false__then_logs_gcp_selection(
155148
self,
@@ -189,11 +182,11 @@ def test__given_gcp_selected_without_credentials__then_raises_error(
189182
self,
190183
mock_factory_logger,
191184
):
192-
# Given
185+
# Given - explicitly select GCP without credentials
193186
import os
194187

195188
env_copy = dict(os.environ)
196-
env_copy.pop("USE_MODAL_SIMULATION_API", None)
189+
env_copy["USE_MODAL_SIMULATION_API"] = "false"
197190
env_copy.pop("GOOGLE_APPLICATION_CREDENTIALS", None)
198191

199192
with patch.dict("os.environ", env_copy, clear=True):

0 commit comments

Comments
 (0)