Skip to content

Commit

Permalink
hydrate functions then classes in container entrypoint (#2583)
Browse files Browse the repository at this point in the history
  • Loading branch information
devennavani authored Nov 28, 2024
1 parent 6f2ffcb commit bd320d8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions modal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,19 @@ def _init_container(self, client: _Client, running_app: RunningApp):

_App._container_app = running_app

# Hydrate objects on app
indexed_objects = dict(**self._functions, **self._classes)
for tag, object_id in running_app.tag_to_object_id.items():
if tag in indexed_objects:
obj = indexed_objects[tag]
handle_metadata = running_app.object_handle_metadata[object_id]
obj._hydrate(object_id, client, handle_metadata)
# Hydrate objects on app -- hydrating functions first so that when a class is being hydrated its
# corresponding class service function is already hydrated.
def hydrate_objects(objects_dict):
for tag, object_id in running_app.tag_to_object_id.items():
if tag in objects_dict:
obj = objects_dict[tag]
handle_metadata = running_app.object_handle_metadata[object_id]
obj._hydrate(object_id, client, handle_metadata)

# Hydrate function objects
hydrate_objects(self._functions)
# Hydrate class objects
hydrate_objects(self._classes)

@property
def registered_functions(self) -> Dict[str, _Function]:
Expand Down

0 comments on commit bd320d8

Please sign in to comment.