modAL 1.3.1.dev24__py3-none-any.whl → 1.3.1.dev26__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.
modal/cli/run.py CHANGED
@@ -49,6 +49,26 @@ class AnyParamType(click.ParamType):
49
49
  return value
50
50
 
51
51
 
52
+ class LiteralIntParamType(click.Choice):
53
+ """A ParamType for Literal types containing only integers."""
54
+
55
+ def __init__(self, literal_values: tuple[int, ...]):
56
+ self.int_values = {str(v): v for v in literal_values}
57
+ super().__init__(list(self.int_values.keys()))
58
+
59
+ def convert(self, value, param, ctx):
60
+ # If value is already an int (e.g., from a default), validate and return it
61
+ # Exclude bools since they're a subclass of int but we don't support them
62
+ if isinstance(value, int) and not isinstance(value, bool):
63
+ if value in self.int_values.values():
64
+ return value
65
+ # Invalid int - convert to string so Choice can generate a nice error message
66
+ value = str(value)
67
+ # Use Choice's validation for string inputs, then convert back to int
68
+ str_value = super().convert(value, param, ctx)
69
+ return self.int_values[str_value]
70
+
71
+
52
72
  option_parsers = {
53
73
  "str": str,
54
74
  "int": int,
@@ -99,6 +119,20 @@ def _get_cli_runnable_signature(sig: inspect.Signature, type_hints: dict[str, ty
99
119
  return CliRunnableSignature(signature, has_variadic_args)
100
120
 
101
121
 
122
+ def _get_literal_values(type_hint: Any) -> Optional[tuple[Any, ...]]:
123
+ """Extract values from a Literal type annotation.
124
+
125
+ Returns None if not a Literal type, otherwise returns tuple of literal values.
126
+ """
127
+ try:
128
+ origin = typing.get_origin(type_hint)
129
+ if origin is typing.Literal:
130
+ return typing.get_args(type_hint)
131
+ except Exception:
132
+ pass
133
+ return None
134
+
135
+
102
136
  def _get_param_type_as_str(annot: Any) -> str:
103
137
  """Return annotation as a string, handling various spellings for optional types."""
104
138
  annot_str = str(annot)
@@ -121,16 +155,28 @@ def _add_click_options(func, parameters: dict[str, ParameterMetadata]):
121
155
  Kind of like typer, but using options instead of positional arguments
122
156
  """
123
157
  for param in parameters.values():
124
- param_type_str = _get_param_type_as_str(param["type_hint"])
125
158
  param_name = param["name"].replace("_", "-")
126
159
  cli_name = "--" + param_name
127
- if param_type_str == "bool":
128
- cli_name += "/--no-" + param_name
129
160
 
130
- parser = option_parsers.get(param_type_str)
131
- if parser is None:
132
- msg = f"Parameter `{param_name}` has unparseable annotation: {param['annotation']}"
133
- raise NoParserAvailable(msg)
161
+ parser: Any
162
+ if (literal_values := _get_literal_values(param["type_hint"])) is not None:
163
+ if all(isinstance(v, str) for v in literal_values):
164
+ parser = click.Choice(list(literal_values))
165
+ elif all(isinstance(v, int) and not isinstance(v, bool) for v in literal_values):
166
+ parser = LiteralIntParamType(literal_values)
167
+ else:
168
+ # Mixed types, booleans, or other unsupported types
169
+ msg = f"Parameter `{param_name}` has unparseable annotation: {param['annotation']}"
170
+ raise NoParserAvailable(msg)
171
+ else:
172
+ param_type_str = _get_param_type_as_str(param["type_hint"])
173
+ if param_type_str == "bool":
174
+ cli_name += "/--no-" + param_name
175
+
176
+ parser = option_parsers.get(param_type_str)
177
+ if parser is None:
178
+ msg = f"Parameter `{param_name}` has unparseable annotation: {param['annotation']}"
179
+ raise NoParserAvailable(msg)
134
180
  kwargs: Any = {
135
181
  "type": parser,
136
182
  }
modal/client.pyi CHANGED
@@ -33,7 +33,7 @@ class _Client:
33
33
  server_url: str,
34
34
  client_type: int,
35
35
  credentials: typing.Optional[tuple[str, str]],
36
- version: str = "1.3.1.dev24",
36
+ version: str = "1.3.1.dev26",
37
37
  ):
38
38
  """mdmd:hidden
39
39
  The Modal client object is not intended to be instantiated directly by users.
@@ -163,7 +163,7 @@ class Client:
163
163
  server_url: str,
164
164
  client_type: int,
165
165
  credentials: typing.Optional[tuple[str, str]],
166
- version: str = "1.3.1.dev24",
166
+ version: str = "1.3.1.dev26",
167
167
  ):
168
168
  """mdmd:hidden
169
169
  The Modal client object is not intended to be instantiated directly by users.
modal/functions.pyi CHANGED
@@ -407,7 +407,7 @@ class Function(
407
407
 
408
408
  _call_generator: ___call_generator_spec
409
409
 
410
- class __remote_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
410
+ class __remote_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
411
411
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER:
412
412
  """Calls the function remotely, executing it with the given arguments and returning the execution's result."""
413
413
  ...
@@ -416,7 +416,7 @@ class Function(
416
416
  """Calls the function remotely, executing it with the given arguments and returning the execution's result."""
417
417
  ...
418
418
 
419
- remote: __remote_spec[modal._functions.ReturnType, modal._functions.P]
419
+ remote: __remote_spec[modal._functions.P, modal._functions.ReturnType]
420
420
 
421
421
  class __remote_gen_spec(typing_extensions.Protocol):
422
422
  def __call__(self, /, *args, **kwargs) -> typing.Generator[typing.Any, None, None]:
@@ -443,7 +443,7 @@ class Function(
443
443
  """
444
444
  ...
445
445
 
446
- class ___experimental_spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
446
+ class ___experimental_spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
447
447
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
448
448
  """[Experimental] Calls the function with the given arguments, without waiting for the results.
449
449
 
@@ -466,7 +466,7 @@ class Function(
466
466
  """
467
467
  ...
468
468
 
469
- _experimental_spawn: ___experimental_spawn_spec[modal._functions.ReturnType, modal._functions.P]
469
+ _experimental_spawn: ___experimental_spawn_spec[modal._functions.P, modal._functions.ReturnType]
470
470
 
471
471
  class ___spawn_map_inner_spec(typing_extensions.Protocol[P_INNER]):
472
472
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> None: ...
@@ -474,7 +474,7 @@ class Function(
474
474
 
475
475
  _spawn_map_inner: ___spawn_map_inner_spec[modal._functions.P]
476
476
 
477
- class __spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER]):
477
+ class __spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
478
478
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
479
479
  """Calls the function with the given arguments, without waiting for the results.
480
480
 
@@ -495,7 +495,7 @@ class Function(
495
495
  """
496
496
  ...
497
497
 
498
- spawn: __spawn_spec[modal._functions.ReturnType, modal._functions.P]
498
+ spawn: __spawn_spec[modal._functions.P, modal._functions.ReturnType]
499
499
 
500
500
  def get_raw_f(self) -> collections.abc.Callable[..., typing.Any]:
501
501
  """Return the inner Python object wrapped by this Modal Function."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.3.1.dev24
3
+ Version: 1.3.1.dev26
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -26,7 +26,7 @@ modal/app.pyi,sha256=0myfmGDqVoEoxTUWFG_Z4-0KFMlXZXe8k5hcFzl8k2I,50863
26
26
  modal/billing.py,sha256=zmQ3bcCJlwa4KD1IA_QgdWpm1pn13c-7qfy79iEauYI,195
27
27
  modal/call_graph.py,sha256=1g2DGcMIJvRy-xKicuf63IVE98gJSnQsr8R_NVMptNc,2581
28
28
  modal/client.py,sha256=CXnyJYLhY--xaCkjv3tpjYDca8AuXGQG1IiaXQVX4y4,14436
29
- modal/client.pyi,sha256=vzEvhPJ0G0DxwHAyAAdCQ9BA0ahKibjKp09ynYVYwbc,14473
29
+ modal/client.pyi,sha256=EgiosZrIfT2Wr2bZvU6vjLkby7X1w-fwWVIfDfKAceY,14473
30
30
  modal/cloud_bucket_mount.py,sha256=cvVj5Rt4nDHoQbTneoJPTaAcnl_Ab_mrsjnnzd0v9OI,6013
31
31
  modal/cloud_bucket_mount.pyi,sha256=vXusGMOUk9HjCs4lhxteuCK4xLQclPfugGWKo7LECEA,7539
32
32
  modal/cls.py,sha256=DNXcOrd9l2DoX-nLGdpwXm-N9V0BbQEvWA7d2UwFf44,41510
@@ -43,7 +43,7 @@ modal/file_io.py,sha256=dx90C5L8cQv2Z7pVVPaQmE0R3pUOGv2h-wn1qNNXbGQ,19818
43
43
  modal/file_io.pyi,sha256=up9OhV2Y54n-X7nlfV6j_eBwJ8D2cNMEswZ1iddrEQw,15877
44
44
  modal/file_pattern_matcher.py,sha256=A_Kdkej6q7YQyhM_2-BvpFmPqJ0oHb54B6yf9VqvPVE,8116
45
45
  modal/functions.py,sha256=kcNHvqeGBxPI7Cgd57NIBBghkfbeFJzXO44WW0jSmao,325
46
- modal/functions.pyi,sha256=fkjxeYAqh6sX9C84gjUGoLVgHT1IfNB_07h0fpmIyWw,36465
46
+ modal/functions.pyi,sha256=fDH5yZSKq_uUrcze_zwWWZyxSCeEI1PfGlGOqCutCTY,36465
47
47
  modal/gpu.py,sha256=Fe5ORvVPDIstSq1xjmM6OoNgLYFWvogP9r5BgmD3hYg,6769
48
48
  modal/image.py,sha256=HKPUQwdXCwuP7d_KZyEYXMVvtyIQH1_H3_BslQEk6ck,109094
49
49
  modal/image.pyi,sha256=x8a6gohK9XD35z8MejOmKHauOnI7JwbQcZhp3bVfB5I,78383
@@ -145,7 +145,7 @@ modal/cli/launch.py,sha256=1inePjuiqV3HHwk0H-Lk-UAxhkoodCwFoRswD_dat2U,3840
145
145
  modal/cli/network_file_system.py,sha256=AOT24KkYEM3YaHIPIZGe8SsA4-mDyj50o9HNwDsHiaE,7664
146
146
  modal/cli/profile.py,sha256=g8X6tFFK9ccKyu2he9Yu19WLSLNdztzECgmIV__XJFs,3257
147
147
  modal/cli/queues.py,sha256=S5dqk6lEd_2fJolHqoN9iRs6EkeTa0k7KqJWBBGS23k,6170
148
- modal/cli/run.py,sha256=iYMx45Q3IqjVj_KA7GB5QkreayJCv_hPTQ14deGdacE,19341
148
+ modal/cli/run.py,sha256=RMQnTGL42CrpTn8YPK5wXRUrngDImNLt4BT7jqTI9gY,21340
149
149
  modal/cli/secret.py,sha256=zkCztov8c4x8CI8G0EoyieUfv9XLQQtVXV8xeMLK-Os,8044
150
150
  modal/cli/shell.py,sha256=L5Dw8yeuu9-f6vNlBGbUT4oh9AVSK4GuB5J6m6vYLBk,12613
151
151
  modal/cli/token.py,sha256=OiVPDsFo6EpCGVuOOx7Q9WjKxVKIka2gRx_676MaITU,4017
@@ -158,7 +158,7 @@ modal/experimental/__init__.py,sha256=GOuo3t4-Le0ZVddiHIOw0MQxkdTJge-bVbhDvgnblm
158
158
  modal/experimental/flash.py,sha256=GJZwSr-4OHlP6gCIZdcbsSb8D8WX9xJwMphjwcfsRoU,31262
159
159
  modal/experimental/flash.pyi,sha256=W62a0AhmLUuH9a0n8Y3-DYhyEEFH3-bRUQFphOQfKHg,16418
160
160
  modal/experimental/ipython.py,sha256=TrCfmol9LGsRZMeDoeMPx3Hv3BFqQhYnmD_iH0pqdhk,2904
161
- modal-1.3.1.dev24.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
161
+ modal-1.3.1.dev26.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
162
162
  modal_docs/__init__.py,sha256=svYKtV8HDwDCN86zbdWqyq5T8sMdGDj0PVlzc2tIxDM,28
163
163
  modal_docs/gen_cli_docs.py,sha256=c1yfBS_x--gL5bs0N4ihMwqwX8l3IBWSkBAKNNIi6bQ,3801
164
164
  modal_docs/gen_reference_docs.py,sha256=d_CQUGQ0rfw28u75I2mov9AlS773z9rG40-yq5o7g2U,6359
@@ -166,10 +166,10 @@ modal_docs/mdmd/__init__.py,sha256=svYKtV8HDwDCN86zbdWqyq5T8sMdGDj0PVlzc2tIxDM,2
166
166
  modal_docs/mdmd/mdmd.py,sha256=tUTImNd4UMFk1opkaw8J672gX8AkBO5gbY2S_NMxsxs,7140
167
167
  modal_docs/mdmd/signatures.py,sha256=XJaZrK7Mdepk5fdX51A8uENiLFNil85Ud0d4MH8H5f0,3218
168
168
  modal_proto/__init__.py,sha256=MIEP8jhXUeGq_eCjYFcqN5b1bxBM4fdk0VESpjWR0fc,28
169
- modal_proto/api.proto,sha256=GXKOqBNz9URbPeIWchVUNfsQNxhNwD356aMfyX6d0uc,112224
169
+ modal_proto/api.proto,sha256=GhR7Tmb5fWMFV5yWGnRzQvyCO1_uW-u4YvCoI_H0Wco,112379
170
170
  modal_proto/api_grpc.py,sha256=ozNudkNLbPLp2bFm0bJtb0FHK9ACvJXXnGy771noCKc,135188
171
- modal_proto/api_pb2.py,sha256=DeyC243zTKxyoQR8koJFroYEdim1aK7gXYmcOKFNvi8,388892
172
- modal_proto/api_pb2.pyi,sha256=-a8hoKsyc2g_H_6SFD3ZRU_szPJ1cwTfkNrtO7I0vdM,549568
171
+ modal_proto/api_pb2.py,sha256=jDHJi7-YmJBj3J1NijOmxSJ7TbaMVovf9i-pHuRzw_M,388965
172
+ modal_proto/api_pb2.pyi,sha256=qyHiqRccVC9g9zk4VSHKpqZ9uJGj39V-YNTj83Pl1Ms,549964
173
173
  modal_proto/api_pb2_grpc.py,sha256=hHdfvfbS6HELZXTmHNfxlgPxFRDSc2B81G8YRtLwuHM,291347
174
174
  modal_proto/api_pb2_grpc.pyi,sha256=cqpXpAVrLoMQMCCyzyW5oXSFKmUPC9Y2wkTOpwNeAGM,68141
175
175
  modal_proto/modal_api_grpc.py,sha256=ls_o6oVYm8iup0nbKGPqs-CcJZJrry0eIY51mQFJRUc,21407
@@ -180,10 +180,10 @@ modal_proto/task_command_router_pb2.py,sha256=2Y8wRvnq4_7RiQ-5ZAPIgXaxrHv_MXzgS5
180
180
  modal_proto/task_command_router_pb2.pyi,sha256=yI4tFteErLlonFA2HyaWtONfhY_VGSe7KCWFIspvmkE,16323
181
181
  modal_proto/task_command_router_pb2_grpc.py,sha256=q2VWfK2-4uDcPaPLhAqPZkgxhuQRYnWmwUcnEbPbGuk,13895
182
182
  modal_proto/task_command_router_pb2_grpc.pyi,sha256=e1MM10VGUgDkm041v53QeTglGQPzTpA0FUsFtezjp74,4536
183
- modal_version/__init__.py,sha256=eBXZa63P2mg95hILp8Aek07wu1xLlZ1OX8Uw6tJj-LI,121
183
+ modal_version/__init__.py,sha256=7tbtl25ym-HZEH6ltI7zPvpaQ96GO0eoB3Qiq8JHWKU,121
184
184
  modal_version/__main__.py,sha256=nLUbubxKx7GXNzJIkTB7M7_u8080LyLM0IS0rzFkC_c,119
185
- modal-1.3.1.dev24.dist-info/METADATA,sha256=oBb3BUZSJMnTFWQ1_ZJ53JBuz5Aym7AIqwh1zMN6yPw,2582
186
- modal-1.3.1.dev24.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
187
- modal-1.3.1.dev24.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
188
- modal-1.3.1.dev24.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
189
- modal-1.3.1.dev24.dist-info/RECORD,,
185
+ modal-1.3.1.dev26.dist-info/METADATA,sha256=t9ETeUwuxaQrVMx9cho1fSiDQZV1LfWPdrgL5r8hdEw,2582
186
+ modal-1.3.1.dev26.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
187
+ modal-1.3.1.dev26.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
188
+ modal-1.3.1.dev26.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
189
+ modal-1.3.1.dev26.dist-info/RECORD,,
modal_proto/api.proto CHANGED
@@ -1561,6 +1561,7 @@ message Function {
1561
1561
 
1562
1562
  bool single_use_containers = 91; // When True, containers will shut down after handling a single input
1563
1563
 
1564
+ bool is_server = 92; // When True, the function is a server-side function.
1564
1565
  }
1565
1566
 
1566
1567
  message FunctionAsyncInvokeRequest {
@@ -1744,6 +1745,8 @@ message FunctionData {
1744
1745
  // Attribute on the module with the implementation, which may differ from function_name
1745
1746
  // when the user provided a custom name= for the Function inside the Application namespace
1746
1747
  string implementation_name = 40;
1748
+
1749
+ bool is_server = 41; // When True, the function is a server-side function.
1747
1750
  }
1748
1751
 
1749
1752
  message FunctionExtended {