Skip to content

Commit

Permalink
Slightly different error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Feb 10, 2025
1 parent ff265de commit c687b14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modal/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,5 @@ def parse_gpu_config(value: GPU_T) -> api_pb2.GPUConfig:
return api_pb2.GPUConfig()
else:
raise InvalidError(
f"Invalid GPU config: {value}. Value must be a string or `None` (or a deprecated `_GPUConfig` object)."
f"Invalid GPU config: {value}. Value must be a string or `None` (or a deprecated `modal.gpu` object)"
)
27 changes: 27 additions & 0 deletions test/function_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,33 @@ def test_default_cloud_provider(client, servicer, monkeypatch):
assert f.cloud_provider_str == "OCI"


def test_default_cloud_provider_int(client, servicer, monkeypatch):
# TODO(erikbern): remove support for this very soon
app = App()

monkeypatch.setenv("MODAL_DEFAULT_CLOUD", "42")
app.function()(dummy)
with app.run(client=client):
object_id: str = app.registered_functions["dummy"].object_id
f = servicer.app_functions[object_id]

assert f.cloud_provider == 42
assert f.cloud_provider_str == "42"


def test_default_cloud_provider_str(client, servicer, monkeypatch):
app = App()

monkeypatch.setenv("MODAL_DEFAULT_CLOUD", "xyz")
app.function()(dummy)
with app.run(client=client):
object_id: str = app.registered_functions["dummy"].object_id
f = servicer.app_functions[object_id]

assert f.cloud_provider == api_pb2.CLOUD_PROVIDER_UNSPECIFIED
assert f.cloud_provider_str == "xyz"


def test_not_hydrated():
with pytest.raises(ExecutionError):
assert foo.remote(2, 4) == 20
Expand Down

0 comments on commit c687b14

Please sign in to comment.