diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..3332d2280 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + changed: + - Enable Modal simulation API by default instead of GCP Workflows diff --git a/policyengine_api/libs/simulation_api_factory.py b/policyengine_api/libs/simulation_api_factory.py index c94d1f90b..38af346d1 100644 --- a/policyengine_api/libs/simulation_api_factory.py +++ b/policyengine_api/libs/simulation_api_factory.py @@ -18,8 +18,8 @@ def get_simulation_api() -> ( - Union["SimulationAPI", "SimulationAPIModal"] # noqa: F821 -): + Union["SimulationAPI", "SimulationAPIModal"] +): # noqa: F821 """ Get the appropriate simulation API client based on environment configuration. @@ -37,7 +37,7 @@ def get_simulation_api() -> ( If GCP client is requested but GOOGLE_APPLICATION_CREDENTIALS is not set. """ use_modal = ( - os.environ.get("USE_MODAL_SIMULATION_API", "false").lower() == "true" + os.environ.get("USE_MODAL_SIMULATION_API", "true").lower() == "true" ) if use_modal: diff --git a/tests/unit/libs/test_simulation_api_factory.py b/tests/unit/libs/test_simulation_api_factory.py index 6602c47b4..9e243197a 100644 --- a/tests/unit/libs/test_simulation_api_factory.py +++ b/tests/unit/libs/test_simulation_api_factory.py @@ -120,36 +120,29 @@ def test__given_use_modal_env_false__then_returns_gcp_api( # Then assert isinstance(api, SimulationAPI) - def test__given_use_modal_env_not_set__then_returns_gcp_api( + def test__given_use_modal_env_not_set__then_returns_modal_api( self, mock_factory_logger, ): - # Given + # Given - default is now Modal when env var is not set import os env_copy = dict(os.environ) env_copy.pop("USE_MODAL_SIMULATION_API", None) - env_copy["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/creds.json" with patch.dict("os.environ", env_copy, clear=True): - with patch( - "policyengine_api.libs.simulation_api.executions_v1.ExecutionsClient" - ): - with patch( - "policyengine_api.libs.simulation_api.workflows_v1.WorkflowsClient" - ): - from policyengine_api.libs.simulation_api_factory import ( - get_simulation_api, - ) - from policyengine_api.libs.simulation_api import ( - SimulationAPI, - ) + from policyengine_api.libs.simulation_api_factory import ( + get_simulation_api, + ) + from policyengine_api.libs.simulation_api_modal import ( + SimulationAPIModal, + ) - # When - api = get_simulation_api() + # When + api = get_simulation_api() - # Then - assert isinstance(api, SimulationAPI) + # Then + assert isinstance(api, SimulationAPIModal) def test__given_use_modal_env_false__then_logs_gcp_selection( self, @@ -189,11 +182,11 @@ def test__given_gcp_selected_without_credentials__then_raises_error( self, mock_factory_logger, ): - # Given + # Given - explicitly select GCP without credentials import os env_copy = dict(os.environ) - env_copy.pop("USE_MODAL_SIMULATION_API", None) + env_copy["USE_MODAL_SIMULATION_API"] = "false" env_copy.pop("GOOGLE_APPLICATION_CREDENTIALS", None) with patch.dict("os.environ", env_copy, clear=True):