modAL 1.2.3.dev15__tar.gz → 1.2.4__tar.gz

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.
Files changed (200) hide show
  1. {modal-1.2.3.dev15 → modal-1.2.4}/PKG-INFO +1 -1
  2. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_tunnel.py +11 -2
  3. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_tunnel.pyi +25 -3
  4. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/grpc_utils.py +20 -15
  5. {modal-1.2.3.dev15 → modal-1.2.4}/modal/client.pyi +2 -10
  6. {modal-1.2.3.dev15 → modal-1.2.4}/modal/config.py +1 -8
  7. {modal-1.2.3.dev15 → modal-1.2.4}/modal/experimental/flash.py +4 -2
  8. {modal-1.2.3.dev15 → modal-1.2.4}/modal/experimental/flash.pyi +4 -0
  9. {modal-1.2.3.dev15 → modal-1.2.4}/modal/sandbox.py +2 -1
  10. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/PKG-INFO +1 -1
  11. {modal-1.2.3.dev15 → modal-1.2.4}/modal_version/__init__.py +1 -1
  12. {modal-1.2.3.dev15 → modal-1.2.4}/LICENSE +0 -0
  13. {modal-1.2.3.dev15 → modal-1.2.4}/README.md +0 -0
  14. {modal-1.2.3.dev15 → modal-1.2.4}/modal/__init__.py +0 -0
  15. {modal-1.2.3.dev15 → modal-1.2.4}/modal/__main__.py +0 -0
  16. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_billing.py +0 -0
  17. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_clustered_functions.py +0 -0
  18. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_clustered_functions.pyi +0 -0
  19. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_container_entrypoint.py +0 -0
  20. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_functions.py +0 -0
  21. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_grpc_client.py +0 -0
  22. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_ipython.py +0 -0
  23. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_load_context.py +0 -0
  24. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_location.py +0 -0
  25. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_object.py +0 -0
  26. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_output.py +0 -0
  27. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_partial_function.py +0 -0
  28. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_pty.py +0 -0
  29. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_resolver.py +0 -0
  30. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_resources.py +0 -0
  31. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/__init__.py +0 -0
  32. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/asgi.py +0 -0
  33. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/container_io_manager.py +0 -0
  34. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/container_io_manager.pyi +0 -0
  35. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/execution_context.py +0 -0
  36. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/execution_context.pyi +0 -0
  37. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/gpu_memory_snapshot.py +0 -0
  38. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/telemetry.py +0 -0
  39. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_runtime/user_code_imports.py +0 -0
  40. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_serialization.py +0 -0
  41. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_traceback.py +0 -0
  42. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_type_manager.py +0 -0
  43. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/__init__.py +0 -0
  44. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/app_utils.py +0 -0
  45. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/async_utils.py +0 -0
  46. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/auth_token_manager.py +0 -0
  47. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/blob_utils.py +0 -0
  48. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/bytes_io_segment_payload.py +0 -0
  49. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/deprecation.py +0 -0
  50. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/docker_utils.py +0 -0
  51. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/function_utils.py +0 -0
  52. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/git_utils.py +0 -0
  53. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/grpc_testing.py +0 -0
  54. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/hash_utils.py +0 -0
  55. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/http_utils.py +0 -0
  56. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/jwt_utils.py +0 -0
  57. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/logger.py +0 -0
  58. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/mount_utils.py +0 -0
  59. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/name_utils.py +0 -0
  60. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/package_utils.py +0 -0
  61. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/pattern_utils.py +0 -0
  62. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/rand_pb_testing.py +0 -0
  63. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/shell_utils.py +0 -0
  64. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/task_command_router_client.py +0 -0
  65. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_utils/time_utils.py +0 -0
  66. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_vendor/__init__.py +0 -0
  67. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_vendor/a2wsgi_wsgi.py +0 -0
  68. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_vendor/cloudpickle.py +0 -0
  69. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_vendor/tblib.py +0 -0
  70. {modal-1.2.3.dev15 → modal-1.2.4}/modal/_watcher.py +0 -0
  71. {modal-1.2.3.dev15 → modal-1.2.4}/modal/app.py +0 -0
  72. {modal-1.2.3.dev15 → modal-1.2.4}/modal/app.pyi +0 -0
  73. {modal-1.2.3.dev15 → modal-1.2.4}/modal/billing.py +0 -0
  74. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/2023.12.312.txt +0 -0
  75. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/2023.12.txt +0 -0
  76. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/2024.04.txt +0 -0
  77. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/2024.10.txt +0 -0
  78. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/2025.06.txt +0 -0
  79. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/PREVIEW.txt +0 -0
  80. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/README.md +0 -0
  81. {modal-1.2.3.dev15 → modal-1.2.4}/modal/builder/base-images.json +0 -0
  82. {modal-1.2.3.dev15 → modal-1.2.4}/modal/call_graph.py +0 -0
  83. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/__init__.py +0 -0
  84. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/_download.py +0 -0
  85. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/_traceback.py +0 -0
  86. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/app.py +0 -0
  87. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/cluster.py +0 -0
  88. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/config.py +0 -0
  89. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/container.py +0 -0
  90. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/dict.py +0 -0
  91. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/entry_point.py +0 -0
  92. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/environment.py +0 -0
  93. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/import_refs.py +0 -0
  94. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/launch.py +0 -0
  95. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/network_file_system.py +0 -0
  96. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/profile.py +0 -0
  97. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/programs/__init__.py +0 -0
  98. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/programs/launch_instance_ssh.py +0 -0
  99. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/programs/run_jupyter.py +0 -0
  100. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/programs/run_marimo.py +0 -0
  101. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/programs/vscode.py +0 -0
  102. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/queues.py +0 -0
  103. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/run.py +0 -0
  104. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/secret.py +0 -0
  105. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/token.py +0 -0
  106. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/utils.py +0 -0
  107. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cli/volume.py +0 -0
  108. {modal-1.2.3.dev15 → modal-1.2.4}/modal/client.py +0 -0
  109. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cloud_bucket_mount.py +0 -0
  110. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cloud_bucket_mount.pyi +0 -0
  111. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cls.py +0 -0
  112. {modal-1.2.3.dev15 → modal-1.2.4}/modal/cls.pyi +0 -0
  113. {modal-1.2.3.dev15 → modal-1.2.4}/modal/container_process.py +0 -0
  114. {modal-1.2.3.dev15 → modal-1.2.4}/modal/container_process.pyi +0 -0
  115. {modal-1.2.3.dev15 → modal-1.2.4}/modal/dict.py +0 -0
  116. {modal-1.2.3.dev15 → modal-1.2.4}/modal/dict.pyi +0 -0
  117. {modal-1.2.3.dev15 → modal-1.2.4}/modal/environments.py +0 -0
  118. {modal-1.2.3.dev15 → modal-1.2.4}/modal/environments.pyi +0 -0
  119. {modal-1.2.3.dev15 → modal-1.2.4}/modal/exception.py +0 -0
  120. {modal-1.2.3.dev15 → modal-1.2.4}/modal/experimental/__init__.py +0 -0
  121. {modal-1.2.3.dev15 → modal-1.2.4}/modal/experimental/ipython.py +0 -0
  122. {modal-1.2.3.dev15 → modal-1.2.4}/modal/file_io.py +0 -0
  123. {modal-1.2.3.dev15 → modal-1.2.4}/modal/file_io.pyi +0 -0
  124. {modal-1.2.3.dev15 → modal-1.2.4}/modal/file_pattern_matcher.py +0 -0
  125. {modal-1.2.3.dev15 → modal-1.2.4}/modal/functions.py +0 -0
  126. {modal-1.2.3.dev15 → modal-1.2.4}/modal/functions.pyi +0 -0
  127. {modal-1.2.3.dev15 → modal-1.2.4}/modal/gpu.py +0 -0
  128. {modal-1.2.3.dev15 → modal-1.2.4}/modal/image.py +0 -0
  129. {modal-1.2.3.dev15 → modal-1.2.4}/modal/image.pyi +0 -0
  130. {modal-1.2.3.dev15 → modal-1.2.4}/modal/io_streams.py +0 -0
  131. {modal-1.2.3.dev15 → modal-1.2.4}/modal/io_streams.pyi +0 -0
  132. {modal-1.2.3.dev15 → modal-1.2.4}/modal/mount.py +0 -0
  133. {modal-1.2.3.dev15 → modal-1.2.4}/modal/mount.pyi +0 -0
  134. {modal-1.2.3.dev15 → modal-1.2.4}/modal/network_file_system.py +0 -0
  135. {modal-1.2.3.dev15 → modal-1.2.4}/modal/network_file_system.pyi +0 -0
  136. {modal-1.2.3.dev15 → modal-1.2.4}/modal/object.py +0 -0
  137. {modal-1.2.3.dev15 → modal-1.2.4}/modal/object.pyi +0 -0
  138. {modal-1.2.3.dev15 → modal-1.2.4}/modal/output.py +0 -0
  139. {modal-1.2.3.dev15 → modal-1.2.4}/modal/parallel_map.py +0 -0
  140. {modal-1.2.3.dev15 → modal-1.2.4}/modal/parallel_map.pyi +0 -0
  141. {modal-1.2.3.dev15 → modal-1.2.4}/modal/partial_function.py +0 -0
  142. {modal-1.2.3.dev15 → modal-1.2.4}/modal/partial_function.pyi +0 -0
  143. {modal-1.2.3.dev15 → modal-1.2.4}/modal/proxy.py +0 -0
  144. {modal-1.2.3.dev15 → modal-1.2.4}/modal/proxy.pyi +0 -0
  145. {modal-1.2.3.dev15 → modal-1.2.4}/modal/py.typed +0 -0
  146. {modal-1.2.3.dev15 → modal-1.2.4}/modal/queue.py +0 -0
  147. {modal-1.2.3.dev15 → modal-1.2.4}/modal/queue.pyi +0 -0
  148. {modal-1.2.3.dev15 → modal-1.2.4}/modal/retries.py +0 -0
  149. {modal-1.2.3.dev15 → modal-1.2.4}/modal/runner.py +0 -0
  150. {modal-1.2.3.dev15 → modal-1.2.4}/modal/runner.pyi +0 -0
  151. {modal-1.2.3.dev15 → modal-1.2.4}/modal/running_app.py +0 -0
  152. {modal-1.2.3.dev15 → modal-1.2.4}/modal/sandbox.pyi +0 -0
  153. {modal-1.2.3.dev15 → modal-1.2.4}/modal/schedule.py +0 -0
  154. {modal-1.2.3.dev15 → modal-1.2.4}/modal/scheduler_placement.py +0 -0
  155. {modal-1.2.3.dev15 → modal-1.2.4}/modal/secret.py +0 -0
  156. {modal-1.2.3.dev15 → modal-1.2.4}/modal/secret.pyi +0 -0
  157. {modal-1.2.3.dev15 → modal-1.2.4}/modal/serving.py +0 -0
  158. {modal-1.2.3.dev15 → modal-1.2.4}/modal/serving.pyi +0 -0
  159. {modal-1.2.3.dev15 → modal-1.2.4}/modal/snapshot.py +0 -0
  160. {modal-1.2.3.dev15 → modal-1.2.4}/modal/snapshot.pyi +0 -0
  161. {modal-1.2.3.dev15 → modal-1.2.4}/modal/stream_type.py +0 -0
  162. {modal-1.2.3.dev15 → modal-1.2.4}/modal/token_flow.py +0 -0
  163. {modal-1.2.3.dev15 → modal-1.2.4}/modal/token_flow.pyi +0 -0
  164. {modal-1.2.3.dev15 → modal-1.2.4}/modal/volume.py +0 -0
  165. {modal-1.2.3.dev15 → modal-1.2.4}/modal/volume.pyi +0 -0
  166. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/SOURCES.txt +0 -0
  167. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/dependency_links.txt +0 -0
  168. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/entry_points.txt +0 -0
  169. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/requires.txt +0 -0
  170. {modal-1.2.3.dev15 → modal-1.2.4}/modal.egg-info/top_level.txt +0 -0
  171. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/__init__.py +0 -0
  172. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/gen_cli_docs.py +0 -0
  173. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/gen_reference_docs.py +0 -0
  174. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/mdmd/__init__.py +0 -0
  175. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/mdmd/mdmd.py +0 -0
  176. {modal-1.2.3.dev15 → modal-1.2.4}/modal_docs/mdmd/signatures.py +0 -0
  177. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/__init__.py +0 -0
  178. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api.proto +0 -0
  179. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api_grpc.py +0 -0
  180. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api_pb2.py +0 -0
  181. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api_pb2.pyi +0 -0
  182. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api_pb2_grpc.py +0 -0
  183. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/api_pb2_grpc.pyi +0 -0
  184. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/modal_api_grpc.py +0 -0
  185. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/py.typed +0 -0
  186. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router.proto +0 -0
  187. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router_grpc.py +0 -0
  188. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router_pb2.py +0 -0
  189. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router_pb2.pyi +0 -0
  190. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router_pb2_grpc.py +0 -0
  191. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/sandbox_router_pb2_grpc.pyi +0 -0
  192. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router.proto +0 -0
  193. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router_grpc.py +0 -0
  194. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router_pb2.py +0 -0
  195. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router_pb2.pyi +0 -0
  196. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router_pb2_grpc.py +0 -0
  197. {modal-1.2.3.dev15 → modal-1.2.4}/modal_proto/task_command_router_pb2_grpc.pyi +0 -0
  198. {modal-1.2.3.dev15 → modal-1.2.4}/modal_version/__main__.py +0 -0
  199. {modal-1.2.3.dev15 → modal-1.2.4}/pyproject.toml +0 -0
  200. {modal-1.2.3.dev15 → modal-1.2.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.2.3.dev15
3
+ Version: 1.2.4
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -51,13 +51,17 @@ class Tunnel:
51
51
 
52
52
 
53
53
  @asynccontextmanager
54
- async def _forward(port: int, *, unencrypted: bool = False, client: Optional[_Client] = None) -> AsyncIterator[Tunnel]:
54
+ async def _forward(
55
+ port: int, *, unencrypted: bool = False, h2_enabled: bool = False, client: Optional[_Client] = None
56
+ ) -> AsyncIterator[Tunnel]:
55
57
  """Expose a port publicly from inside a running Modal container, with TLS.
56
58
 
57
59
  If `unencrypted` is set, this also exposes the TCP socket without encryption on a random port
58
60
  number. This can be used to SSH into a container (see example below). Note that it is on the public Internet, so
59
61
  make sure you are using a secure protocol over TCP.
60
62
 
63
+ If `h2_enabled` is set, the TLS server will advertise support for HTTP/2.
64
+
61
65
  **Important:** This is an experimental API which may change in the future.
62
66
 
63
67
  **Usage:**
@@ -168,6 +172,8 @@ async def _forward(port: int, *, unencrypted: bool = False, client: Optional[_Cl
168
172
  raise InvalidError(f"The port argument should be an int, not {port!r}")
169
173
  if port < 1 or port > 65535:
170
174
  raise InvalidError(f"Invalid port number {port}")
175
+ if h2_enabled and unencrypted:
176
+ raise InvalidError("H2 can only be used with encrypted ports")
171
177
 
172
178
  if not client:
173
179
  client = await _Client.from_env()
@@ -175,8 +181,11 @@ async def _forward(port: int, *, unencrypted: bool = False, client: Optional[_Cl
175
181
  if client.client_type != api_pb2.CLIENT_TYPE_CONTAINER:
176
182
  raise InvalidError("Forwarding ports only works inside a Modal container")
177
183
 
184
+ tunnel_type = api_pb2.TUNNEL_TYPE_H2 if h2_enabled else api_pb2.TUNNEL_TYPE_UNSPECIFIED
178
185
  try:
179
- response = await client.stub.TunnelStart(api_pb2.TunnelStartRequest(port=port, unencrypted=unencrypted))
186
+ response = await client.stub.TunnelStart(
187
+ api_pb2.TunnelStartRequest(port=port, unencrypted=unencrypted, tunnel_type=tunnel_type)
188
+ )
180
189
  except GRPCError as exc:
181
190
  if exc.status == Status.ALREADY_EXISTS:
182
191
  raise InvalidError(f"Port {port} is already forwarded")
@@ -54,7 +54,11 @@ class Tunnel:
54
54
  ...
55
55
 
56
56
  def _forward(
57
- port: int, *, unencrypted: bool = False, client: typing.Optional[modal.client._Client] = None
57
+ port: int,
58
+ *,
59
+ unencrypted: bool = False,
60
+ h2_enabled: bool = False,
61
+ client: typing.Optional[modal.client._Client] = None,
58
62
  ) -> typing.AsyncContextManager[Tunnel]:
59
63
  '''Expose a port publicly from inside a running Modal container, with TLS.
60
64
 
@@ -62,6 +66,8 @@ def _forward(
62
66
  number. This can be used to SSH into a container (see example below). Note that it is on the public Internet, so
63
67
  make sure you are using a secure protocol over TCP.
64
68
 
69
+ If `h2_enabled` is set, the TLS server will advertise support for HTTP/2.
70
+
65
71
  **Important:** This is an experimental API which may change in the future.
66
72
 
67
73
  **Usage:**
@@ -171,7 +177,13 @@ def _forward(
171
177
 
172
178
  class __forward_spec(typing_extensions.Protocol):
173
179
  def __call__(
174
- self, /, port: int, *, unencrypted: bool = False, client: typing.Optional[modal.client.Client] = None
180
+ self,
181
+ /,
182
+ port: int,
183
+ *,
184
+ unencrypted: bool = False,
185
+ h2_enabled: bool = False,
186
+ client: typing.Optional[modal.client.Client] = None,
175
187
  ) -> synchronicity.combined_types.AsyncAndBlockingContextManager[Tunnel]:
176
188
  '''Expose a port publicly from inside a running Modal container, with TLS.
177
189
 
@@ -179,6 +191,8 @@ class __forward_spec(typing_extensions.Protocol):
179
191
  number. This can be used to SSH into a container (see example below). Note that it is on the public Internet, so
180
192
  make sure you are using a secure protocol over TCP.
181
193
 
194
+ If `h2_enabled` is set, the TLS server will advertise support for HTTP/2.
195
+
182
196
  **Important:** This is an experimental API which may change in the future.
183
197
 
184
198
  **Usage:**
@@ -287,7 +301,13 @@ class __forward_spec(typing_extensions.Protocol):
287
301
  ...
288
302
 
289
303
  def aio(
290
- self, /, port: int, *, unencrypted: bool = False, client: typing.Optional[modal.client.Client] = None
304
+ self,
305
+ /,
306
+ port: int,
307
+ *,
308
+ unencrypted: bool = False,
309
+ h2_enabled: bool = False,
310
+ client: typing.Optional[modal.client.Client] = None,
291
311
  ) -> typing.AsyncContextManager[Tunnel]:
292
312
  '''Expose a port publicly from inside a running Modal container, with TLS.
293
313
 
@@ -295,6 +315,8 @@ class __forward_spec(typing_extensions.Protocol):
295
315
  number. This can be used to SSH into a container (see example below). Note that it is on the public Internet, so
296
316
  make sure you are using a secure protocol over TCP.
297
317
 
318
+ If `h2_enabled` is set, the TLS server will advertise support for HTTP/2.
319
+
298
320
  **Important:** This is an experimental API which may change in the future.
299
321
 
300
322
  **Usage:**
@@ -271,15 +271,13 @@ def process_exception_before_retry(
271
271
  fn_name: str,
272
272
  n_retries: int,
273
273
  delay: float,
274
- total_deadline: Optional[float],
275
274
  idempotency_key: str,
276
275
  ):
277
276
  """Process exception before retry, used by `_retry_transient_errors`."""
278
277
  with suppress_tb_frames(1):
279
278
  if final_attempt:
280
279
  logger.debug(
281
- f"Final attempt failed with {repr(exc)} {n_retries=} {delay=} "
282
- f"{total_deadline=} for {fn_name} ({idempotency_key[:8]})"
280
+ f"Final attempt failed with {repr(exc)} {n_retries=} {delay=} for {fn_name} ({idempotency_key[:8]})"
283
281
  )
284
282
  if isinstance(exc, OSError):
285
283
  raise ConnectionError(str(exc))
@@ -358,6 +356,7 @@ async def _retry_transient_errors(
358
356
  timeout = min(timeouts) # In case the function provided both types of timeouts
359
357
  else:
360
358
  timeout = None
359
+
361
360
  try:
362
361
  with suppress_tb_frames(1):
363
362
  return await fn_callable(req, metadata=attempt_metadata, timeout=timeout)
@@ -366,21 +365,29 @@ async def _retry_transient_errors(
366
365
  # in grpclib<=0.4.7. See above (search for `write_appdata`).
367
366
 
368
367
  # Server side instruction for retries
369
- if isinstance(exc, GRPCError) and (server_retry_policy := get_server_retry_policy(exc)):
368
+ max_throttle_wait: Optional[int] = config.get("max_throttle_wait")
369
+ if (
370
+ max_throttle_wait != 0
371
+ and isinstance(exc, GRPCError)
372
+ and (server_retry_policy := get_server_retry_policy(exc))
373
+ ):
370
374
  server_delay = server_retry_policy.retry_after_secs
371
375
 
372
- # When `total_deadline` is not defined and server gives instruction for retries, then use
373
- # `max_throttle_wait`.
374
- if total_deadline is None and (max_throttle_wait := config.get("max_throttle_wait")):
375
- total_deadline = t0 + max_throttle_wait
376
+ now = time.time()
376
377
 
377
- final_attempt = (
378
- total_deadline is not None
379
- and time.time() + server_delay + retry.attempt_timeout_floor >= total_deadline
378
+ # We check if the timeout will be reached **after** the sleep, so we can raise an error early
379
+ # without needing to actually sleep.
380
+ total_timeout_will_be_reached = (
381
+ retry.total_timeout is not None and (now + server_delay - t0) >= retry.total_timeout
382
+ )
383
+ max_throttle_will_be_reached = (
384
+ max_throttle_wait is not None and (now + server_delay - t0) >= max_throttle_wait
380
385
  )
386
+ final_attempt = total_timeout_will_be_reached or max_throttle_will_be_reached
387
+
381
388
  with suppress_tb_frames(1):
382
389
  process_exception_before_retry(
383
- exc, final_attempt, fn.name, n_retries, server_delay, total_deadline, idempotency_key
390
+ exc, final_attempt, fn.name, n_retries, server_delay, idempotency_key
384
391
  )
385
392
 
386
393
  now = time.time()
@@ -411,9 +418,7 @@ async def _retry_transient_errors(
411
418
  final_attempt = False
412
419
 
413
420
  with suppress_tb_frames(1):
414
- process_exception_before_retry(
415
- exc, final_attempt, fn.name, n_retries, delay, total_deadline, idempotency_key
416
- )
421
+ process_exception_before_retry(exc, final_attempt, fn.name, n_retries, delay, idempotency_key)
417
422
 
418
423
  n_retries += 1
419
424
 
@@ -28,11 +28,7 @@ class _Client:
28
28
  _snapshotted: bool
29
29
 
30
30
  def __init__(
31
- self,
32
- server_url: str,
33
- client_type: int,
34
- credentials: typing.Optional[tuple[str, str]],
35
- version: str = "1.2.3.dev15",
31
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "1.2.4"
36
32
  ):
37
33
  """mdmd:hidden
38
34
  The Modal client object is not intended to be instantiated directly by users.
@@ -159,11 +155,7 @@ class Client:
159
155
  _snapshotted: bool
160
156
 
161
157
  def __init__(
162
- self,
163
- server_url: str,
164
- client_type: int,
165
- credentials: typing.Optional[tuple[str, str]],
166
- version: str = "1.2.3.dev15",
158
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "1.2.4"
167
159
  ):
168
160
  """mdmd:hidden
169
161
  The Modal client object is not intended to be instantiated directly by users.
@@ -221,13 +221,6 @@ def _enforce_suffix_rules(x: str) -> str:
221
221
  return x
222
222
 
223
223
 
224
- def _int_or_none(x: str) -> Optional[int]:
225
- if not x:
226
- return None
227
- x_int = int(x)
228
- return x_int if x_int > 0 else None
229
-
230
-
231
224
  class _Setting(typing.NamedTuple):
232
225
  default: typing.Any = None
233
226
  transform: typing.Callable[[str], typing.Any] = lambda x: x # noqa: E731
@@ -269,7 +262,7 @@ _SETTINGS = {
269
262
  transform=lambda s: _check_value(["pickle", "cbor"])(s.lower()),
270
263
  ),
271
264
  "dev_suffix": _Setting("", transform=_enforce_suffix_rules),
272
- "max_throttle_wait": _Setting(None, transform=_int_or_none),
265
+ "max_throttle_wait": _Setting(None, transform=lambda x: int(x) if x else None),
273
266
  }
274
267
 
275
268
 
@@ -30,13 +30,14 @@ class _FlashManager:
30
30
  port: int,
31
31
  process: Optional[subprocess.Popen] = None,
32
32
  health_check_url: Optional[str] = None,
33
+ h2_enabled: bool = False,
33
34
  ):
34
35
  self.client = client
35
36
  self.port = port
36
37
  # Health check is not currently being used
37
38
  self.health_check_url = health_check_url
38
39
  self.process = process
39
- self.tunnel_manager = _forward_tunnel(port, client=client)
40
+ self.tunnel_manager = _forward_tunnel(port, h2_enabled=h2_enabled, client=client)
40
41
  self.stopped = False
41
42
  self.num_failures = 0
42
43
  self.task_id = os.environ["MODAL_TASK_ID"]
@@ -170,6 +171,7 @@ async def flash_forward(
170
171
  port: int,
171
172
  process: Optional[subprocess.Popen] = None,
172
173
  health_check_url: Optional[str] = None,
174
+ h2_enabled: bool = False,
173
175
  ) -> _FlashManager:
174
176
  """
175
177
  Forward a port to the Modal Flash service, exposing that port as a stable web endpoint.
@@ -178,7 +180,7 @@ async def flash_forward(
178
180
  """
179
181
  client = await _Client.from_env()
180
182
 
181
- manager = _FlashManager(client, port, process=process, health_check_url=health_check_url)
183
+ manager = _FlashManager(client, port, process=process, health_check_url=health_check_url, h2_enabled=h2_enabled)
182
184
  await manager._start()
183
185
  return manager
184
186
 
@@ -10,6 +10,7 @@ class _FlashManager:
10
10
  port: int,
11
11
  process: typing.Optional[subprocess.Popen] = None,
12
12
  health_check_url: typing.Optional[str] = None,
13
+ h2_enabled: bool = False,
13
14
  ):
14
15
  """Initialize self. See help(type(self)) for accurate signature."""
15
16
  ...
@@ -36,6 +37,7 @@ class FlashManager:
36
37
  port: int,
37
38
  process: typing.Optional[subprocess.Popen] = None,
38
39
  health_check_url: typing.Optional[str] = None,
40
+ h2_enabled: bool = False,
39
41
  ): ...
40
42
 
41
43
  class __is_port_connection_healthy_spec(typing_extensions.Protocol[SUPERSELF]):
@@ -92,6 +94,7 @@ class __flash_forward_spec(typing_extensions.Protocol):
92
94
  port: int,
93
95
  process: typing.Optional[subprocess.Popen] = None,
94
96
  health_check_url: typing.Optional[str] = None,
97
+ h2_enabled: bool = False,
95
98
  ) -> FlashManager:
96
99
  """Forward a port to the Modal Flash service, exposing that port as a stable web endpoint.
97
100
  This is a highly experimental method that can break or be removed at any time without warning.
@@ -105,6 +108,7 @@ class __flash_forward_spec(typing_extensions.Protocol):
105
108
  port: int,
106
109
  process: typing.Optional[subprocess.Popen] = None,
107
110
  health_check_url: typing.Optional[str] = None,
111
+ h2_enabled: bool = False,
108
112
  ) -> FlashManager:
109
113
  """Forward a port to the Modal Flash service, exposing that port as a stable web endpoint.
110
114
  This is a highly experimental method that can break or be removed at any time without warning.
@@ -938,7 +938,8 @@ class _Sandbox(_Object, type_prefix="sb"):
938
938
  elif stderr == StreamType.DEVNULL:
939
939
  stderr_config = sr_pb2.TaskExecStderrConfig.TASK_EXEC_STDERR_CONFIG_DEVNULL
940
940
  elif stderr == StreamType.STDOUT:
941
- stderr_config = sr_pb2.TaskExecStderrConfig.TASK_EXEC_STDERR_CONFIG_STDOUT
941
+ # Stream stderr to the client so that it can be printed locally in the reader.
942
+ stderr_config = sr_pb2.TaskExecStderrConfig.TASK_EXEC_STDERR_CONFIG_PIPE
942
943
  else:
943
944
  raise ValueError("Unsupported StreamType for stderr")
944
945
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.2.3.dev15
3
+ Version: 1.2.4
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -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.2.3.dev15"
4
+ __version__ = "1.2.4"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes