modal 1.6.4.dev16__tar.gz → 1.6.5.dev0__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 (257) hide show
  1. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/PKG-INFO +1 -1
  2. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/__main__.py +2 -1
  3. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_cluster.py +1 -1
  4. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_environments.py +1 -1
  5. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_functions.py +2 -2
  6. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_image.py +32 -21
  7. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_object.py +17 -11
  8. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_output/manager.py +4 -3
  9. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_output/rich.py +18 -5
  10. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/task_lifecycle_manager.py +1 -1
  11. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/async_utils.py +23 -5
  12. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/auth_token_manager.py +17 -0
  13. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/http_utils.py +9 -3
  14. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_workspace.py +57 -1
  15. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/app.py +27 -8
  16. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/app.pyi +63 -18
  17. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_help.py +14 -17
  18. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_suggest.py +16 -0
  19. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/app.py +2 -1
  20. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/endpoint.py +55 -0
  21. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/image.py +46 -1
  22. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/import_refs.py +7 -4
  23. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/run.py +57 -38
  24. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/shell.py +2 -16
  25. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/utils.py +4 -7
  26. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/workspace.py +96 -0
  27. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/client.py +74 -27
  28. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/client.pyi +45 -14
  29. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cls.py +1 -1
  30. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/config.py +14 -3
  31. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/dict.py +1 -1
  32. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/_flash_container_entry.py +1 -1
  33. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/image.pyi +10 -10
  34. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/mount.py +2 -2
  35. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/network_file_system.py +1 -1
  36. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/object.pyi +3 -1
  37. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/proxy.py +1 -1
  38. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/queue.py +1 -1
  39. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_common.py +1 -1
  40. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_impl_persistent.py +11 -2
  41. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_sandbox.py +65 -3
  42. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_sidecar.py +1 -1
  43. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_snapshot.py +1 -1
  44. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/sandbox.pyi +107 -1
  45. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/secret.py +1 -1
  46. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/types.py +33 -4
  47. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/volume.py +1 -1
  48. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/workspace.pyi +104 -0
  49. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/PKG-INFO +1 -1
  50. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/mdmd/mdmd.py +2 -1
  51. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/api_grpc.py +48 -0
  52. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/api_pb2.py +1294 -1220
  53. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/api_pb2.pyi +172 -12
  54. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/api_pb2_grpc.py +99 -0
  55. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/api_pb2_grpc.pyi +30 -0
  56. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/modal_api_grpc.py +3 -0
  57. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_version/__init__.py +1 -1
  58. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/LICENSE +0 -0
  59. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/README.md +0 -0
  60. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/__init__.py +0 -0
  61. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_audit_logs/__init__.py +0 -0
  62. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_audit_logs/_rpcs.py +0 -0
  63. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_audit_logs/count.py +0 -0
  64. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_audit_logs/list.py +0 -0
  65. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_billing.py +0 -0
  66. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_cluster.pyi +0 -0
  67. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_container_entrypoint.py +0 -0
  68. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_function_variants.py +0 -0
  69. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_grpc_client.py +0 -0
  70. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_ipython.py +0 -0
  71. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_load_context.py +0 -0
  72. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_location.py +0 -0
  73. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_logs.py +0 -0
  74. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_logs_manager.py +0 -0
  75. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_logs_manager.pyi +0 -0
  76. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_metrics.py +0 -0
  77. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_metrics.pyi +0 -0
  78. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_outbound_policy.py +0 -0
  79. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_outbound_policy.pyi +0 -0
  80. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_output/__init__.py +0 -0
  81. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_output/pty.py +0 -0
  82. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_output/status.py +0 -0
  83. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_partial_function.py +0 -0
  84. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_resolver.py +0 -0
  85. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_resources.py +0 -0
  86. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/__init__.py +0 -0
  87. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/asgi.py +0 -0
  88. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/container_io_manager.py +0 -0
  89. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/container_io_manager.pyi +0 -0
  90. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/execution_context.py +0 -0
  91. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/execution_context.pyi +0 -0
  92. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/gpu_memory_snapshot.py +0 -0
  93. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/task_lifecycle_manager.pyi +0 -0
  94. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/telemetry.py +0 -0
  95. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/user_code_event_loop.py +0 -0
  96. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_runtime/user_code_imports.py +0 -0
  97. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_serialization.py +0 -0
  98. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_server.py +0 -0
  99. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_server.pyi +0 -0
  100. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_supports_logs.py +0 -0
  101. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_traceback.py +0 -0
  102. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_tunnel.py +0 -0
  103. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_tunnel.pyi +0 -0
  104. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_type_manager.py +0 -0
  105. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/__init__.py +0 -0
  106. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/app_utils.py +0 -0
  107. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/blob_utils.py +0 -0
  108. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/browser_utils.py +0 -0
  109. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/bytes_io_segment_payload.py +0 -0
  110. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/curl_utils.py +0 -0
  111. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/deprecation.py +0 -0
  112. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/display_utils.py +0 -0
  113. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/docker_utils.py +0 -0
  114. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/function_utils.py +0 -0
  115. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/git_utils.py +0 -0
  116. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/grpc_testing.py +0 -0
  117. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/grpc_utils.py +0 -0
  118. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/hash_utils.py +0 -0
  119. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/idle_countdown.py +0 -0
  120. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/jwt_utils.py +0 -0
  121. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/logger.py +0 -0
  122. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/mount_utils.py +0 -0
  123. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/name_utils.py +0 -0
  124. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/oauth.py +0 -0
  125. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/package_utils.py +0 -0
  126. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/pattern_utils.py +0 -0
  127. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/proxy_support.py +0 -0
  128. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/rand_pb_testing.py +0 -0
  129. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/sandbox_fs_utils.py +0 -0
  130. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/shell_utils.py +0 -0
  131. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_utils/time_utils.py +0 -0
  132. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_vendor/__init__.py +0 -0
  133. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_vendor/a2wsgi_wsgi.py +0 -0
  134. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_vendor/cloudpickle.py +0 -0
  135. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_vendor/tblib.py +0 -0
  136. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_vendor/version.py +0 -0
  137. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/_watcher.py +0 -0
  138. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/billing.py +0 -0
  139. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/billing.pyi +0 -0
  140. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2023.12.312.txt +0 -0
  141. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2023.12.txt +0 -0
  142. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2024.04.txt +0 -0
  143. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2024.10.txt +0 -0
  144. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2025.06.txt +0 -0
  145. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/2026.10.txt +0 -0
  146. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/PREVIEW.txt +0 -0
  147. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/README.md +0 -0
  148. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/builder/base-images.json +0 -0
  149. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/call_graph.py +0 -0
  150. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/__init__.py +0 -0
  151. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_download.py +0 -0
  152. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_logs.py +0 -0
  153. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_stats.py +0 -0
  154. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/_traceback.py +0 -0
  155. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/billing.py +0 -0
  156. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/changelog.py +0 -0
  157. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/config.py +0 -0
  158. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/container.py +0 -0
  159. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/curl.py +0 -0
  160. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/dashboard.py +0 -0
  161. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/dict.py +0 -0
  162. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/entry_point.py +0 -0
  163. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/environment.py +0 -0
  164. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/function.py +0 -0
  165. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/logo.py +0 -0
  166. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/network_file_system.py +0 -0
  167. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/profile.py +0 -0
  168. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/queues.py +0 -0
  169. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/secret.py +0 -0
  170. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/selector.py +0 -0
  171. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/server.py +0 -0
  172. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/skills.py +0 -0
  173. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/token.py +0 -0
  174. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cli/volume.py +0 -0
  175. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cloud_bucket_mount.py +0 -0
  176. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cloud_bucket_mount.pyi +0 -0
  177. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cls.pyi +0 -0
  178. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cluster.py +0 -0
  179. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/cluster.pyi +0 -0
  180. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/container_process.py +0 -0
  181. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/container_process.pyi +0 -0
  182. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/dict.pyi +0 -0
  183. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/environments.py +0 -0
  184. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/environments.pyi +0 -0
  185. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/exception.py +0 -0
  186. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/__init__.py +0 -0
  187. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/flash.py +0 -0
  188. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/flash.pyi +0 -0
  189. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/flash_server.py +0 -0
  190. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/flash_server.pyi +0 -0
  191. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/ipython.py +0 -0
  192. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/stream.py +0 -0
  193. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/experimental/stream.pyi +0 -0
  194. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/file_pattern_matcher.py +0 -0
  195. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/functions.py +0 -0
  196. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/functions.pyi +0 -0
  197. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/image.py +0 -0
  198. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/io_streams.py +0 -0
  199. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/io_streams.pyi +0 -0
  200. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/mount.pyi +0 -0
  201. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/network_file_system.pyi +0 -0
  202. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/object.py +0 -0
  203. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/output.py +0 -0
  204. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/parallel_map.py +0 -0
  205. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/parallel_map.pyi +0 -0
  206. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/partial_function.py +0 -0
  207. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/partial_function.pyi +0 -0
  208. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/proxy.pyi +0 -0
  209. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/py.typed +0 -0
  210. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/queue.pyi +0 -0
  211. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/retries.py +0 -0
  212. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/runner.py +0 -0
  213. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/runner.pyi +0 -0
  214. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/running_app.py +0 -0
  215. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/__init__.py +0 -0
  216. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_filesystem.py +0 -0
  217. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_impl_v1.py +0 -0
  218. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_impl_v2.py +0 -0
  219. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/_task_command_router_client.py +0 -0
  220. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/sandbox/sandbox.py +0 -0
  221. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/schedule.py +0 -0
  222. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/scheduler_placement.py +0 -0
  223. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/secret.pyi +0 -0
  224. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/server.py +0 -0
  225. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/server.pyi +0 -0
  226. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/serving.py +0 -0
  227. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/serving.pyi +0 -0
  228. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/skills/modal/SKILL.md +0 -0
  229. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/stream_type.py +0 -0
  230. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/token_flow.py +0 -0
  231. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/token_flow.pyi +0 -0
  232. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/volume.pyi +0 -0
  233. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal/workspace.py +0 -0
  234. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/SOURCES.txt +0 -0
  235. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/dependency_links.txt +0 -0
  236. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/entry_points.txt +0 -0
  237. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/requires.txt +0 -0
  238. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal.egg-info/top_level.txt +0 -0
  239. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/__init__.py +0 -0
  240. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/gen_cli_docs.py +0 -0
  241. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/gen_cli_docs_main.py +0 -0
  242. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/gen_reference_docs.py +0 -0
  243. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/gen_reference_docs_main.py +0 -0
  244. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/mdmd/__init__.py +0 -0
  245. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/mdmd/signatures.py +0 -0
  246. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/mdmd/types.py +0 -0
  247. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_docs/reference_intro.md +0 -0
  248. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/__init__.py +0 -0
  249. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/py.typed +0 -0
  250. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/task_command_router_grpc.py +0 -0
  251. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/task_command_router_pb2.py +0 -0
  252. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/task_command_router_pb2.pyi +0 -0
  253. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/task_command_router_pb2_grpc.py +0 -0
  254. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_proto/task_command_router_pb2_grpc.pyi +0 -0
  255. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/modal_version/__main__.py +0 -0
  256. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/pyproject.toml +0 -0
  257. {modal-1.6.4.dev16 → modal-1.6.5.dev0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.6.4.dev16
3
+ Version: 1.6.5.dev0
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License-Expression: Apache-2.0
@@ -2,6 +2,7 @@
2
2
  import sys
3
3
 
4
4
  from ._traceback import reduce_traceback_to_user_code
5
+ from .cli._suggest import get_hint
5
6
  from .cli._traceback import highlight_modal_warnings, setup_rich_traceback
6
7
  from .cli.entry_point import entrypoint_cli
7
8
  from .cli.import_refs import _CliUserExecutionError
@@ -41,7 +42,7 @@ def main():
41
42
  if notes := getattr(exc, "__notes__", []):
42
43
  content = f"{content}\n\nNote: {' '.join(notes)}"
43
44
 
44
- OutputManager.get().print_error(content)
45
+ OutputManager.get().print_error(content, hint=get_hint(exc))
45
46
  sys.exit(1)
46
47
 
47
48
 
@@ -40,7 +40,7 @@ def get_current_cluster_context() -> ClusterContext:
40
40
  return current_cluster_context
41
41
 
42
42
 
43
- class _Cluster(_Object, type_prefix="cu"):
43
+ class _Cluster(_Object, type_prefixes=("cu",)):
44
44
  """A group of containers scheduled together for a clustered Function or Server.
45
45
 
46
46
  Use `Cluster.from_context()` inside a cluster, or `Cluster.from_id()` to
@@ -353,7 +353,7 @@ class _EnvironmentAppsManager:
353
353
  ]
354
354
 
355
355
 
356
- class _Environment(_Object, type_prefix="en"):
356
+ class _Environment(_Object, type_prefixes=("en",)):
357
357
  _name: str | None = None
358
358
  _settings: EnvironmentSettings
359
359
 
@@ -620,7 +620,7 @@ OriginalReturnType = typing.TypeVar(
620
620
  T = typing.TypeVar("T", covariant=True)
621
621
 
622
622
 
623
- class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type_prefix="fu"):
623
+ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type_prefixes=("fu",)):
624
624
  """Functions are the basic units of serverless execution on Modal.
625
625
 
626
626
  Generally, you will not construct a `Function` directly. Instead, use the
@@ -2371,7 +2371,7 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type
2371
2371
  experimental_spawn_map = MethodWithAio(_experimental_spawn_map_sync, _experimental_spawn_map_async, synchronizer)
2372
2372
 
2373
2373
 
2374
- class _FunctionCall(typing.Generic[ReturnType], _Object, type_prefix="fc"):
2374
+ class _FunctionCall(typing.Generic[ReturnType], _Object, type_prefixes=("fc",)):
2375
2375
  """A reference to an executed function call.
2376
2376
 
2377
2377
  Constructed using `.spawn(...)` on a Modal function with the same
@@ -587,7 +587,7 @@ class _FailedBuildAttempt:
587
587
  client: _Client
588
588
 
589
589
 
590
- class _Image(_Object, type_prefix="im"):
590
+ class _Image(_Object, type_prefixes=("im",)):
591
591
  """Base class for container images to run functions in.
592
592
 
593
593
  Do not construct this class directly; instead use one of its static factory methods,
@@ -1127,7 +1127,7 @@ class _Image(_Object, type_prefix="im"):
1127
1127
 
1128
1128
  return typing.cast(typing_extensions.Self, synchronizer._translate_out(obj))
1129
1129
 
1130
- async def build(self, app: "modal.app._App") -> "_Image":
1130
+ async def build(self, app: "modal.app._App | None" = None) -> "_Image":
1131
1131
  """Eagerly build an image.
1132
1132
 
1133
1133
  If your image was previously built, then this method will not rebuild your image
@@ -1137,7 +1137,8 @@ class _Image(_Object, type_prefix="im"):
1137
1137
  You do not need to build the image explicitly in that case.
1138
1138
 
1139
1139
  Args:
1140
- app: Initialized app used as the load context for the image build.
1140
+ app: App for running the build. If not provided, the build will run
1141
+ in an ephemeral App.
1141
1142
 
1142
1143
  Returns:
1143
1144
  This image after the build (and resolver load) completes.
@@ -1146,9 +1147,8 @@ class _Image(_Object, type_prefix="im"):
1146
1147
  ```python
1147
1148
  image = modal.Image.debian_slim().uv_pip_install("scipy", "numpy")
1148
1149
 
1149
- app = modal.App.lookup("build-image", create_if_missing=True)
1150
1150
  with modal.enable_output(): # To see logs in your local terminal
1151
- image.build(app)
1151
+ image.build()
1152
1152
 
1153
1153
  # Save the image id
1154
1154
  my_image_id = image.object_id
@@ -1181,23 +1181,34 @@ class _Image(_Object, type_prefix="im"):
1181
1181
  ...
1182
1182
  ```
1183
1183
  """
1184
- if app.app_id is None:
1185
- raise InvalidError("App has not been initialized yet. Use the context manager `app.run()` or `App.lookup`")
1186
-
1187
- resolver = Resolver()
1188
- async with TaskContext() as tc:
1189
- self._build_steps = None
1190
- self._failed_build_attempt = None
1191
- load_context = LoadContext(task_context=tc).merged_with(app._root_load_context)
1192
- try:
1193
- await resolver.load(self, load_context)
1194
- except ImageBuildError as e:
1195
- self._failed_build_attempt = _FailedBuildAttempt(
1196
- image_id=e.image_id,
1197
- client=load_context.client,
1184
+
1185
+ if app is None:
1186
+ from .runner import _run_app
1187
+
1188
+ app_context = _run_app(modal.app._App("modal-image-build"), stream_output=False)
1189
+ else:
1190
+ app_context = contextlib.nullcontext(app)
1191
+
1192
+ async with app_context as app:
1193
+ if app.app_id is None:
1194
+ raise InvalidError(
1195
+ "App has not been initialized yet. Use the context manager `app.run()` or `App.lookup`"
1198
1196
  )
1199
1197
 
1200
- raise
1198
+ resolver = Resolver()
1199
+ async with TaskContext() as tc:
1200
+ self._build_steps = None
1201
+ self._failed_build_attempt = None
1202
+ load_context = LoadContext(task_context=tc).merged_with(app._root_load_context)
1203
+ try:
1204
+ await resolver.load(self, load_context)
1205
+ except ImageBuildError as e:
1206
+ self._failed_build_attempt = _FailedBuildAttempt(
1207
+ image_id=e.image_id,
1208
+ client=load_context.client,
1209
+ )
1210
+
1211
+ raise
1201
1212
  return self
1202
1213
 
1203
1214
  @_requires_image_instance
@@ -3239,7 +3250,7 @@ class _Image(_Object, type_prefix="im"):
3239
3250
 
3240
3251
  ```python notest
3241
3252
  image = modal.Image.debian_slim().pip_install("numpy")
3242
- image.build(app)
3253
+ image.build()
3243
3254
  image.publish("my-image-with-numpy") # my-image-with-numpy:latest
3244
3255
  image.publish("my-image-with-numpy:v1")
3245
3256
  ```
@@ -82,7 +82,8 @@ def live_method_contextmanager(
82
82
 
83
83
 
84
84
  class _Object:
85
- _type_prefix: ClassVar[str | None] = None
85
+ # Prefixes of the object IDs that hydrate this type, e.g. `("sb",)` for `sb-...` IDs.
86
+ _type_prefixes: ClassVar[tuple[str, ...]] = ()
86
87
  _prefix_to_type: ClassVar[dict[str, type["_Object"]]] = {}
87
88
 
88
89
  # For constructors
@@ -114,11 +115,16 @@ class _Object:
114
115
  self.__is_hydrated = value
115
116
 
116
117
  @classmethod
117
- def __init_subclass__(cls, type_prefix: str | None = None):
118
+ def __init_subclass__(cls, type_prefixes: Sequence[str] = ()):
118
119
  super().__init_subclass__()
119
- if type_prefix is not None:
120
- cls._type_prefix = type_prefix
121
- cls._prefix_to_type[type_prefix] = cls
120
+ if type_prefixes:
121
+ cls._type_prefixes = tuple(type_prefixes)
122
+ for prefix in cls._type_prefixes:
123
+ cls._prefix_to_type[prefix] = cls
124
+
125
+ @classmethod
126
+ def _has_type_prefix(cls, object_id: str) -> bool:
127
+ return any(object_id.startswith(prefix + "-") for prefix in cls._type_prefixes)
122
128
 
123
129
  def __init__(self, *args, **kwargs):
124
130
  """mdmd:hidden"""
@@ -174,11 +180,11 @@ class _Object:
174
180
  self._client = other._client
175
181
 
176
182
  def _hydrate(self, object_id: str, client: _Client, metadata: Message | None):
177
- assert isinstance(object_id, str) and self._type_prefix is not None
178
- if not object_id.startswith(self._type_prefix):
183
+ assert isinstance(object_id, str) and self._type_prefixes
184
+ if not self._has_type_prefix(object_id):
179
185
  raise ExecutionError(
180
186
  f"Can not hydrate {type(self)}: "
181
- f" it has type prefix {self._type_prefix}"
187
+ f" it has type prefixes {self._type_prefixes}"
182
188
  f" but the object_id starts with {object_id[:3]}. "
183
189
  "This usually means the object name was previously used for a different type. "
184
190
  "Rename the object/app or stop the previous deployment and redeploy."
@@ -270,11 +276,11 @@ class _Object:
270
276
  rep: str | None = None,
271
277
  ) -> Self:
272
278
  obj_cls: type[Self]
273
- if cls._type_prefix is not None:
279
+ if cls._type_prefixes:
274
280
  # This is called directly on a subclass, e.g. Secret.from_id
275
281
  # validate the id matching the expected id type of the Object subclass
276
- if not object_id.startswith(cls._type_prefix + "-"):
277
- raise InvalidError(f"Object {object_id} does not start with {cls._type_prefix}")
282
+ if not cls._has_type_prefix(object_id):
283
+ raise InvalidError(f"Object {object_id} does not start with any of {cls._type_prefixes}")
278
284
 
279
285
  obj_cls = cls
280
286
  else:
@@ -207,7 +207,7 @@ class OutputManager(ABC):
207
207
  ...
208
208
 
209
209
  @abstractmethod
210
- def print_error(self, error_text: str) -> None:
210
+ def print_error(self, error_text: str, hint: str = "") -> None:
211
211
  """Print an error message to stderr, ignoring quiet/disabled mode.
212
212
 
213
213
  This method always prints the error message regardless of quiet mode
@@ -216,6 +216,7 @@ class OutputManager(ABC):
216
216
 
217
217
  Args:
218
218
  error_text: The error message text to display.
219
+ hint: An optional suggestion (e.g. "Did you mean ...?") shown after the message.
219
220
  """
220
221
  ...
221
222
 
@@ -490,9 +491,9 @@ class DisabledOutputManager(OutputManager):
490
491
  ) -> None:
491
492
  pass
492
493
 
493
- def print_error(self, error_text: str) -> None:
494
+ def print_error(self, error_text: str, hint: str = "") -> None:
494
495
  # Print error to stderr without any formatting (Rich is not available)
495
- sys.stderr.write(error_text + "\n")
496
+ sys.stderr.write(f"{error_text}\n{hint}\n" if hint else f"{error_text}\n")
496
497
 
497
498
  def show_warning(
498
499
  self,
@@ -227,6 +227,19 @@ _ANSI_RESET = "\033[0m"
227
227
  QUEUEING_STRAGGLER_GRACE_SECS = 30.0
228
228
 
229
229
 
230
+ def format_error_message(error_text: str, hint: str = "") -> Text:
231
+ """Build the styled text for a CLI error message.
232
+
233
+ The message and hint are taken literally (no markup is interpreted). The message gets an
234
+ "Error:" prefix, and the hint, if any, follows on the next line in a dim style.
235
+ """
236
+ message = Text.assemble(("Error:", "bold red"), " ", error_text)
237
+ if hint:
238
+ message.append("\n")
239
+ message.append(hint, style="dim")
240
+ return message
241
+
242
+
230
243
  class RichOutputManager(OutputManager):
231
244
  """Rich-based implementation of OutputManager.
232
245
 
@@ -347,13 +360,13 @@ class RichOutputManager(OutputManager):
347
360
  else:
348
361
  self._console.print(renderable, highlight=highlight, style=style, sep=sep, end=end)
349
362
 
350
- def print_error(self, error_text: str) -> None:
351
- """Print an error message to stderr in a panel, ignoring quiet mode.
363
+ def print_error(self, error_text: str, hint: str = "") -> None:
364
+ """Print an error message, and an optional suggestion hint, to stderr, ignoring quiet mode.
352
365
 
353
- This method always prints the error message regardless of quiet mode.
366
+ The message is printed as-is after a styled "Error:" prefix, without hard line wrapping,
367
+ so that a single-line message stays on one line regardless of terminal width.
354
368
  """
355
- panel = Panel(escape(error_text), title="Error", title_align="left", border_style="red")
356
- self._stderr_console.print(panel, highlight=False)
369
+ self._stderr_console.print(format_error_message(error_text, hint), highlight=False, soft_wrap=True)
357
370
 
358
371
  def print_json(self, data: str) -> None:
359
372
  """Print JSON data with formatting."""
@@ -230,7 +230,7 @@ class _TaskLifecycleManager:
230
230
  api_pb2.ContainerCheckpointRequest(checkpoint_id=self.checkpoint_id)
231
231
  )
232
232
 
233
- await self._client._close(prep_for_restore=True)
233
+ await self._client._prep_for_snapshot()
234
234
 
235
235
  logger.debug("Memory snapshot request sent. Connection closed.")
236
236
  await self.memory_restore()
@@ -864,19 +864,37 @@ class AsyncOrSyncIterable:
864
864
  await self._async_iterable.aclose()
865
865
 
866
866
 
867
- _shutdown_tasks = []
867
+ _shutdown_tasks: set[asyncio.Task] = set()
868
868
 
869
869
 
870
- def on_shutdown(coro):
870
+ def on_shutdown(cleanup: Callable[[], Awaitable[Any]]) -> Callable[[], None]:
871
871
  # hook into event loop shutdown when all active tasks get cancelled
872
+ active = True
873
+
872
874
  async def wrapper():
875
+ nonlocal active
873
876
  try:
874
877
  await asyncio.sleep(1e10) # never awake except for exceptions
875
878
  finally:
876
- await coro
877
- raise
879
+ if active:
880
+ active = False
881
+ await cleanup()
882
+
883
+ task = asyncio.create_task(wrapper())
884
+ _shutdown_tasks.add(task)
885
+ task.add_done_callback(_shutdown_tasks.discard)
886
+
887
+ def unregister():
888
+ nonlocal active
889
+ if not active:
890
+ return
891
+ active = False
892
+ _shutdown_tasks.discard(task)
893
+ loop = task.get_loop()
894
+ if not loop.is_closed() and not task.done() and task is not asyncio.current_task(loop=loop):
895
+ task.cancel()
878
896
 
879
- _shutdown_tasks.append(asyncio.create_task(wrapper()))
897
+ return unregister
880
898
 
881
899
 
882
900
  def asyncify(f: Callable[P, T]) -> Callable[P, typing.Coroutine[None, None, T]]:
@@ -54,6 +54,17 @@ class _AuthTokenManager:
54
54
  self._backoff = self.FAILURE_BACKOFF_BASE
55
55
  self._refresh_task: asyncio.Task | None = None
56
56
 
57
+ async def reset(self) -> None:
58
+ if self._refresh_task is not None:
59
+ self._refresh_task.cancel()
60
+ await asyncio.gather(self._refresh_task, return_exceptions=True)
61
+ self._refresh_task = None
62
+ self._token = ""
63
+ self._expiry = 0.0
64
+ self._refresh_at = 0.0
65
+ self._retry_after = 0.0
66
+ self._backoff = self.FAILURE_BACKOFF_BASE
67
+
57
68
  async def get_token(self) -> str:
58
69
  """
59
70
  When called, the AuthTokenManager can be in one of three states:
@@ -80,6 +91,12 @@ class _AuthTokenManager:
80
91
 
81
92
  return self._token
82
93
 
94
+ async def close(self) -> None:
95
+ task, self._refresh_task = self._refresh_task, None
96
+ if task is not None:
97
+ task.cancel()
98
+ await asyncio.gather(task, return_exceptions=True)
99
+
83
100
  async def _try_refresh_token(self):
84
101
  try:
85
102
  await self._refresh_token()
@@ -1,6 +1,6 @@
1
1
  # Copyright Modal Labs 2022
2
2
  import contextlib
3
- from typing import TYPE_CHECKING
3
+ from typing import TYPE_CHECKING, ClassVar
4
4
 
5
5
  # Note: importing aiohttp seems to take about 100ms, and it's not really necessarily,
6
6
  # unless we need to work with blobs. So that's why we import it lazily instead.
@@ -54,20 +54,26 @@ def _http_client_with_tls(timeout: float | None) -> "ClientSession":
54
54
  class ClientSessionRegistry:
55
55
  _client_session: "ClientSession"
56
56
  _client_session_active: bool = False
57
+ _shutdown_unregister: "ClassVar[staticmethod[[], None] | None]" = None
57
58
 
58
59
  @staticmethod
59
60
  def get_session():
60
61
  if not ClientSessionRegistry._client_session_active:
61
62
  ClientSessionRegistry._client_session = _http_client_with_tls(timeout=None)
62
63
  ClientSessionRegistry._client_session_active = True
63
- on_shutdown(ClientSessionRegistry.close_session())
64
+ ClientSessionRegistry._shutdown_unregister = staticmethod(on_shutdown(ClientSessionRegistry.close_session))
64
65
  return ClientSessionRegistry._client_session
65
66
 
66
67
  @staticmethod
67
68
  async def close_session():
69
+ if ClientSessionRegistry._shutdown_unregister is not None:
70
+ ClientSessionRegistry._shutdown_unregister()
71
+ ClientSessionRegistry._shutdown_unregister = None
68
72
  if ClientSessionRegistry._client_session_active:
69
- await ClientSessionRegistry._client_session.close()
73
+ session = ClientSessionRegistry._client_session
74
+ del ClientSessionRegistry._client_session
70
75
  ClientSessionRegistry._client_session_active = False
76
+ await session.close()
71
77
 
72
78
 
73
79
  @contextlib.asynccontextmanager
@@ -71,7 +71,7 @@ class _WorkspaceMembersManager:
71
71
  ]
72
72
 
73
73
 
74
- class _Workspace(_Object, type_prefix="ac"):
74
+ class _Workspace(_Object, type_prefixes=("ac",)):
75
75
  _name: Optional[str] = None
76
76
 
77
77
  def __init__(self):
@@ -773,6 +773,62 @@ class _WorkspaceMemberTokenManager:
773
773
 
774
774
  return [MemberTokenInfo._from_proto(token) for token in resp.tokens]
775
775
 
776
+ async def disable(self, *token_ids: str) -> None:
777
+ """Disable member tokens in the specified Workspace.
778
+
779
+ If you are a Workspace Manager or Owner, you can use this method to disable any token in the
780
+ Workspace. Otherwise, you can only disable tokens that you have created. Disabled tokens cannot
781
+ be used to authenticate with Modal, but can be re-enabled at any point.
782
+
783
+ Args:
784
+ *token_ids: The ID(s) of any tokens you want to disable.
785
+
786
+ Examples:
787
+
788
+ ```python notest
789
+ ws = modal.Workspace.from_context()
790
+ ws.member_tokens.disable("ak-0123456789abcdefghijkl", "ak-mnopqrstuvwxyz01234567")
791
+ ```
792
+
793
+ See Also:
794
+ - [`Workspace.member_tokens.enable()`](https://modal.com/docs/sdk/py/latest/Workspace#member_tokensenable):
795
+ A function that re-enables a disabled token, so that it may be used again.
796
+ - [`modal workspace member-tokens disable`](https://modal.com/docs/cli/latest/workspace#modal-workspace-member-tokens-disable)
797
+ Command-line equivalent to this function.
798
+
799
+ """
800
+ if not self._workspace._is_hydrated:
801
+ await self._workspace.hydrate()
802
+
803
+ await self._workspace.client._stub.TokenDisable(api_pb2.TokenDisableRequest(token_ids=list(set(token_ids))))
804
+
805
+ async def enable(self, *token_ids: str) -> None:
806
+ """Re-enable member tokens that have been disabled in the specified Workspace.
807
+
808
+ If you are a Workspace Manager or Owner, you can use this method to enable any token in the
809
+ Workspace. Otherwise, you can only enable tokens that you have created.
810
+
811
+ Args:
812
+ *token_ids: The ID(s) of any tokens you want to enable.
813
+
814
+ Examples:
815
+
816
+ ```python notest
817
+ ws = modal.Workspace.from_context()
818
+ ws.member_tokens.enable("ak-0123456789abcdefghijkl", "ak-mnopqrstuvwxyz01234567")
819
+ ```
820
+
821
+ See Also:
822
+ - [`Workspace.member_tokens.disable()`](https://modal.com/docs/sdk/py/latest/Workspace#member_tokensdisable).
823
+ A function that disables a token, so that it may not be used to authenticate with Modal.
824
+ - [`modal workspace member-tokens enable`](https://modal.com/docs/cli/latest/workspace#modal-workspace-member-tokens-enable)
825
+ Command-line equivalent to this function.
826
+ """
827
+ if not self._workspace._is_hydrated:
828
+ await self._workspace.hydrate()
829
+
830
+ await self._workspace.client._stub.TokenEnable(api_pb2.TokenEnableRequest(token_ids=list(set(token_ids))))
831
+
776
832
  async def delete(self, token_id: str, *, allow_missing: bool = False) -> None:
777
833
  """Delete a Member Token in the specified Workspace.
778
834
 
@@ -43,7 +43,7 @@ from ._utils.function_utils import (
43
43
  validate_target_concurrency,
44
44
  )
45
45
  from ._utils.mount_utils import validate_volumes
46
- from ._utils.name_utils import check_object_name, check_tag_dict
46
+ from ._utils.name_utils import check_object_name, check_tag_dict, is_app_id
47
47
  from .client import _Client
48
48
  from .cloud_bucket_mount import _CloudBucketMount
49
49
  from .cls import _Cls, parameter
@@ -168,9 +168,9 @@ class _AppSandboxesManager:
168
168
  Yields:
169
169
  `SandboxGroupStats` objects, one per combination of tag values, with the following fields:
170
170
  - `tags`: the value of each name in `group_by_tags` for the group's Sandboxes, `None` where not present.
171
- - `cost`: total cost in USD, the sum of `cost_by_resource`.
172
- - `cost_by_resource`: cost in USD by billed resource: `CPU`, `Memory`, and GPU types such as
173
- `H100`. The resource names are subject to change as Modal's billing model evolves.
171
+ - `cost`: total cost in USD as a `decimal.Decimal`, the sum of `cost_by_resource`.
172
+ - `cost_by_resource`: cost in USD as `decimal.Decimal`s, by billed resource: `CPU`, `Memory`, and GPU
173
+ types such as `H100`. The resource names are subject to change as Modal's billing model evolves.
174
174
 
175
175
  Raises:
176
176
  InvalidError: If the time range is invalid or there are more than 10,000 groups.
@@ -421,28 +421,47 @@ class _App:
421
421
  environment_name: str | None = None,
422
422
  create_if_missing: bool = False,
423
423
  ) -> "_App":
424
- """Look up an App with a given name, creating a new App if necessary.
424
+ """Look up an App by name or App ID, creating a new App if necessary.
425
425
 
426
426
  Note that Apps created through this method will be in a deployed state,
427
427
  but they will not have any associated Functions or Classes. This method
428
428
  is mainly useful for creating an App to associate with a Sandbox.
429
429
 
430
+ Passing an App ID (`ap-...`) instead of a name looks up that specific App,
431
+ which also works for ephemeral Apps started with `app.run()` and for stopped
432
+ Apps. A lookup by ID ignores `environment_name` and cannot be combined with
433
+ `create_if_missing`.
434
+
430
435
  Args:
431
- name: App name to resolve or create.
436
+ name: App name to resolve or create, or the ID of an existing App.
432
437
  client: Modal client to use; defaults to `Client.from_env()` when omitted.
433
438
  environment_name: Optional environment name; defaults to the configured environment.
439
+ Ignored when `name` is an App ID.
434
440
  create_if_missing: If True, create the app when it does not already exist.
441
+ Not supported when looking up an App by ID.
435
442
 
436
443
  Returns:
437
- An `App` handle tied to the deployed app record.
444
+ An `App` handle tied to the App record.
438
445
 
439
446
  Examples:
440
447
  ```python
441
448
  app = modal.App.lookup("my-app", create_if_missing=True)
442
449
  modal.Sandbox.create("echo", "hi", app=app)
443
450
  ```
451
+
452
+ Look up an ephemeral App by its ID and read its most recent logs:
453
+
454
+ ```python notest
455
+ app = modal.App.lookup("ap-Xk7fT2qLm9RzVb4NwYc8Hd")
456
+ for entry in app.logs.tail(20):
457
+ print(entry.message, end="")
458
+ ```
444
459
  """
445
- check_object_name(name, "App")
460
+ if is_app_id(name):
461
+ if create_if_missing:
462
+ raise InvalidError("`create_if_missing=True` is not supported when looking up an App by ID.")
463
+ else:
464
+ check_object_name(name, "App")
446
465
 
447
466
  if client is None:
448
467
  client = await _Client.from_env()