modal 0.68.45__py3-none-any.whl → 0.68.47__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,16 +99,18 @@ def get_function_type(is_generator: Optional[bool]) -> "api_pb2.Function.Functio
99
99
 
100
100
 
101
101
  class FunctionInfo:
102
- """Class that helps us extract a bunch of information about a locally defined function.
102
+ """Utility that determines serialization/deserialization mechanisms for functions
103
103
 
104
- Used for populating the definition of a remote function, and for making .local() calls
105
- on a host with the local definition available.
104
+ * Stored as file vs serialized
105
+ * If serialized: how to serialize the function
106
+ * If file: which module/function name should be used to retrieve
107
+
108
+ Used for populating the definition of a remote function
106
109
  """
107
110
 
108
111
  raw_f: Optional[Callable[..., Any]] # if None - this is a "class service function"
109
112
  function_name: str
110
113
  user_cls: Optional[type[Any]]
111
- definition_type: "modal_proto.api_pb2.Function.DefinitionType.ValueType"
112
114
  module_name: Optional[str]
113
115
 
114
116
  _type: FunctionInfoType
@@ -116,6 +118,12 @@ class FunctionInfo:
116
118
  _base_dir: str
117
119
  _remote_dir: Optional[PurePosixPath] = None
118
120
 
121
+ def get_definition_type(self) -> "modal_proto.api_pb2.Function.DefinitionType.ValueType":
122
+ if self.is_serialized():
123
+ return modal_proto.api_pb2.Function.DEFINITION_TYPE_SERIALIZED
124
+ else:
125
+ return modal_proto.api_pb2.Function.DEFINITION_TYPE_FILE
126
+
119
127
  def is_service_class(self):
120
128
  if self.raw_f is None:
121
129
  assert self.user_cls
@@ -172,7 +180,7 @@ class FunctionInfo:
172
180
  self._base_dir = base_dirs[0]
173
181
  self.module_name = module.__spec__.name
174
182
  self._remote_dir = ROOT_DIR / PurePosixPath(module.__package__.split(".")[0])
175
- self.definition_type = api_pb2.Function.DEFINITION_TYPE_FILE
183
+ self._is_serialized = False
176
184
  self._type = FunctionInfoType.PACKAGE
177
185
  elif hasattr(module, "__file__") and not serialized:
178
186
  # This generally covers the case where it's invoked with
@@ -182,18 +190,18 @@ class FunctionInfo:
182
190
  self._file = os.path.abspath(inspect.getfile(module))
183
191
  self.module_name = inspect.getmodulename(self._file)
184
192
  self._base_dir = os.path.dirname(self._file)
185
- self.definition_type = api_pb2.Function.DEFINITION_TYPE_FILE
193
+ self._is_serialized = False
186
194
  self._type = FunctionInfoType.FILE
187
195
  else:
188
196
  self.module_name = None
189
197
  self._base_dir = os.path.abspath("") # get current dir
190
- self.definition_type = api_pb2.Function.DEFINITION_TYPE_SERIALIZED
191
- if serialized:
198
+ self._is_serialized = True # either explicitly, or by being in a notebook
199
+ if serialized: # if explicit
192
200
  self._type = FunctionInfoType.SERIALIZED
193
201
  else:
194
202
  self._type = FunctionInfoType.NOTEBOOK
195
203
 
196
- if self.definition_type == api_pb2.Function.DEFINITION_TYPE_FILE:
204
+ if not self.is_serialized():
197
205
  # Sanity check that this function is defined in global scope
198
206
  # Unfortunately, there's no "clean" way to do this in Python
199
207
  qualname = f.__qualname__ if f else user_cls.__qualname__
@@ -203,7 +211,7 @@ class FunctionInfo:
203
211
  )
204
212
 
205
213
  def is_serialized(self) -> bool:
206
- return self.definition_type == api_pb2.Function.DEFINITION_TYPE_SERIALIZED
214
+ return self._is_serialized
207
215
 
208
216
  def serialized_function(self) -> bytes:
209
217
  # Note: this should only be called from .load() and not at function decoration time
@@ -312,7 +320,7 @@ class FunctionInfo:
312
320
  if self._type == FunctionInfoType.PACKAGE:
313
321
  if config.get("automount"):
314
322
  return [_Mount.from_local_python_packages(self.module_name)]
315
- elif self.definition_type == api_pb2.Function.DEFINITION_TYPE_FILE:
323
+ elif not self.is_serialized():
316
324
  # mount only relevant file and __init__.py:s
317
325
  return [
318
326
  _Mount.from_local_dir(
@@ -322,7 +330,7 @@ class FunctionInfo:
322
330
  condition=entrypoint_only_package_mount_condition(self._file),
323
331
  )
324
332
  ]
325
- elif self.definition_type == api_pb2.Function.DEFINITION_TYPE_FILE:
333
+ elif not self.is_serialized():
326
334
  remote_path = ROOT_DIR / Path(self._file).name
327
335
  if not _is_modal_path(remote_path):
328
336
  return [
modal/client.pyi CHANGED
@@ -26,7 +26,7 @@ class _Client:
26
26
  _stub: typing.Optional[modal_proto.api_grpc.ModalClientStub]
27
27
 
28
28
  def __init__(
29
- self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.45"
29
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.47"
30
30
  ): ...
31
31
  def is_closed(self) -> bool: ...
32
32
  @property
@@ -81,7 +81,7 @@ class Client:
81
81
  _stub: typing.Optional[modal_proto.api_grpc.ModalClientStub]
82
82
 
83
83
  def __init__(
84
- self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.45"
84
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.47"
85
85
  ): ...
86
86
  def is_closed(self) -> bool: ...
87
87
  @property
modal/functions.py CHANGED
@@ -753,7 +753,7 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type
753
753
  mount_ids=loaded_mount_ids,
754
754
  secret_ids=[secret.object_id for secret in secrets],
755
755
  image_id=(image.object_id if image else ""),
756
- definition_type=info.definition_type,
756
+ definition_type=info.get_definition_type(),
757
757
  function_serialized=function_serialized or b"",
758
758
  class_serialized=class_serialized or b"",
759
759
  function_type=function_type,
modal/functions.pyi CHANGED
@@ -462,11 +462,11 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
462
462
 
463
463
  _call_generator_nowait: ___call_generator_nowait_spec
464
464
 
465
- class __remote_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
465
+ class __remote_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
466
466
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER: ...
467
467
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER: ...
468
468
 
469
- remote: __remote_spec[P, ReturnType]
469
+ remote: __remote_spec[ReturnType, P]
470
470
 
471
471
  class __remote_gen_spec(typing_extensions.Protocol):
472
472
  def __call__(self, *args, **kwargs) -> typing.Generator[typing.Any, None, None]: ...
@@ -479,17 +479,17 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
479
479
  def _get_obj(self) -> typing.Optional[modal.cls.Obj]: ...
480
480
  def local(self, *args: P.args, **kwargs: P.kwargs) -> OriginalReturnType: ...
481
481
 
482
- class ___experimental_spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
482
+ class ___experimental_spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
483
483
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
484
484
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
485
485
 
486
- _experimental_spawn: ___experimental_spawn_spec[P, ReturnType]
486
+ _experimental_spawn: ___experimental_spawn_spec[ReturnType, P]
487
487
 
488
- class __spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
488
+ class __spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
489
489
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
490
490
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
491
491
 
492
- spawn: __spawn_spec[P, ReturnType]
492
+ spawn: __spawn_spec[ReturnType, P]
493
493
 
494
494
  def get_raw_f(self) -> typing.Callable[..., typing.Any]: ...
495
495
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modal
3
- Version: 0.68.45
3
+ Version: 0.68.47
4
4
  Summary: Python client library for Modal
5
5
  Author: Modal Labs
6
6
  Author-email: support@modal.com
@@ -19,7 +19,7 @@ modal/app.py,sha256=JWefPs4yB70BKQwSZejB_4_muhxn63cC9UmnNvpQ9XY,45526
19
19
  modal/app.pyi,sha256=FYPCEJNhof4YF6HIuNP_2yG6s2PgZnKW9tO1hFE6sfA,25194
20
20
  modal/call_graph.py,sha256=1g2DGcMIJvRy-xKicuf63IVE98gJSnQsr8R_NVMptNc,2581
21
21
  modal/client.py,sha256=JAnd4-GCN093BwkvOFAK5a6iy5ycxofjpUncMxlrIMw,15253
22
- modal/client.pyi,sha256=TY3jSaKaB-OExejVFSqv97I2K2K-NuGRHwa4MXP5nLk,7280
22
+ modal/client.pyi,sha256=OxOOf5W4hAGglmZ18CWS2VKu-yldaGcm_E28ZPsImHs,7280
23
23
  modal/cloud_bucket_mount.py,sha256=G7T7jWLD0QkmrfKR75mSTwdUZ2xNfj7pkVqb4ipmxmI,5735
24
24
  modal/cloud_bucket_mount.pyi,sha256=CEi7vrH3kDUF4LAy4qP6tfImy2UJuFRcRbsgRNM1wo8,1403
25
25
  modal/cls.py,sha256=3hjb0JcoPjxKZNeK22f5rR43bZRBjoRI7_EMZXY7YrE,31172
@@ -36,8 +36,8 @@ modal/experimental.py,sha256=jFuNbwrNHos47viMB9q-cHJSvf2RDxDdoEcss9plaZE,2302
36
36
  modal/file_io.py,sha256=pDOFNQU5m-x-k3oJauck4fOp3bZ55Vc-_LvSaN5_Bow,16465
37
37
  modal/file_io.pyi,sha256=GMhCCRyMftXYI3HqI9EdGPOx70CbCNi-VC5Sfy5TYnc,7631
38
38
  modal/file_pattern_matcher.py,sha256=V6P74Vc7LAuBFe_uepIaZmoDJiuAvqjFibe0GcMJwxo,5119
39
- modal/functions.py,sha256=-PHjDWuGBfoHYDiZc8eJtD2W9ka-c4jla2vHvA0z1fI,67821
40
- modal/functions.pyi,sha256=snttn47K81lKhmrCLWNVZelZTDhNsbxtw4l1DlLDR74,25317
39
+ modal/functions.py,sha256=aXXXr3rk7BCeh5OWMvxGksGm8FQoYCyrBDGV74FPoPE,67827
40
+ modal/functions.pyi,sha256=oMmcExtQxHwPej06jQ3uBe1tUlSR3VbAx7u3Vm-Ohhg,25317
41
41
  modal/gpu.py,sha256=MTxj6ql8EpgfBg8YmZ5a1cLznyuZFssX1qXbEX4LKVM,7503
42
42
  modal/image.py,sha256=sv45bYaF5Jlmk8mQE3EDADYyXLi14hOe2CUM0Zb8Xao,82243
43
43
  modal/image.pyi,sha256=VY_4HnDBhW8u_Zd3n-YBZ1H9idbTorWGwzsAzY7-B70,24213
@@ -88,7 +88,7 @@ modal/_utils/async_utils.py,sha256=9ubwMkwiDB4gzOYG2jL9j7Fs-5dxHjcifZe3r7JRg-k,2
88
88
  modal/_utils/blob_utils.py,sha256=N66LtZI8PpCkZ7maA7GLW5CAmYUoNJdG-GjaAUR4_NQ,14509
89
89
  modal/_utils/bytes_io_segment_payload.py,sha256=uunxVJS4PE1LojF_UpURMzVK9GuvmYWRqQo_bxEj5TU,3385
90
90
  modal/_utils/deprecation.py,sha256=dycySRBxyZf3ITzEqPNM6MxXTk9-0VVLA8oCPQ5j_Os,3426
91
- modal/_utils/function_utils.py,sha256=LgcveUUb4XU_dWxtqgK_3ujZBvS3cGVzcDOkljyFZ2w,25066
91
+ modal/_utils/function_utils.py,sha256=7vIYYezYcKA-19wBJFaoquVMLfD4LKCTlZlo92an-nY,25141
92
92
  modal/_utils/grpc_testing.py,sha256=H1zHqthv19eGPJz2HKXDyWXWGSqO4BRsxah3L5Xaa8A,8619
93
93
  modal/_utils/grpc_utils.py,sha256=PPB5ay-vXencXNIWPVw5modr3EH7gfq2QPcO5YJ1lMU,7737
94
94
  modal/_utils/hash_utils.py,sha256=zg3J6OGxTFGSFri1qQ12giDz90lWk8bzaxCTUCRtiX4,3034
@@ -164,10 +164,10 @@ modal_proto/options_pb2_grpc.pyi,sha256=CImmhxHsYnF09iENPoe8S4J-n93jtgUYD2JPAc0y
164
164
  modal_proto/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
165
  modal_version/__init__.py,sha256=RT6zPoOdFO99u5Wcxxaoir4ZCuPTbQ22cvzFAXl3vUY,470
166
166
  modal_version/__main__.py,sha256=2FO0yYQQwDTh6udt1h-cBnGd1c4ZyHnHSI4BksxzVac,105
167
- modal_version/_version_generated.py,sha256=WnY6krxop48LTzDQ4GseM2SUj2P1jOy-kc8CbxaY3oY,149
168
- modal-0.68.45.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
169
- modal-0.68.45.dist-info/METADATA,sha256=O7_g2tZtnla6XEVfp2AB-5k25BWbD2VFshcJJE4ucYI,2329
170
- modal-0.68.45.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
171
- modal-0.68.45.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
172
- modal-0.68.45.dist-info/top_level.txt,sha256=1nvYbOSIKcmU50fNrpnQnrrOpj269ei3LzgB6j9xGqg,64
173
- modal-0.68.45.dist-info/RECORD,,
167
+ modal_version/_version_generated.py,sha256=gkRhVl6jqopEWV4HtiiRkMcl5qU23x4ko0vEWlIuB-8,149
168
+ modal-0.68.47.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
169
+ modal-0.68.47.dist-info/METADATA,sha256=V4n9wNGSC6ElQ9E0cH5RDIJ22rqUIB6cZURV9LDcPnU,2329
170
+ modal-0.68.47.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
171
+ modal-0.68.47.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
172
+ modal-0.68.47.dist-info/top_level.txt,sha256=1nvYbOSIKcmU50fNrpnQnrrOpj269ei3LzgB6j9xGqg,64
173
+ modal-0.68.47.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  # Copyright Modal Labs 2024
2
2
 
3
3
  # Note: Reset this value to -1 whenever you make a minor `0.X` release of the client.
4
- build_number = 45 # git: 31a2631
4
+ build_number = 47 # git: 9b7ac6f