modal 1.1.5.dev15__py3-none-any.whl → 1.1.5.dev16__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/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.1.5.dev15",
36
+ version: str = "1.1.5.dev16",
37
37
  ):
38
38
  """mdmd:hidden
39
39
  The Modal client object is not intended to be instantiated directly by users.
@@ -164,7 +164,7 @@ class Client:
164
164
  server_url: str,
165
165
  client_type: int,
166
166
  credentials: typing.Optional[tuple[str, str]],
167
- version: str = "1.1.5.dev15",
167
+ version: str = "1.1.5.dev16",
168
168
  ):
169
169
  """mdmd:hidden
170
170
  The Modal client object is not intended to be instantiated directly by users.
modal/sandbox.py CHANGED
@@ -1,9 +1,11 @@
1
1
  # Copyright Modal Labs 2022
2
2
  import asyncio
3
+ import json
3
4
  import os
4
5
  import time
5
6
  from collections.abc import AsyncGenerator, Sequence
6
- from typing import TYPE_CHECKING, AsyncIterator, Literal, Optional, Union, overload
7
+ from dataclasses import dataclass
8
+ from typing import TYPE_CHECKING, Any, AsyncIterator, Literal, Optional, Union, overload
7
9
 
8
10
  from .config import config, logger
9
11
 
@@ -99,6 +101,14 @@ class DefaultSandboxNameOverride(str):
99
101
  _DEFAULT_SANDBOX_NAME_OVERRIDE = DefaultSandboxNameOverride()
100
102
 
101
103
 
104
+ @dataclass(frozen=True)
105
+ class SandboxConnectCredentials:
106
+ """Simple data structure storing credentials for making HTTP connections to a sandbox."""
107
+
108
+ url: str
109
+ token: str
110
+
111
+
102
112
  class _Sandbox(_Object, type_prefix="sb"):
103
113
  """A `Sandbox` object lets you interact with a running sandbox. This API is similar to Python's
104
114
  [asyncio.subprocess.Process](https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.subprocess.Process).
@@ -626,6 +636,23 @@ class _Sandbox(_Object, type_prefix="sb"):
626
636
 
627
637
  return self._tunnels
628
638
 
639
+ async def create_connect_token(
640
+ self, metadata: Optional[Union[str, dict[str, Any]]] = None
641
+ ) -> SandboxConnectCredentials:
642
+ """Create a token for making HTTP connections to the sandbox.
643
+
644
+ Also accepts an optional metadata string or dict to associate with the token. This metadata
645
+ will be added to the headers by the proxy when forwarding requests to the sandbox."""
646
+ if metadata is not None and isinstance(metadata, dict):
647
+ try:
648
+ metadata = json.dumps(metadata)
649
+ except Exception as e:
650
+ raise InvalidError(f"Failed to serialize metadata: {e}")
651
+
652
+ req = api_pb2.SandboxCreateConnectTokenRequest(sandbox_id=self.object_id, metadata=metadata)
653
+ resp = await retry_transient_errors(self._client.stub.SandboxCreateConnectToken, req)
654
+ return SandboxConnectCredentials(resp.url, resp.token)
655
+
629
656
  async def reload_volumes(self) -> None:
630
657
  """Reload all Volumes mounted in the Sandbox.
631
658
 
modal/sandbox.pyi CHANGED
@@ -39,6 +39,36 @@ class DefaultSandboxNameOverride(str):
39
39
 
40
40
  _DEFAULT_SANDBOX_NAME_OVERRIDE: DefaultSandboxNameOverride
41
41
 
42
+ class SandboxConnectCredentials:
43
+ """Simple data structure storing credentials for making HTTP connections to a sandbox."""
44
+
45
+ url: str
46
+ token: str
47
+
48
+ def __init__(self, url: str, token: str) -> None:
49
+ """Initialize self. See help(type(self)) for accurate signature."""
50
+ ...
51
+
52
+ def __repr__(self):
53
+ """Return repr(self)."""
54
+ ...
55
+
56
+ def __eq__(self, other):
57
+ """Return self==value."""
58
+ ...
59
+
60
+ def __setattr__(self, name, value):
61
+ """Implement setattr(self, name, value)."""
62
+ ...
63
+
64
+ def __delattr__(self, name):
65
+ """Implement delattr(self, name)."""
66
+ ...
67
+
68
+ def __hash__(self):
69
+ """Return hash(self)."""
70
+ ...
71
+
42
72
  class _Sandbox(modal._object._Object):
43
73
  """A `Sandbox` object lets you interact with a running sandbox. This API is similar to Python's
44
74
  [asyncio.subprocess.Process](https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.subprocess.Process).
@@ -224,6 +254,16 @@ class _Sandbox(modal._object._Object):
224
254
  """
225
255
  ...
226
256
 
257
+ async def create_connect_token(
258
+ self, metadata: typing.Union[str, dict[str, typing.Any], None] = None
259
+ ) -> SandboxConnectCredentials:
260
+ """Create a token for making HTTP connections to the sandbox.
261
+
262
+ Also accepts an optional metadata string or dict to associate with the token. This metadata
263
+ will be added to the headers by the proxy when forwarding requests to the sandbox.
264
+ """
265
+ ...
266
+
227
267
  async def reload_volumes(self) -> None:
228
268
  """Reload all Volumes mounted in the Sandbox.
229
269
 
@@ -708,6 +748,29 @@ class Sandbox(modal.object.Object):
708
748
 
709
749
  tunnels: __tunnels_spec[typing_extensions.Self]
710
750
 
751
+ class __create_connect_token_spec(typing_extensions.Protocol[SUPERSELF]):
752
+ def __call__(
753
+ self, /, metadata: typing.Union[str, dict[str, typing.Any], None] = None
754
+ ) -> SandboxConnectCredentials:
755
+ """Create a token for making HTTP connections to the sandbox.
756
+
757
+ Also accepts an optional metadata string or dict to associate with the token. This metadata
758
+ will be added to the headers by the proxy when forwarding requests to the sandbox.
759
+ """
760
+ ...
761
+
762
+ async def aio(
763
+ self, /, metadata: typing.Union[str, dict[str, typing.Any], None] = None
764
+ ) -> SandboxConnectCredentials:
765
+ """Create a token for making HTTP connections to the sandbox.
766
+
767
+ Also accepts an optional metadata string or dict to associate with the token. This metadata
768
+ will be added to the headers by the proxy when forwarding requests to the sandbox.
769
+ """
770
+ ...
771
+
772
+ create_connect_token: __create_connect_token_spec[typing_extensions.Self]
773
+
711
774
  class __reload_volumes_spec(typing_extensions.Protocol[SUPERSELF]):
712
775
  def __call__(self, /) -> None:
713
776
  """Reload all Volumes mounted in the Sandbox.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.1.5.dev15
3
+ Version: 1.1.5.dev16
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -22,7 +22,7 @@ modal/app.py,sha256=F4baVULljFq0CwC_7U-EKNRNx7CYeWBKudjjYUuWc4U,48416
22
22
  modal/app.pyi,sha256=AbXJCBkyt2rI_-M3VbTBYb32at0P6iRZuoC87xY_JrQ,43591
23
23
  modal/call_graph.py,sha256=1g2DGcMIJvRy-xKicuf63IVE98gJSnQsr8R_NVMptNc,2581
24
24
  modal/client.py,sha256=kyAIVB3Ay-XKJizQ_1ufUFB__EagV0MLmHJpyYyJ7J0,18636
25
- modal/client.pyi,sha256=EVR-5DQpNrl9KdLOS3BUBdjXBViBgiUWzVfOAsSyZpY,15831
25
+ modal/client.pyi,sha256=ZTlMHTB-1zrkMR8-8C24M6SNrlKzbhQJ5k5nDwiIwhw,15831
26
26
  modal/cloud_bucket_mount.py,sha256=YOe9nnvSr4ZbeCn587d7_VhE9IioZYRvF9VYQTQux08,5914
27
27
  modal/cloud_bucket_mount.pyi,sha256=-qSfYAQvIoO_l2wsCCGTG5ZUwQieNKXdAO00yP1-LYU,7394
28
28
  modal/cls.py,sha256=pTEO7pHjlO7taMbIqs4oI9ZZgKDJpVKyGkO5ZT0w6tQ,40934
@@ -65,8 +65,8 @@ modal/retries.py,sha256=IvNLDM0f_GLUDD5VgEDoN09C88yoxSrCquinAuxT1Sc,5205
65
65
  modal/runner.py,sha256=ostdzYpQb-20tlD6dIq7bpWTkZkOhjJBNuMNektqnJA,24068
66
66
  modal/runner.pyi,sha256=lbwLljm1cC8d6PcNvmYQhkE8501V9fg0bYqqKX6G4r4,8489
67
67
  modal/running_app.py,sha256=v61mapYNV1-O-Uaho5EfJlryMLvIT9We0amUOSvSGx8,1188
68
- modal/sandbox.py,sha256=BDjFvr_rp67W5WGoGvV47uBPVsmp3yceoCqqHAGLFwg,42384
69
- modal/sandbox.pyi,sha256=mOyungHDDmUrg7jLmJpWuoUEbA4z6TUaVx291hndPmI,42049
68
+ modal/sandbox.py,sha256=GYSF--CsWnm-uta5xEnhilMRhx4burLFJ2VsAJCl9l0,43519
69
+ modal/sandbox.pyi,sha256=eu7ZcHRlrXAC54v0Q1pq3E--w0L9iHSLLW6gQsVS_Q0,44265
70
70
  modal/schedule.py,sha256=ng0g0AqNY5GQI9KhkXZQ5Wam5G42glbkqVQsNpBtbDE,3078
71
71
  modal/scheduler_placement.py,sha256=BAREdOY5HzHpzSBqt6jDVR6YC_jYfHMVqOzkyqQfngU,1235
72
72
  modal/secret.py,sha256=jcNJKc4ZB2nvAn7HJFawInqE-_7sbB43IWLZwyLBQ28,19308
@@ -153,7 +153,7 @@ modal/experimental/__init__.py,sha256=fCqzo_f3vcY750vHtd7CtLs5dvdM_C0ZLLGb3zXuK9
153
153
  modal/experimental/flash.py,sha256=8HOHZ0XLSN8Znzsi6hGggS46CC6t_7IgGWyNoeSXS9o,28417
154
154
  modal/experimental/flash.pyi,sha256=R9VV0UDotiY9BRUjacB-xI4qhR3yBymAvEZFRFHztLs,15143
155
155
  modal/experimental/ipython.py,sha256=TrCfmol9LGsRZMeDoeMPx3Hv3BFqQhYnmD_iH0pqdhk,2904
156
- modal-1.1.5.dev15.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
156
+ modal-1.1.5.dev16.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
157
157
  modal_docs/__init__.py,sha256=svYKtV8HDwDCN86zbdWqyq5T8sMdGDj0PVlzc2tIxDM,28
158
158
  modal_docs/gen_cli_docs.py,sha256=c1yfBS_x--gL5bs0N4ihMwqwX8l3IBWSkBAKNNIi6bQ,3801
159
159
  modal_docs/gen_reference_docs.py,sha256=d_CQUGQ0rfw28u75I2mov9AlS773z9rG40-yq5o7g2U,6359
@@ -176,10 +176,10 @@ modal_proto/options_pb2.pyi,sha256=l7DBrbLO7q3Ir-XDkWsajm0d0TQqqrfuX54i4BMpdQg,1
176
176
  modal_proto/options_pb2_grpc.py,sha256=1oboBPFxaTEXt9Aw7EAj8gXHDCNMhZD2VXqocC9l_gk,159
177
177
  modal_proto/options_pb2_grpc.pyi,sha256=CImmhxHsYnF09iENPoe8S4J-n93jtgUYD2JPAc0yJSI,247
178
178
  modal_proto/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
179
- modal_version/__init__.py,sha256=BfhHTlzVGwOKmBrMyLPzpnjxvFq16xQIkznYuN4k5Dc,121
179
+ modal_version/__init__.py,sha256=cMKY8SDIJ0r3UzuMVrF4zlcfkTEjbjrpY7H7GBFCL8s,121
180
180
  modal_version/__main__.py,sha256=2FO0yYQQwDTh6udt1h-cBnGd1c4ZyHnHSI4BksxzVac,105
181
- modal-1.1.5.dev15.dist-info/METADATA,sha256=z6-yg2PdFZ3h2caVnZcdMoHj7Lr6M5QnZhoU_EToILE,2460
182
- modal-1.1.5.dev15.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
183
- modal-1.1.5.dev15.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
184
- modal-1.1.5.dev15.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
185
- modal-1.1.5.dev15.dist-info/RECORD,,
181
+ modal-1.1.5.dev16.dist-info/METADATA,sha256=sI81kjsY50naAuY5QWX7TNoUDHXlsRPSOzUjM8dOQ8k,2460
182
+ modal-1.1.5.dev16.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
183
+ modal-1.1.5.dev16.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
184
+ modal-1.1.5.dev16.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
185
+ modal-1.1.5.dev16.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.1.5.dev15"
4
+ __version__ = "1.1.5.dev16"