Skip to content

Commit

Permalink
obj init cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
devennavani committed Oct 31, 2024
1 parent 9e8c2a9 commit 7215fba
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modal/cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
self,
user_cls: type,
class_service_function: Optional[_Function], # only None for <v0.63 classes
classbound_methods: Dict[str, _Function],
# classbound_methods: Dict[str, _Function],
from_other_workspace: bool,
options: Optional[api_pb2.FunctionOptions],
args,
Expand All @@ -103,19 +103,19 @@ def __init__(
check_valid_cls_constructor_arg(key, kwarg)

self._method_functions = {}
if class_service_function:
if class_service_function._is_hydrated:
# >= v0.63 classes
# first create the singular object function used by all methods on this parameterization
self._instance_service_function = class_service_function._bind_parameters(
self, from_other_workspace, options, args, kwargs
)
for method_name, class_bound_method in classbound_methods.items():
for method_name, class_bound_method in class_service_function._method_functions.items():
method = self._instance_service_function._bind_instance_method(class_bound_method)
self._method_functions[method_name] = method
else:
# <v0.63 classes - bind each individual method to the new parameters
self._instance_service_function = None
for method_name, class_bound_method in classbound_methods.items():
for method_name, class_bound_method in class_service_function._method_functions.items():
method = class_bound_method._bind_parameters(self, from_other_workspace, options, args, kwargs)
self._method_functions[method_name] = method

Expand Down Expand Up @@ -267,7 +267,6 @@ def _get_partial_functions(self) -> Dict[str, _PartialFunction]:
def _hydrate_metadata(self, metadata: Message):
assert isinstance(metadata, api_pb2.ClassHandleMetadata)
if self._class_service_function:
print("foo")
if self._class_service_function._method_functions:
# The class only has a class service service function and no method placeholders.
return
Expand Down Expand Up @@ -542,7 +541,7 @@ def __call__(self, *args, **kwargs) -> _Obj:
return _Obj(
self._user_cls,
self._class_service_function,
self._class_service_function._method_functions,
# self._class_service_function._method_functions,
self._from_other_workspace,
self._options,
args,
Expand Down

0 comments on commit 7215fba

Please sign in to comment.