Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
thundergolfer committed Sep 3, 2024
1 parent f10aa4f commit 5336ec7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modal/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class _Object:
_object_id: str
_client: _Client
_is_hydrated: bool
_is_rehydrating: bool
_is_rehydrated: bool

@classmethod
def __init_subclass__(cls, type_prefix: Optional[str] = None):
Expand Down Expand Up @@ -222,6 +222,7 @@ async def resolve(self):
self._is_hydrated = False # un-hydrate and re-resolve
resolver = Resolver(await _Client.from_env())
await resolver.load(self)
self._is_rehydrated = True
return
elif not self._hydrate_lazily:
self._validate_is_hydrated()
Expand Down
4 changes: 4 additions & 0 deletions test/container_app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ async def test_container_snapshot_reference_capture(container_client, tmpdir, se
assert new_app_id != app_id
await f.remote.aio()
assert f.object_id == "fu-2"
# Purposefully break FunctionGet to check the hydration is cached.
del servicer.app_objects[new_app_id]
await f.remote.aio() # remote call succeeds because it didn't re-hydrate Function
assert f.object_id == "fu-2"
channel.close()


Expand Down

0 comments on commit 5336ec7

Please sign in to comment.