modAL 1.3.1.dev24__py3-none-any.whl → 1.3.1.dev25__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.dev25",
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.dev25",
167
167
  ):
168
168
  """mdmd:hidden
169
169
  The Modal client object is not intended to be instantiated directly by users.
@@ -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.dev25
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=4BCHbzHfz3z6AxEpeRJ65DXjuk_Nb1khNKgdsjf7-_c,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
@@ -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.dev25.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
@@ -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=GdWEmyGQZpEknf8Gdx1td3885Y3nYJMNrxXHDq4e1zk,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.dev25.dist-info/METADATA,sha256=JxYK9z-i-7Ra1KUPC5DsrHrMGzqoxatUBTHHkVZ3Ans,2582
186
+ modal-1.3.1.dev25.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
187
+ modal-1.3.1.dev25.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
188
+ modal-1.3.1.dev25.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
189
+ modal-1.3.1.dev25.dist-info/RECORD,,
modal_version/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # Copyright Modal Labs 2025
2
2
  """Supplies the current version of the modal client library."""
3
3
 
4
- __version__ = "1.3.1.dev24"
4
+ __version__ = "1.3.1.dev25"