Skip to content

Commit

Permalink
Merge branch 'cathy/batching-integration' of github.com:modal-labs/mo…
Browse files Browse the repository at this point in the history
…dal-client into cathy/batching-integration
  • Loading branch information
cathyzbn committed Jul 31, 2024
2 parents c6d8ff0 + 9a83ef5 commit 3df6fb4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Starting in this version, all `@methods` and web endpoints will be part of the s



### v0.62.230 (2024-06-18)
### 0.62.230 (2024-06-18)

- It is now an error to create or lookup Modal objects (`Volume`, `Dict`, `Secret`, etc.) with an invalid name. Object names must be shorter than 64 characters and may contain only alphanumeric characters, dashes, periods, and underscores. The name check had inadvertently been removed for a brief time following an internal refactor and then reintroduced as a warning. It is once more a hard error. Please get in touch if this is blocking access to your data.

Expand Down
27 changes: 15 additions & 12 deletions modal/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,24 @@ def _init_from_other(self, other: O):
# Transient use case, see Dict, Queue, and SharedVolume
self._init(other._rep, other._load, other._is_another_app, other._preload)

def _validate_is_hydrated(self: O):
if not self._is_hydrated:
object_type = self.__class__.__name__.strip("_")
if hasattr(self, "_app") and getattr(self._app, "_running_app", "") is None:
# The most common cause of this error: e.g., user called a Function without using App.run()
reason = ", because the App it is defined on is not running."
else:
# Technically possible, but with an ambiguous cause.
reason = ""
raise ExecutionError(
f"{object_type} has not been hydrated with the metadata it needs to run on Modal{reason}."
)

def clone(self: O) -> O:
"""mdmd:hidden Clone a given hydrated object."""

# Object to clone must already be hydrated, otherwise from_loader is more suitable.
assert self._is_hydrated

self._validate_is_hydrated()
obj = _Object.__new__(type(self))
obj._initialize_from_other(self)
return obj
Expand Down Expand Up @@ -204,16 +216,7 @@ async def resolve(self):
if self._is_hydrated:
return
elif not self._hydrate_lazily:
object_type = self.__class__.__name__.strip("_")
if hasattr(self, "_app") and getattr(self._app, "_running_app", "") is None:
# The most common cause of this error: e.g., user called a Function without using App.run()
reason = ", because the App it is defined on is not running."
else:
# Technically possible, but with an ambiguous cause.
reason = ""
raise ExecutionError(
f"{object_type} has not been hydrated with the metadata it needs to run on Modal{reason}."
)
self._validate_is_hydrated()
else:
# TODO: this client and/or resolver can't be changed by a caller to X.from_name()
resolver = Resolver(await _Client.from_env())
Expand Down
2 changes: 1 addition & 1 deletion modal_version/_version_generated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Modal Labs 2024

# Note: Reset this value to -1 whenever you make a minor `0.X` release of the client.
build_number = 88 # git: f991317
build_number = 90 # git: 0bc7824
5 changes: 5 additions & 0 deletions test/cls_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def test_class_with_options(client, servicer):
assert options.retry_policy.retries == 5


def test_class_with_options_need_hydrating(client, servicer):
with pytest.raises(ExecutionError, match="hydrate"):
Foo.with_options() # type: ignore


# Reusing the app runs into an issue with stale function handles.
# TODO (akshat): have all the client tests use separate apps, and throw
# an exception if the user tries to reuse an app.
Expand Down
2 changes: 1 addition & 1 deletion test/mounted_files_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def symlinked_python_installation_venv_path(tmp_path, repo_root):
symlink_python_install.symlink_to(python_install_dir)

# use a python executable specified via the above symlink
symlink_python_executable = symlink_python_install / "bin" / "python"
symlink_python_executable = symlink_python_install / "bin" / actual_executable.name
# create a new venv
subprocess.check_call([symlink_python_executable, "-m", "venv", venv_path, "--copies"])
# check that a builtin module, like ast, is indeed identified to be in the non-resolved install path
Expand Down

0 comments on commit 3df6fb4

Please sign in to comment.