modal 1.2.1.dev11__tar.gz → 1.2.1.dev13__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.

Potentially problematic release.


This version of modal might be problematic. Click here for more details.

Files changed (198) hide show
  1. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/PKG-INFO +1 -1
  2. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/client.pyi +2 -2
  3. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/container_process.py +9 -1
  4. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/io_streams.py +414 -78
  5. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/io_streams.pyi +222 -95
  6. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/PKG-INFO +1 -1
  7. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_version/__init__.py +1 -1
  8. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/LICENSE +0 -0
  9. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/README.md +0 -0
  10. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/__init__.py +0 -0
  11. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/__main__.py +0 -0
  12. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_billing.py +0 -0
  13. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_clustered_functions.py +0 -0
  14. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_clustered_functions.pyi +0 -0
  15. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_container_entrypoint.py +0 -0
  16. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_functions.py +0 -0
  17. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_ipython.py +0 -0
  18. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_location.py +0 -0
  19. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_object.py +0 -0
  20. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_output.py +0 -0
  21. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_partial_function.py +0 -0
  22. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_pty.py +0 -0
  23. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_resolver.py +0 -0
  24. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_resources.py +0 -0
  25. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/__init__.py +0 -0
  26. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/asgi.py +0 -0
  27. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/container_io_manager.py +0 -0
  28. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/container_io_manager.pyi +0 -0
  29. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/execution_context.py +0 -0
  30. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/execution_context.pyi +0 -0
  31. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/gpu_memory_snapshot.py +0 -0
  32. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/telemetry.py +0 -0
  33. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_runtime/user_code_imports.py +0 -0
  34. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_serialization.py +0 -0
  35. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_traceback.py +0 -0
  36. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_tunnel.py +0 -0
  37. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_tunnel.pyi +0 -0
  38. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_type_manager.py +0 -0
  39. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/__init__.py +0 -0
  40. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/app_utils.py +0 -0
  41. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/async_utils.py +0 -0
  42. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/auth_token_manager.py +0 -0
  43. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/blob_utils.py +0 -0
  44. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/bytes_io_segment_payload.py +0 -0
  45. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/deprecation.py +0 -0
  46. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/docker_utils.py +0 -0
  47. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/function_utils.py +0 -0
  48. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/git_utils.py +0 -0
  49. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/grpc_testing.py +0 -0
  50. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/grpc_utils.py +0 -0
  51. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/hash_utils.py +0 -0
  52. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/http_utils.py +0 -0
  53. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/jwt_utils.py +0 -0
  54. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/logger.py +0 -0
  55. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/mount_utils.py +0 -0
  56. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/name_utils.py +0 -0
  57. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/package_utils.py +0 -0
  58. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/pattern_utils.py +0 -0
  59. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/rand_pb_testing.py +0 -0
  60. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/shell_utils.py +0 -0
  61. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/task_command_router_client.py +0 -0
  62. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_utils/time_utils.py +0 -0
  63. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_vendor/__init__.py +0 -0
  64. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_vendor/a2wsgi_wsgi.py +0 -0
  65. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_vendor/cloudpickle.py +0 -0
  66. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_vendor/tblib.py +0 -0
  67. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/_watcher.py +0 -0
  68. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/app.py +0 -0
  69. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/app.pyi +0 -0
  70. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/billing.py +0 -0
  71. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/2023.12.312.txt +0 -0
  72. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/2023.12.txt +0 -0
  73. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/2024.04.txt +0 -0
  74. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/2024.10.txt +0 -0
  75. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/2025.06.txt +0 -0
  76. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/PREVIEW.txt +0 -0
  77. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/README.md +0 -0
  78. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/builder/base-images.json +0 -0
  79. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/call_graph.py +0 -0
  80. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/__init__.py +0 -0
  81. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/_download.py +0 -0
  82. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/_traceback.py +0 -0
  83. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/app.py +0 -0
  84. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/cluster.py +0 -0
  85. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/config.py +0 -0
  86. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/container.py +0 -0
  87. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/dict.py +0 -0
  88. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/entry_point.py +0 -0
  89. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/environment.py +0 -0
  90. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/import_refs.py +0 -0
  91. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/launch.py +0 -0
  92. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/network_file_system.py +0 -0
  93. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/profile.py +0 -0
  94. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/programs/__init__.py +0 -0
  95. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/programs/launch_instance_ssh.py +0 -0
  96. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/programs/run_jupyter.py +0 -0
  97. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/programs/run_marimo.py +0 -0
  98. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/programs/vscode.py +0 -0
  99. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/queues.py +0 -0
  100. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/run.py +0 -0
  101. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/secret.py +0 -0
  102. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/token.py +0 -0
  103. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/utils.py +0 -0
  104. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cli/volume.py +0 -0
  105. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/client.py +0 -0
  106. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cloud_bucket_mount.py +0 -0
  107. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cloud_bucket_mount.pyi +0 -0
  108. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cls.py +0 -0
  109. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/cls.pyi +0 -0
  110. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/config.py +0 -0
  111. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/container_process.pyi +0 -0
  112. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/dict.py +0 -0
  113. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/dict.pyi +0 -0
  114. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/environments.py +0 -0
  115. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/environments.pyi +0 -0
  116. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/exception.py +0 -0
  117. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/experimental/__init__.py +0 -0
  118. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/experimental/flash.py +0 -0
  119. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/experimental/flash.pyi +0 -0
  120. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/experimental/ipython.py +0 -0
  121. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/file_io.py +0 -0
  122. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/file_io.pyi +0 -0
  123. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/file_pattern_matcher.py +0 -0
  124. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/functions.py +0 -0
  125. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/functions.pyi +0 -0
  126. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/gpu.py +0 -0
  127. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/image.py +0 -0
  128. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/image.pyi +0 -0
  129. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/mount.py +0 -0
  130. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/mount.pyi +0 -0
  131. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/network_file_system.py +0 -0
  132. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/network_file_system.pyi +0 -0
  133. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/object.py +0 -0
  134. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/object.pyi +0 -0
  135. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/output.py +0 -0
  136. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/parallel_map.py +0 -0
  137. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/parallel_map.pyi +0 -0
  138. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/partial_function.py +0 -0
  139. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/partial_function.pyi +0 -0
  140. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/proxy.py +0 -0
  141. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/proxy.pyi +0 -0
  142. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/py.typed +0 -0
  143. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/queue.py +0 -0
  144. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/queue.pyi +0 -0
  145. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/retries.py +0 -0
  146. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/runner.py +0 -0
  147. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/runner.pyi +0 -0
  148. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/running_app.py +0 -0
  149. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/sandbox.py +0 -0
  150. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/sandbox.pyi +0 -0
  151. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/schedule.py +0 -0
  152. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/scheduler_placement.py +0 -0
  153. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/secret.py +0 -0
  154. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/secret.pyi +0 -0
  155. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/serving.py +0 -0
  156. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/serving.pyi +0 -0
  157. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/snapshot.py +0 -0
  158. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/snapshot.pyi +0 -0
  159. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/stream_type.py +0 -0
  160. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/token_flow.py +0 -0
  161. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/token_flow.pyi +0 -0
  162. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/volume.py +0 -0
  163. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal/volume.pyi +0 -0
  164. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/SOURCES.txt +0 -0
  165. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/dependency_links.txt +0 -0
  166. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/entry_points.txt +0 -0
  167. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/requires.txt +0 -0
  168. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal.egg-info/top_level.txt +0 -0
  169. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/__init__.py +0 -0
  170. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/gen_cli_docs.py +0 -0
  171. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/gen_reference_docs.py +0 -0
  172. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/mdmd/__init__.py +0 -0
  173. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/mdmd/mdmd.py +0 -0
  174. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_docs/mdmd/signatures.py +0 -0
  175. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/__init__.py +0 -0
  176. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api.proto +0 -0
  177. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api_grpc.py +0 -0
  178. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api_pb2.py +0 -0
  179. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api_pb2.pyi +0 -0
  180. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api_pb2_grpc.py +0 -0
  181. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/api_pb2_grpc.pyi +0 -0
  182. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/modal_api_grpc.py +0 -0
  183. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/py.typed +0 -0
  184. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router.proto +0 -0
  185. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router_grpc.py +0 -0
  186. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router_pb2.py +0 -0
  187. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router_pb2.pyi +0 -0
  188. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router_pb2_grpc.py +0 -0
  189. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/sandbox_router_pb2_grpc.pyi +0 -0
  190. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router.proto +0 -0
  191. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router_grpc.py +0 -0
  192. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router_pb2.py +0 -0
  193. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router_pb2.pyi +0 -0
  194. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router_pb2_grpc.py +0 -0
  195. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_proto/task_command_router_pb2_grpc.pyi +0 -0
  196. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/modal_version/__main__.py +0 -0
  197. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/pyproject.toml +0 -0
  198. {modal-1.2.1.dev11 → modal-1.2.1.dev13}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.2.1.dev11
3
+ Version: 1.2.1.dev13
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -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.2.1.dev11",
36
+ version: str = "1.2.1.dev13",
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.2.1.dev11",
167
+ version: str = "1.2.1.dev13",
168
168
  ):
169
169
  """mdmd:hidden
170
170
  The Modal client object is not intended to be instantiated directly by users.
@@ -155,8 +155,16 @@ class _ContainerProcess(Generic[T]):
155
155
  on_connect = asyncio.Event()
156
156
 
157
157
  async def _write_to_fd_loop(stream: _StreamReader):
158
+ # This is required to make modal shell to an existing task work,
159
+ # since that uses ContainerExec RPCs directly, but this is hacky.
160
+ #
161
+ # TODO(saltzm): Once we use the new exec path for that use case, this code can all be removed.
162
+ from .io_streams import _StreamReaderThroughServer
163
+
164
+ assert isinstance(stream._impl, _StreamReaderThroughServer)
165
+ stream_impl = stream._impl
158
166
  # Don't skip empty messages so we can detect when the process has booted.
159
- async for chunk in stream._get_logs(skip_empty_messages=False):
167
+ async for chunk in stream_impl._get_logs(skip_empty_messages=False):
160
168
  if chunk is None:
161
169
  break
162
170
 
@@ -1,7 +1,9 @@
1
1
  # Copyright Modal Labs 2022
2
2
  import asyncio
3
+ import codecs
3
4
  import time
4
5
  from collections.abc import AsyncGenerator, AsyncIterator
6
+ from dataclasses import dataclass
5
7
  from typing import (
6
8
  TYPE_CHECKING,
7
9
  Generic,
@@ -15,11 +17,12 @@ from typing import (
15
17
  from grpclib import Status
16
18
  from grpclib.exceptions import GRPCError, StreamTerminatedError
17
19
 
18
- from modal.exception import ClientClosed, InvalidError
20
+ from modal.exception import ClientClosed, ExecTimeoutError, InvalidError
19
21
  from modal_proto import api_pb2
20
22
 
21
23
  from ._utils.async_utils import synchronize_api
22
24
  from ._utils.grpc_utils import RETRYABLE_GRPC_STATUS_CODES, retry_transient_errors
25
+ from ._utils.task_command_router_client import TaskCommandRouterClient
23
26
  from .client import _Client
24
27
  from .config import logger
25
28
  from .stream_type import StreamType
@@ -83,27 +86,8 @@ async def _container_process_logs_iterator(
83
86
  T = TypeVar("T", str, bytes)
84
87
 
85
88
 
86
- class _StreamReader(Generic[T]):
87
- """Retrieve logs from a stream (`stdout` or `stderr`).
88
-
89
- As an asynchronous iterable, the object supports the `for` and `async for`
90
- statements. Just loop over the object to read in chunks.
91
-
92
- **Usage**
93
-
94
- ```python fixture:running_app
95
- from modal import Sandbox
96
-
97
- sandbox = Sandbox.create(
98
- "bash",
99
- "-c",
100
- "for i in $(seq 1 10); do echo foo; sleep 0.1; done",
101
- app=running_app,
102
- )
103
- for message in sandbox.stdout:
104
- print(f"Message: {message}")
105
- ```
106
- """
89
+ class _StreamReaderThroughServer(Generic[T]):
90
+ """A StreamReader implementation that reads from the server."""
107
91
 
108
92
  _stream: Optional[AsyncGenerator[Optional[bytes], None]]
109
93
 
@@ -133,10 +117,6 @@ class _StreamReader(Generic[T]):
133
117
  if object_type == "sandbox" and not text:
134
118
  raise ValueError("Sandbox streams must have text mode enabled.")
135
119
 
136
- # line-buffering is only supported when text=True
137
- if by_line and not text:
138
- raise ValueError("line-buffering is only supported when text=True")
139
-
140
120
  self._text = text
141
121
  self._by_line = by_line
142
122
 
@@ -166,19 +146,7 @@ class _StreamReader(Generic[T]):
166
146
  return self._file_descriptor
167
147
 
168
148
  async def read(self) -> T:
169
- """Fetch the entire contents of the stream until EOF.
170
-
171
- **Usage**
172
-
173
- ```python fixture:running_app
174
- from modal import Sandbox
175
-
176
- sandbox = Sandbox.create("echo", "hello", app=running_app)
177
- sandbox.wait()
178
-
179
- print(sandbox.stdout.read())
180
- ```
181
- """
149
+ """Fetch the entire contents of the stream until EOF."""
182
150
  data_str = ""
183
151
  data_bytes = b""
184
152
  logger.debug(f"{self._object_id} StreamReader fd={self._file_descriptor} read starting")
@@ -330,11 +298,6 @@ class _StreamReader(Generic[T]):
330
298
  self._stream = self._get_logs()
331
299
  return self._stream
332
300
 
333
- def __aiter__(self) -> AsyncIterator[T]:
334
- """mdmd:hidden"""
335
- self._ensure_stream()
336
- return self
337
-
338
301
  async def __anext__(self) -> T:
339
302
  """mdmd:hidden"""
340
303
  stream = self._ensure_stream()
@@ -356,10 +319,293 @@ class _StreamReader(Generic[T]):
356
319
  await self._stream.aclose()
357
320
 
358
321
 
322
+ async def _decode_bytes_stream_to_str(stream: AsyncGenerator[bytes, None]) -> AsyncGenerator[str, None]:
323
+ """Incrementally decode a bytes async generator as UTF-8 without breaking on chunk boundaries.
324
+
325
+ This function uses a streaming UTF-8 decoder so that multi-byte characters split across
326
+ chunks are handled correctly instead of raising ``UnicodeDecodeError``.
327
+ """
328
+ decoder = codecs.getincrementaldecoder("utf-8")(errors="strict")
329
+ async for item in stream:
330
+ text = decoder.decode(item, final=False)
331
+ if text:
332
+ yield text
333
+ # Flush any buffered partial character at end-of-stream
334
+ tail = decoder.decode(b"", final=True)
335
+ if tail:
336
+ yield tail
337
+
338
+
339
+ async def _stream_by_line(stream: AsyncGenerator[bytes, None]) -> AsyncGenerator[bytes, None]:
340
+ """Yield complete lines only (ending with \n), buffering partial lines until complete."""
341
+ line_buffer = b""
342
+ async for message in stream:
343
+ assert isinstance(message, bytes)
344
+ line_buffer += message
345
+ while b"\n" in line_buffer:
346
+ line, line_buffer = line_buffer.split(b"\n", 1)
347
+ yield line + b"\n"
348
+
349
+ if line_buffer:
350
+ yield line_buffer
351
+
352
+
353
+ @dataclass
354
+ class _StreamReaderThroughCommandRouterParams:
355
+ file_descriptor: "api_pb2.FileDescriptor.ValueType"
356
+ task_id: str
357
+ object_id: str
358
+ command_router_client: TaskCommandRouterClient
359
+ deadline: Optional[float]
360
+
361
+
362
+ async def _stdio_stream_from_command_router(
363
+ params: _StreamReaderThroughCommandRouterParams,
364
+ ) -> AsyncGenerator[bytes, None]:
365
+ """Stream raw bytes from the router client."""
366
+ stream = params.command_router_client.exec_stdio_read(
367
+ params.task_id, params.object_id, params.file_descriptor, params.deadline
368
+ )
369
+ try:
370
+ async for item in stream:
371
+ if len(item.data) == 0:
372
+ # This is an error.
373
+ raise ValueError("Received empty message streaming stdio from sandbox.")
374
+
375
+ yield item.data
376
+ except ExecTimeoutError:
377
+ logger.debug(f"Deadline exceeded while streaming stdio for exec {params.object_id}")
378
+ # TODO(saltzm): This is a weird API, but customers currently may rely on it. We
379
+ # should probably raise this error rather than just ending the stream.
380
+ return
381
+
382
+
383
+ class _BytesStreamReaderThroughCommandRouter(Generic[T]):
384
+ """
385
+ StreamReader implementation that will read directly from the worker that
386
+ hosts the sandbox.
387
+
388
+ This implementation is used for non-text streams.
389
+ """
390
+
391
+ def __init__(
392
+ self,
393
+ params: _StreamReaderThroughCommandRouterParams,
394
+ ) -> None:
395
+ self._params = params
396
+ self._stream = None
397
+
398
+ @property
399
+ def file_descriptor(self) -> int:
400
+ return self._params.file_descriptor
401
+
402
+ async def read(self) -> T:
403
+ data_bytes = b""
404
+ async for part in self:
405
+ data_bytes += cast(bytes, part)
406
+ return cast(T, data_bytes)
407
+
408
+ def __aiter__(self) -> AsyncIterator[T]:
409
+ return self
410
+
411
+ async def __anext__(self) -> T:
412
+ if self._stream is None:
413
+ self._stream = _stdio_stream_from_command_router(self._params)
414
+ # This raises StopAsyncIteration if the stream is at EOF.
415
+ return cast(T, await self._stream.__anext__())
416
+
417
+ async def aclose(self):
418
+ if self._stream:
419
+ await self._stream.aclose()
420
+
421
+
422
+ class _TextStreamReaderThroughCommandRouter(Generic[T]):
423
+ """
424
+ StreamReader implementation that will read directly from the worker
425
+ that hosts the sandbox.
426
+
427
+ This implementation is used for text streams.
428
+ """
429
+
430
+ def __init__(
431
+ self,
432
+ params: _StreamReaderThroughCommandRouterParams,
433
+ by_line: bool,
434
+ ) -> None:
435
+ self._params = params
436
+ self._by_line = by_line
437
+ self._stream = None
438
+
439
+ @property
440
+ def file_descriptor(self) -> int:
441
+ return self._params.file_descriptor
442
+
443
+ async def read(self) -> T:
444
+ data_str = ""
445
+ async for part in self:
446
+ data_str += cast(str, part)
447
+ return cast(T, data_str)
448
+
449
+ def __aiter__(self) -> AsyncIterator[T]:
450
+ return self
451
+
452
+ async def __anext__(self) -> T:
453
+ if self._stream is None:
454
+ bytes_stream = _stdio_stream_from_command_router(self._params)
455
+ if self._by_line:
456
+ self._stream = _decode_bytes_stream_to_str(_stream_by_line(bytes_stream))
457
+ else:
458
+ self._stream = _decode_bytes_stream_to_str(bytes_stream)
459
+ # This raises StopAsyncIteration if the stream is at EOF.
460
+ return cast(T, await self._stream.__anext__())
461
+
462
+ async def aclose(self):
463
+ if self._stream:
464
+ await self._stream.aclose()
465
+
466
+
467
+ class _DevnullStreamReader(Generic[T]):
468
+ """StreamReader implementation for a stream configured with
469
+ StreamType.DEVNULL. Throws an error if read or any other method is
470
+ called.
471
+ """
472
+
473
+ def __init__(self, file_descriptor: "api_pb2.FileDescriptor.ValueType") -> None:
474
+ self._file_descriptor = file_descriptor
475
+
476
+ @property
477
+ def file_descriptor(self) -> int:
478
+ return self._file_descriptor
479
+
480
+ async def read(self) -> T:
481
+ raise ValueError("read is not supported for a stream configured with StreamType.DEVNULL")
482
+
483
+ def __aiter__(self) -> AsyncIterator[T]:
484
+ raise ValueError("__aiter__ is not supported for a stream configured with StreamType.DEVNULL")
485
+
486
+ async def __anext__(self) -> T:
487
+ raise ValueError("__anext__ is not supported for a stream configured with StreamType.DEVNULL")
488
+
489
+ async def aclose(self):
490
+ raise ValueError("aclose is not supported for a stream configured with StreamType.DEVNULL")
491
+
492
+
493
+ class _StreamReader(Generic[T]):
494
+ """Retrieve logs from a stream (`stdout` or `stderr`).
495
+
496
+ As an asynchronous iterable, the object supports the `for` and `async for`
497
+ statements. Just loop over the object to read in chunks.
498
+
499
+ **Usage**
500
+
501
+ ```python fixture:running_app
502
+ from modal import Sandbox
503
+
504
+ sandbox = Sandbox.create(
505
+ "bash",
506
+ "-c",
507
+ "for i in $(seq 1 10); do echo foo; sleep 0.1; done",
508
+ app=running_app,
509
+ )
510
+ for message in sandbox.stdout:
511
+ print(f"Message: {message}")
512
+ ```
513
+ """
514
+
515
+ def __init__(
516
+ self,
517
+ file_descriptor: "api_pb2.FileDescriptor.ValueType",
518
+ object_id: str,
519
+ object_type: Literal["sandbox", "container_process"],
520
+ client: _Client,
521
+ stream_type: StreamType = StreamType.PIPE,
522
+ text: bool = True,
523
+ by_line: bool = False,
524
+ deadline: Optional[float] = None,
525
+ command_router_client: Optional[TaskCommandRouterClient] = None,
526
+ task_id: Optional[str] = None,
527
+ ) -> None:
528
+ """mdmd:hidden"""
529
+ if by_line and not text:
530
+ raise ValueError("line-buffering is only supported when text=True")
531
+
532
+ if command_router_client is None:
533
+ self._impl = _StreamReaderThroughServer(
534
+ file_descriptor, object_id, object_type, client, stream_type, text, by_line, deadline
535
+ )
536
+ else:
537
+ # The only reason task_id is optional is because StreamReader is
538
+ # also used for sandbox logs, which don't have a task ID available
539
+ # when the StreamReader is created.
540
+ assert task_id is not None
541
+ assert object_type == "container_process"
542
+ if stream_type == StreamType.DEVNULL:
543
+ self._impl = _DevnullStreamReader(file_descriptor)
544
+ else:
545
+ assert stream_type == StreamType.PIPE or stream_type == StreamType.STDOUT
546
+ # TODO(saltzm): The original implementation of STDOUT StreamType in
547
+ # _StreamReaderThroughServer prints to stdout immediately. This doesn't match
548
+ # python subprocess.run, which uses None to print to stdout immediately, and uses
549
+ # STDOUT as an argument to stderr to redirect stderr to the stdout stream. We should
550
+ # implement the old behavior here before moving out of beta, but after that
551
+ # we should consider changing the API to match python subprocess.run. I don't expect
552
+ # many customers are using this in any case, so I think it's fine to leave this
553
+ # unimplemented for now.
554
+ if stream_type == StreamType.STDOUT:
555
+ raise NotImplementedError(
556
+ "Currently only the PIPE stream type is supported when using exec "
557
+ "through a task command router, which is currently in beta."
558
+ )
559
+ params = _StreamReaderThroughCommandRouterParams(
560
+ file_descriptor, task_id, object_id, command_router_client, deadline
561
+ )
562
+ if text:
563
+ self._impl = _TextStreamReaderThroughCommandRouter(params, by_line)
564
+ else:
565
+ self._impl = _BytesStreamReaderThroughCommandRouter(params)
566
+
567
+ @property
568
+ def file_descriptor(self) -> int:
569
+ """Possible values are `1` for stdout and `2` for stderr."""
570
+ return self._impl.file_descriptor
571
+
572
+ async def read(self) -> T:
573
+ """Fetch the entire contents of the stream until EOF.
574
+
575
+ **Usage**
576
+
577
+ ```python fixture:running_app
578
+ from modal import Sandbox
579
+
580
+ sandbox = Sandbox.create("echo", "hello", app=running_app)
581
+ sandbox.wait()
582
+
583
+ print(sandbox.stdout.read())
584
+ ```
585
+ """
586
+ return await self._impl.read()
587
+
588
+ # TODO(saltzm): I'd prefer to have the implementation classes only implement __aiter__
589
+ # and have them return generator functions directly, but synchronicity doesn't let us
590
+ # return self._impl.__aiter__() here because it won't properly wrap the implementation
591
+ # classes.
592
+ def __aiter__(self) -> AsyncIterator[T]:
593
+ """mdmd:hidden"""
594
+ return self
595
+
596
+ async def __anext__(self) -> T:
597
+ """mdmd:hidden"""
598
+ return await self._impl.__anext__()
599
+
600
+ async def aclose(self):
601
+ """mdmd:hidden"""
602
+ await self._impl.aclose()
603
+
604
+
359
605
  MAX_BUFFER_SIZE = 2 * 1024 * 1024
360
606
 
361
607
 
362
- class _StreamWriter:
608
+ class _StreamWriterThroughServer:
363
609
  """Provides an interface to buffer and write logs to a sandbox or container process stream (`stdin`)."""
364
610
 
365
611
  def __init__(self, object_id: str, object_type: Literal["sandbox", "container_process"], client: _Client) -> None:
@@ -381,25 +627,6 @@ class _StreamWriter:
381
627
 
382
628
  This is non-blocking and queues the data to an internal buffer. Must be
383
629
  used along with the `drain()` method, which flushes the buffer.
384
-
385
- **Usage**
386
-
387
- ```python fixture:running_app
388
- from modal import Sandbox
389
-
390
- sandbox = Sandbox.create(
391
- "bash",
392
- "-c",
393
- "while read line; do echo $line; done",
394
- app=running_app,
395
- )
396
- sandbox.stdin.write(b"foo\\n")
397
- sandbox.stdin.write(b"bar\\n")
398
- sandbox.stdin.write_eof()
399
-
400
- sandbox.stdin.drain()
401
- sandbox.wait()
402
- ```
403
630
  """
404
631
  if self._is_closed:
405
632
  raise ValueError("Stdin is closed. Cannot write to it.")
@@ -407,7 +634,7 @@ class _StreamWriter:
407
634
  if isinstance(data, str):
408
635
  data = data.encode("utf-8")
409
636
  if len(self._buffer) + len(data) > MAX_BUFFER_SIZE:
410
- raise BufferError("Buffer size exceed limit. Call drain to clear the buffer.")
637
+ raise BufferError("Buffer size exceed limit. Call drain to flush the buffer.")
411
638
  self._buffer.extend(data)
412
639
  else:
413
640
  raise TypeError(f"data argument must be a bytes-like object, not {type(data).__name__}")
@@ -426,19 +653,6 @@ class _StreamWriter:
426
653
 
427
654
  This is a flow control method that blocks until data is sent. It returns
428
655
  when it is appropriate to continue writing data to the stream.
429
-
430
- **Usage**
431
-
432
- ```python notest
433
- writer.write(data)
434
- writer.drain()
435
- ```
436
-
437
- Async usage:
438
- ```python notest
439
- writer.write(data) # not a blocking operation
440
- await writer.drain.aio()
441
- ```
442
656
  """
443
657
  data = bytes(self._buffer)
444
658
  self._buffer.clear()
@@ -467,5 +681,127 @@ class _StreamWriter:
467
681
  raise exc
468
682
 
469
683
 
684
+ class _StreamWriterThroughCommandRouter:
685
+ def __init__(
686
+ self,
687
+ object_id: str,
688
+ command_router_client: TaskCommandRouterClient,
689
+ task_id: str,
690
+ ) -> None:
691
+ self._object_id = object_id
692
+ self._command_router_client = command_router_client
693
+ self._task_id = task_id
694
+ self._is_closed = False
695
+ self._buffer = bytearray()
696
+ self._offset = 0
697
+
698
+ def write(self, data: Union[bytes, bytearray, memoryview, str]) -> None:
699
+ if self._is_closed:
700
+ raise ValueError("Stdin is closed. Cannot write to it.")
701
+ if isinstance(data, (bytes, bytearray, memoryview, str)):
702
+ if isinstance(data, str):
703
+ data = data.encode("utf-8")
704
+ if len(self._buffer) + len(data) > MAX_BUFFER_SIZE:
705
+ raise BufferError("Buffer size exceed limit. Call drain to flush the buffer.")
706
+ self._buffer.extend(data)
707
+ else:
708
+ raise TypeError(f"data argument must be a bytes-like object, not {type(data).__name__}")
709
+
710
+ def write_eof(self) -> None:
711
+ self._is_closed = True
712
+
713
+ async def drain(self) -> None:
714
+ eof = self._is_closed
715
+ # NB: There's no need to prevent writing eof twice, because the command router will ignore the second EOF.
716
+ if self._buffer or eof:
717
+ data = bytes(self._buffer)
718
+ await self._command_router_client.exec_stdin_write(
719
+ task_id=self._task_id, exec_id=self._object_id, offset=self._offset, data=data, eof=eof
720
+ )
721
+ # Only clear the buffer after writing the data to the command router is successful.
722
+ # This allows the client to retry drain() in the event of an exception (though
723
+ # exec_stdin_write already retries on transient errors, so most users will probably
724
+ # not do this).
725
+ self._buffer.clear()
726
+ self._offset += len(data)
727
+
728
+
729
+ class _StreamWriter:
730
+ """Provides an interface to buffer and write logs to a sandbox or container process stream (`stdin`)."""
731
+
732
+ def __init__(
733
+ self,
734
+ object_id: str,
735
+ object_type: Literal["sandbox", "container_process"],
736
+ client: _Client,
737
+ command_router_client: Optional[TaskCommandRouterClient] = None,
738
+ task_id: Optional[str] = None,
739
+ ) -> None:
740
+ """mdmd:hidden"""
741
+ if command_router_client is None:
742
+ self._impl = _StreamWriterThroughServer(object_id, object_type, client)
743
+ else:
744
+ assert task_id is not None
745
+ assert object_type == "container_process"
746
+ self._impl = _StreamWriterThroughCommandRouter(object_id, command_router_client, task_id=task_id)
747
+
748
+ def write(self, data: Union[bytes, bytearray, memoryview, str]) -> None:
749
+ """Write data to the stream but does not send it immediately.
750
+
751
+ This is non-blocking and queues the data to an internal buffer. Must be
752
+ used along with the `drain()` method, which flushes the buffer.
753
+
754
+ **Usage**
755
+
756
+ ```python fixture:running_app
757
+ from modal import Sandbox
758
+
759
+ sandbox = Sandbox.create(
760
+ "bash",
761
+ "-c",
762
+ "while read line; do echo $line; done",
763
+ app=running_app,
764
+ )
765
+ sandbox.stdin.write(b"foo\\n")
766
+ sandbox.stdin.write(b"bar\\n")
767
+ sandbox.stdin.write_eof()
768
+
769
+ sandbox.stdin.drain()
770
+ sandbox.wait()
771
+ ```
772
+ """
773
+ self._impl.write(data)
774
+
775
+ def write_eof(self) -> None:
776
+ """Close the write end of the stream after the buffered data is drained.
777
+
778
+ If the process was blocked on input, it will become unblocked after
779
+ `write_eof()`. This method needs to be used along with the `drain()`
780
+ method, which flushes the EOF to the process.
781
+ """
782
+ self._impl.write_eof()
783
+
784
+ async def drain(self) -> None:
785
+ """Flush the write buffer and send data to the running process.
786
+
787
+ This is a flow control method that blocks until data is sent. It returns
788
+ when it is appropriate to continue writing data to the stream.
789
+
790
+ **Usage**
791
+
792
+ ```python notest
793
+ writer.write(data)
794
+ writer.drain()
795
+ ```
796
+
797
+ Async usage:
798
+ ```python notest
799
+ writer.write(data) # not a blocking operation
800
+ await writer.drain.aio()
801
+ ```
802
+ """
803
+ await self._impl.drain()
804
+
805
+
470
806
  StreamReader = synchronize_api(_StreamReader)
471
807
  StreamWriter = synchronize_api(_StreamWriter)