modal 0.73.34__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 (187) hide show
  1. modal-0.73.34/LICENSE +176 -0
  2. modal-0.73.34/PKG-INFO +55 -0
  3. modal-0.73.34/README.md +38 -0
  4. modal-0.73.34/modal/__init__.py +86 -0
  5. modal-0.73.34/modal/__main__.py +78 -0
  6. modal-0.73.34/modal/_clustered_functions.py +80 -0
  7. modal-0.73.34/modal/_clustered_functions.pyi +22 -0
  8. modal-0.73.34/modal/_container_entrypoint.py +621 -0
  9. modal-0.73.34/modal/_functions.py +1623 -0
  10. modal-0.73.34/modal/_ipython.py +11 -0
  11. modal-0.73.34/modal/_location.py +11 -0
  12. modal-0.73.34/modal/_object.py +297 -0
  13. modal-0.73.34/modal/_output.py +653 -0
  14. modal-0.73.34/modal/_partial_function.py +691 -0
  15. modal-0.73.34/modal/_proxy_tunnel.py +63 -0
  16. modal-0.73.34/modal/_pty.py +53 -0
  17. modal-0.73.34/modal/_resolver.py +184 -0
  18. modal-0.73.34/modal/_resources.py +51 -0
  19. modal-0.73.34/modal/_runtime/__init__.py +1 -0
  20. modal-0.73.34/modal/_runtime/asgi.py +519 -0
  21. modal-0.73.34/modal/_runtime/container_io_manager.py +1035 -0
  22. modal-0.73.34/modal/_runtime/execution_context.py +89 -0
  23. modal-0.73.34/modal/_runtime/gpu_memory_snapshot.py +101 -0
  24. modal-0.73.34/modal/_runtime/telemetry.py +169 -0
  25. modal-0.73.34/modal/_runtime/user_code_imports.py +356 -0
  26. modal-0.73.34/modal/_serialization.py +477 -0
  27. modal-0.73.34/modal/_traceback.py +129 -0
  28. modal-0.73.34/modal/_tunnel.py +194 -0
  29. modal-0.73.34/modal/_tunnel.pyi +37 -0
  30. modal-0.73.34/modal/_utils/__init__.py +1 -0
  31. modal-0.73.34/modal/_utils/app_utils.py +3 -0
  32. modal-0.73.34/modal/_utils/async_utils.py +762 -0
  33. modal-0.73.34/modal/_utils/blob_utils.py +382 -0
  34. modal-0.73.34/modal/_utils/bytes_io_segment_payload.py +97 -0
  35. modal-0.73.34/modal/_utils/deprecation.py +89 -0
  36. modal-0.73.34/modal/_utils/docker_utils.py +98 -0
  37. modal-0.73.34/modal/_utils/function_utils.py +654 -0
  38. modal-0.73.34/modal/_utils/grpc_testing.py +222 -0
  39. modal-0.73.34/modal/_utils/grpc_utils.py +233 -0
  40. modal-0.73.34/modal/_utils/hash_utils.py +100 -0
  41. modal-0.73.34/modal/_utils/http_utils.py +74 -0
  42. modal-0.73.34/modal/_utils/logger.py +38 -0
  43. modal-0.73.34/modal/_utils/mount_utils.py +78 -0
  44. modal-0.73.34/modal/_utils/name_utils.py +58 -0
  45. modal-0.73.34/modal/_utils/package_utils.py +61 -0
  46. modal-0.73.34/modal/_utils/pattern_utils.py +205 -0
  47. modal-0.73.34/modal/_utils/rand_pb_testing.py +86 -0
  48. modal-0.73.34/modal/_utils/shell_utils.py +79 -0
  49. modal-0.73.34/modal/_vendor/__init__.py +1 -0
  50. modal-0.73.34/modal/_vendor/a2wsgi_wsgi.py +655 -0
  51. modal-0.73.34/modal/_vendor/cloudpickle.py +1465 -0
  52. modal-0.73.34/modal/_vendor/tblib.py +295 -0
  53. modal-0.73.34/modal/_watcher.py +104 -0
  54. modal-0.73.34/modal/app.py +1042 -0
  55. modal-0.73.34/modal/app.pyi +570 -0
  56. modal-0.73.34/modal/call_graph.py +84 -0
  57. modal-0.73.34/modal/cli/__init__.py +1 -0
  58. modal-0.73.34/modal/cli/_download.py +96 -0
  59. modal-0.73.34/modal/cli/_traceback.py +200 -0
  60. modal-0.73.34/modal/cli/app.py +250 -0
  61. modal-0.73.34/modal/cli/config.py +50 -0
  62. modal-0.73.34/modal/cli/container.py +97 -0
  63. modal-0.73.34/modal/cli/dict.py +128 -0
  64. modal-0.73.34/modal/cli/entry_point.py +119 -0
  65. modal-0.73.34/modal/cli/environment.py +123 -0
  66. modal-0.73.34/modal/cli/import_refs.py +346 -0
  67. modal-0.73.34/modal/cli/launch.py +100 -0
  68. modal-0.73.34/modal/cli/network_file_system.py +233 -0
  69. modal-0.73.34/modal/cli/profile.py +86 -0
  70. modal-0.73.34/modal/cli/programs/__init__.py +1 -0
  71. modal-0.73.34/modal/cli/programs/run_jupyter.py +95 -0
  72. modal-0.73.34/modal/cli/programs/vscode.py +110 -0
  73. modal-0.73.34/modal/cli/queues.py +131 -0
  74. modal-0.73.34/modal/cli/run.py +624 -0
  75. modal-0.73.34/modal/cli/secret.py +113 -0
  76. modal-0.73.34/modal/cli/token.py +61 -0
  77. modal-0.73.34/modal/cli/utils.py +111 -0
  78. modal-0.73.34/modal/cli/volume.py +305 -0
  79. modal-0.73.34/modal/client.py +390 -0
  80. modal-0.73.34/modal/client.pyi +200 -0
  81. modal-0.73.34/modal/cloud_bucket_mount.py +168 -0
  82. modal-0.73.34/modal/cloud_bucket_mount.pyi +51 -0
  83. modal-0.73.34/modal/cls.py +739 -0
  84. modal-0.73.34/modal/cls.pyi +239 -0
  85. modal-0.73.34/modal/config.py +321 -0
  86. modal-0.73.34/modal/container_process.py +177 -0
  87. modal-0.73.34/modal/container_process.pyi +84 -0
  88. modal-0.73.34/modal/dict.py +334 -0
  89. modal-0.73.34/modal/dict.pyi +203 -0
  90. modal-0.73.34/modal/environments.py +177 -0
  91. modal-0.73.34/modal/environments.pyi +96 -0
  92. modal-0.73.34/modal/exception.py +187 -0
  93. modal-0.73.34/modal/experimental.py +105 -0
  94. modal-0.73.34/modal/experimental.pyi +29 -0
  95. modal-0.73.34/modal/extensions/__init__.py +1 -0
  96. modal-0.73.34/modal/extensions/ipython.py +41 -0
  97. modal-0.73.34/modal/file_io.py +537 -0
  98. modal-0.73.34/modal/file_io.pyi +237 -0
  99. modal-0.73.34/modal/file_pattern_matcher.py +194 -0
  100. modal-0.73.34/modal/functions.py +7 -0
  101. modal-0.73.34/modal/functions.pyi +330 -0
  102. modal-0.73.34/modal/gpu.py +222 -0
  103. modal-0.73.34/modal/image.py +2097 -0
  104. modal-0.73.34/modal/image.pyi +630 -0
  105. modal-0.73.34/modal/io_streams.py +434 -0
  106. modal-0.73.34/modal/io_streams.pyi +124 -0
  107. modal-0.73.34/modal/mount.py +859 -0
  108. modal-0.73.34/modal/mount.pyi +313 -0
  109. modal-0.73.34/modal/network_file_system.py +369 -0
  110. modal-0.73.34/modal/network_file_system.pyi +210 -0
  111. modal-0.73.34/modal/object.py +5 -0
  112. modal-0.73.34/modal/object.pyi +135 -0
  113. modal-0.73.34/modal/output.py +64 -0
  114. modal-0.73.34/modal/parallel_map.py +434 -0
  115. modal-0.73.34/modal/parallel_map.pyi +78 -0
  116. modal-0.73.34/modal/partial_function.py +28 -0
  117. modal-0.73.34/modal/partial_function.pyi +115 -0
  118. modal-0.73.34/modal/proxy.py +41 -0
  119. modal-0.73.34/modal/proxy.pyi +12 -0
  120. modal-0.73.34/modal/py.typed +0 -0
  121. modal-0.73.34/modal/queue.py +470 -0
  122. modal-0.73.34/modal/queue.pyi +278 -0
  123. modal-0.73.34/modal/requirements/2023.12.312.txt +20 -0
  124. modal-0.73.34/modal/requirements/2023.12.txt +22 -0
  125. modal-0.73.34/modal/requirements/2024.04.txt +29 -0
  126. modal-0.73.34/modal/requirements/2024.10.txt +16 -0
  127. modal-0.73.34/modal/requirements/README.md +21 -0
  128. modal-0.73.34/modal/requirements/base-images.json +22 -0
  129. modal-0.73.34/modal/retries.py +143 -0
  130. modal-0.73.34/modal/runner.py +650 -0
  131. modal-0.73.34/modal/runner.pyi +153 -0
  132. modal-0.73.34/modal/running_app.py +38 -0
  133. modal-0.73.34/modal/sandbox.py +773 -0
  134. modal-0.73.34/modal/sandbox.pyi +479 -0
  135. modal-0.73.34/modal/schedule.py +94 -0
  136. modal-0.73.34/modal/scheduler_placement.py +44 -0
  137. modal-0.73.34/modal/secret.py +260 -0
  138. modal-0.73.34/modal/secret.pyi +89 -0
  139. modal-0.73.34/modal/serving.py +124 -0
  140. modal-0.73.34/modal/serving.pyi +50 -0
  141. modal-0.73.34/modal/snapshot.py +36 -0
  142. modal-0.73.34/modal/snapshot.pyi +18 -0
  143. modal-0.73.34/modal/stream_type.py +15 -0
  144. modal-0.73.34/modal/token_flow.py +174 -0
  145. modal-0.73.34/modal/token_flow.pyi +57 -0
  146. modal-0.73.34/modal/volume.py +732 -0
  147. modal-0.73.34/modal/volume.pyi +345 -0
  148. modal-0.73.34/modal.egg-info/PKG-INFO +55 -0
  149. modal-0.73.34/modal.egg-info/SOURCES.txt +186 -0
  150. modal-0.73.34/modal.egg-info/dependency_links.txt +1 -0
  151. modal-0.73.34/modal.egg-info/entry_points.txt +2 -0
  152. modal-0.73.34/modal.egg-info/requires.txt +14 -0
  153. modal-0.73.34/modal.egg-info/top_level.txt +5 -0
  154. modal-0.73.34/modal_docs/__init__.py +1 -0
  155. modal-0.73.34/modal_docs/gen_cli_docs.py +117 -0
  156. modal-0.73.34/modal_docs/gen_reference_docs.py +193 -0
  157. modal-0.73.34/modal_docs/mdmd/__init__.py +1 -0
  158. modal-0.73.34/modal_docs/mdmd/mdmd.py +195 -0
  159. modal-0.73.34/modal_docs/mdmd/signatures.py +76 -0
  160. modal-0.73.34/modal_global_objects/__init__.py +1 -0
  161. modal-0.73.34/modal_global_objects/images/__init__.py +1 -0
  162. modal-0.73.34/modal_global_objects/images/base_images.py +28 -0
  163. modal-0.73.34/modal_global_objects/mounts/__init__.py +1 -0
  164. modal-0.73.34/modal_global_objects/mounts/modal_client_package.py +29 -0
  165. modal-0.73.34/modal_global_objects/mounts/python_standalone.py +53 -0
  166. modal-0.73.34/modal_proto/__init__.py +1 -0
  167. modal-0.73.34/modal_proto/api.proto +3077 -0
  168. modal-0.73.34/modal_proto/api_grpc.py +2300 -0
  169. modal-0.73.34/modal_proto/api_pb2.py +4248 -0
  170. modal-0.73.34/modal_proto/api_pb2.pyi +9367 -0
  171. modal-0.73.34/modal_proto/api_pb2_grpc.py +4746 -0
  172. modal-0.73.34/modal_proto/api_pb2_grpc.pyi +1488 -0
  173. modal-0.73.34/modal_proto/modal_api_grpc.py +156 -0
  174. modal-0.73.34/modal_proto/modal_options_grpc.py +3 -0
  175. modal-0.73.34/modal_proto/options.proto +17 -0
  176. modal-0.73.34/modal_proto/options_grpc.py +3 -0
  177. modal-0.73.34/modal_proto/options_pb2.py +34 -0
  178. modal-0.73.34/modal_proto/options_pb2.pyi +20 -0
  179. modal-0.73.34/modal_proto/options_pb2_grpc.py +4 -0
  180. modal-0.73.34/modal_proto/options_pb2_grpc.pyi +7 -0
  181. modal-0.73.34/modal_proto/py.typed +0 -0
  182. modal-0.73.34/modal_version/__init__.py +13 -0
  183. modal-0.73.34/modal_version/__main__.py +5 -0
  184. modal-0.73.34/modal_version/_version_generated.py +4 -0
  185. modal-0.73.34/pyproject.toml +65 -0
  186. modal-0.73.34/setup.cfg +62 -0
  187. modal-0.73.34/setup.py +18 -0
modal-0.73.34/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
modal-0.73.34/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.1
2
+ Name: modal
3
+ Version: 0.73.34
4
+ Summary: Python client library for Modal
5
+ Author: Modal Labs
6
+ Author-email: support@modal.com
7
+ Project-URL: Homepage, https://modal.com
8
+ Project-URL: Source, https://github.com/modal-labs/modal-client
9
+ Keywords: modal,client,cloud,serverless,infrastructure
10
+ Classifier: Topic :: System :: Distributed Computing
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ # Modal Python Library
19
+
20
+ [![PyPI Version](https://img.shields.io/pypi/v/modal.svg)](https://pypi.org/project/modal/)
21
+ [![License](https://img.shields.io/badge/license-apache_2.0-darkviolet.svg)](https://github.com/modal-labs/modal-client/blob/master/LICENSE)
22
+ [![Tests](https://github.com/modal-labs/modal-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/modal-labs/modal-client/actions/workflows/ci-cd.yml)
23
+ [![Slack](https://img.shields.io/badge/slack-join-blue.svg?logo=slack)](https://modal.com/slack)
24
+
25
+ The [Modal](https://modal.com/) Python library provides convenient, on-demand
26
+ access to serverless cloud compute from Python scripts on your local computer.
27
+
28
+ ## Documentation
29
+
30
+ See the [online documentation](https://modal.com/docs/guide) for many
31
+ [example applications](https://modal.com/docs/examples),
32
+ a [user guide](https://modal.com/docs/guide), and the detailed
33
+ [API reference](https://modal.com/docs/reference).
34
+
35
+ ## Installation
36
+
37
+ **This library requires Python 3.9 – 3.13.**
38
+
39
+ Install the package with `pip`:
40
+
41
+ ```bash
42
+ pip install modal
43
+ ```
44
+
45
+ You can create a Modal account (or link your existing one) directly on the
46
+ command line:
47
+
48
+ ```bash
49
+ python3 -m modal setup
50
+ ```
51
+
52
+ ## Support
53
+
54
+ For usage questions and other support, please reach out on the
55
+ [Modal Slack](https://modal.com/slack).
@@ -0,0 +1,38 @@
1
+ # Modal Python Library
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/modal.svg)](https://pypi.org/project/modal/)
4
+ [![License](https://img.shields.io/badge/license-apache_2.0-darkviolet.svg)](https://github.com/modal-labs/modal-client/blob/master/LICENSE)
5
+ [![Tests](https://github.com/modal-labs/modal-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/modal-labs/modal-client/actions/workflows/ci-cd.yml)
6
+ [![Slack](https://img.shields.io/badge/slack-join-blue.svg?logo=slack)](https://modal.com/slack)
7
+
8
+ The [Modal](https://modal.com/) Python library provides convenient, on-demand
9
+ access to serverless cloud compute from Python scripts on your local computer.
10
+
11
+ ## Documentation
12
+
13
+ See the [online documentation](https://modal.com/docs/guide) for many
14
+ [example applications](https://modal.com/docs/examples),
15
+ a [user guide](https://modal.com/docs/guide), and the detailed
16
+ [API reference](https://modal.com/docs/reference).
17
+
18
+ ## Installation
19
+
20
+ **This library requires Python 3.9 – 3.13.**
21
+
22
+ Install the package with `pip`:
23
+
24
+ ```bash
25
+ pip install modal
26
+ ```
27
+
28
+ You can create a Modal account (or link your existing one) directly on the
29
+ command line:
30
+
31
+ ```bash
32
+ python3 -m modal setup
33
+ ```
34
+
35
+ ## Support
36
+
37
+ For usage questions and other support, please reach out on the
38
+ [Modal Slack](https://modal.com/slack).
@@ -0,0 +1,86 @@
1
+ # Copyright Modal Labs 2022
2
+ import sys
3
+
4
+ if sys.version_info[:2] < (3, 9):
5
+ raise RuntimeError("This version of Modal requires at least Python 3.9")
6
+ if sys.version_info[:2] >= (3, 14):
7
+ raise RuntimeError("This version of Modal does not support Python 3.14+")
8
+
9
+ from modal_version import __version__
10
+
11
+ try:
12
+ from ._runtime.execution_context import current_function_call_id, current_input_id, interact, is_local
13
+ from ._tunnel import Tunnel, forward
14
+ from .app import App, Stub
15
+ from .client import Client
16
+ from .cloud_bucket_mount import CloudBucketMount
17
+ from .cls import Cls, parameter
18
+ from .dict import Dict
19
+ from .exception import Error
20
+ from .file_pattern_matcher import FilePatternMatcher
21
+ from .functions import Function
22
+ from .image import Image
23
+ from .mount import Mount
24
+ from .network_file_system import NetworkFileSystem
25
+ from .output import enable_output
26
+ from .partial_function import asgi_app, batched, build, enter, exit, method, web_endpoint, web_server, wsgi_app
27
+ from .proxy import Proxy
28
+ from .queue import Queue
29
+ from .retries import Retries
30
+ from .sandbox import Sandbox
31
+ from .schedule import Cron, Period
32
+ from .scheduler_placement import SchedulerPlacement
33
+ from .secret import Secret
34
+ from .snapshot import SandboxSnapshot
35
+ from .volume import Volume
36
+ except Exception:
37
+ print()
38
+ print("#" * 80)
39
+ print("#" + "Something with the Modal installation seems broken.".center(78) + "#")
40
+ print("#" + "Please email support@modal.com and we will try to help!".center(78) + "#")
41
+ print("#" * 80)
42
+ print()
43
+ raise
44
+
45
+ __all__ = [
46
+ "__version__",
47
+ "App",
48
+ "Client",
49
+ "Cls",
50
+ "Cron",
51
+ "Dict",
52
+ "Error",
53
+ "FilePatternMatcher",
54
+ "Function",
55
+ "Image",
56
+ "Mount",
57
+ "NetworkFileSystem",
58
+ "Period",
59
+ "Proxy",
60
+ "Queue",
61
+ "Retries",
62
+ "CloudBucketMount",
63
+ "Sandbox",
64
+ "SandboxSnapshot",
65
+ "SchedulerPlacement",
66
+ "Secret",
67
+ "Stub",
68
+ "Tunnel",
69
+ "Volume",
70
+ "asgi_app",
71
+ "batched",
72
+ "build",
73
+ "current_function_call_id",
74
+ "current_input_id",
75
+ "enable_output",
76
+ "enter",
77
+ "exit",
78
+ "forward",
79
+ "is_local",
80
+ "interact",
81
+ "method",
82
+ "parameter",
83
+ "web_endpoint",
84
+ "web_server",
85
+ "wsgi_app",
86
+ ]
@@ -0,0 +1,78 @@
1
+ # Copyright Modal Labs 2022
2
+ import sys
3
+
4
+ from ._traceback import reduce_traceback_to_user_code
5
+ from .cli._traceback import highlight_modal_deprecation_warnings, setup_rich_traceback
6
+ from .cli.entry_point import entrypoint_cli
7
+ from .cli.import_refs import _CliUserExecutionError
8
+ from .config import config
9
+
10
+
11
+ def main():
12
+ # Setup rich tracebacks, but only on user's end, when using the Modal CLI.
13
+ setup_rich_traceback()
14
+ highlight_modal_deprecation_warnings()
15
+
16
+ try:
17
+ entrypoint_cli()
18
+
19
+ except _CliUserExecutionError as exc:
20
+ if config.get("traceback"):
21
+ raise
22
+
23
+ assert exc.__cause__ # We should always raise this class from another error
24
+ tb = reduce_traceback_to_user_code(exc.__cause__.__traceback__, exc.user_source)
25
+ sys.excepthook(type(exc.__cause__), exc.__cause__, tb)
26
+ sys.exit(1)
27
+
28
+ except Exception as exc:
29
+ if (
30
+ # User has asked to alway see full tracebacks
31
+ config.get("traceback")
32
+ # The exception message is empty, so we need to provide _some_ actionable information
33
+ or not str(exc)
34
+ ):
35
+ raise
36
+
37
+ from grpclib import GRPCError, Status
38
+ from rich.console import Console
39
+ from rich.panel import Panel
40
+ from rich.text import Text
41
+
42
+ if isinstance(exc, GRPCError):
43
+ status_map = {
44
+ Status.ABORTED: "Aborted",
45
+ Status.ALREADY_EXISTS: "Already exists",
46
+ Status.CANCELLED: "Cancelled",
47
+ Status.DATA_LOSS: "Data loss",
48
+ Status.DEADLINE_EXCEEDED: "Deadline exceeded",
49
+ Status.FAILED_PRECONDITION: "Failed precondition",
50
+ Status.INTERNAL: "Internal",
51
+ Status.INVALID_ARGUMENT: "Invalid",
52
+ Status.NOT_FOUND: "Not found",
53
+ Status.OUT_OF_RANGE: "Out of range",
54
+ Status.PERMISSION_DENIED: "Permission denied",
55
+ Status.RESOURCE_EXHAUSTED: "Resource exhausted",
56
+ Status.UNAUTHENTICATED: "Unauthenticaed",
57
+ Status.UNAVAILABLE: "Unavailable",
58
+ Status.UNIMPLEMENTED: "Unimplemented",
59
+ Status.UNKNOWN: "Unknown",
60
+ }
61
+ title = f"Error: {status_map.get(exc.status, 'Unknown')}"
62
+ content = str(exc.message)
63
+ if exc.details:
64
+ content += f"\n\nDetails: {exc.details}"
65
+ else:
66
+ title = "Error"
67
+ content = str(exc)
68
+ if notes := getattr(exc, "__notes__", []):
69
+ content = f"{content}\n\nNote: {' '.join(notes)}"
70
+
71
+ console = Console(stderr=True)
72
+ panel = Panel(Text(content), title=title, title_align="left", border_style="red")
73
+ console.print(panel, highlight=False)
74
+ sys.exit(1)
75
+
76
+
77
+ if __name__ == "__main__":
78
+ main()
@@ -0,0 +1,80 @@
1
+ # Copyright Modal Labs 2024
2
+ import os
3
+ import socket
4
+ from dataclasses import dataclass
5
+ from typing import Optional
6
+
7
+ from modal._utils.async_utils import synchronize_api
8
+ from modal._utils.grpc_utils import retry_transient_errors
9
+ from modal.client import _Client
10
+ from modal.exception import InvalidError
11
+ from modal_proto import api_pb2
12
+
13
+
14
+ @dataclass
15
+ class ClusterInfo:
16
+ rank: int
17
+ container_ips: list[str]
18
+
19
+
20
+ cluster_info: Optional[ClusterInfo] = None
21
+
22
+
23
+ def get_cluster_info() -> ClusterInfo:
24
+ if cluster_info is None:
25
+ raise InvalidError(
26
+ "Cluster info not initialized. Please ensure that you are "
27
+ "calling get_cluster_info() from a clustered function."
28
+ )
29
+ return cluster_info
30
+
31
+
32
+ async def _initialize_clustered_function(client: _Client, task_id: str, world_size: int):
33
+ global cluster_info
34
+
35
+ def get_i6pn():
36
+ """Returns the ipv6 address assigned to this container."""
37
+ return socket.getaddrinfo("i6pn.modal.local", None, socket.AF_INET6)[0][4][0]
38
+
39
+ hostname = socket.gethostname()
40
+ container_ip = get_i6pn()
41
+
42
+ # nccl's default host ID is $(hostname)$(cat /proc/sys/kernel/random/boot_id).
43
+ # on runc, if two i6pn-linked containers get scheduled on the same worker,
44
+ # their boot ID and hostname will both be identical, causing nccl to break.
45
+ # As a workaround, we can explicitly specify a unique host ID here.
46
+ # See MOD-4067.
47
+ os.environ["NCCL_HOSTID"] = f"{hostname}{container_ip}"
48
+
49
+ # We found these settings to work well in most cases. You may be able to achieve
50
+ # better performance by tuning these settings.
51
+ if os.environ["MODAL_CLOUD_PROVIDER"] in ("CLOUD_PROVIDER_GCP", "CLOUD_PROVIDER_OCI"):
52
+ os.environ["NCCL_SOCKET_NTHREADS"] = "4"
53
+ os.environ["NCCL_NSOCKS_PERTHREAD"] = "1"
54
+ elif os.environ["MODAL_CLOUD_PROVIDER"] == "CLOUD_PROVIDER_AWS":
55
+ os.environ["NCCL_SOCKET_NTHREADS"] = "2"
56
+ os.environ["NCCL_NSOCKS_PERTHREAD"] = "8"
57
+ else:
58
+ os.environ["NCCL_SOCKET_NTHREADS"] = "1"
59
+ os.environ["NCCL_NSOCKS_PERTHREAD"] = "1"
60
+
61
+ if world_size > 1:
62
+ resp: api_pb2.TaskClusterHelloResponse = await retry_transient_errors(
63
+ client.stub.TaskClusterHello,
64
+ api_pb2.TaskClusterHelloRequest(
65
+ task_id=task_id,
66
+ container_ip=container_ip,
67
+ ),
68
+ )
69
+ cluster_info = ClusterInfo(
70
+ rank=resp.cluster_rank,
71
+ container_ips=resp.container_ips,
72
+ )
73
+ else:
74
+ cluster_info = ClusterInfo(
75
+ rank=0,
76
+ container_ips=[container_ip],
77
+ )
78
+
79
+
80
+ initialize_clustered_function = synchronize_api(_initialize_clustered_function)
@@ -0,0 +1,22 @@
1
+ import modal.client
2
+ import typing
3
+ import typing_extensions
4
+
5
+ class ClusterInfo:
6
+ rank: int
7
+ container_ips: list[str]
8
+
9
+ def __init__(self, rank: int, container_ips: list[str]) -> None: ...
10
+ def __repr__(self): ...
11
+ def __eq__(self, other): ...
12
+
13
+ def get_cluster_info() -> ClusterInfo: ...
14
+ async def _initialize_clustered_function(client: modal.client._Client, task_id: str, world_size: int): ...
15
+
16
+ class __initialize_clustered_function_spec(typing_extensions.Protocol):
17
+ def __call__(self, client: modal.client.Client, task_id: str, world_size: int): ...
18
+ async def aio(self, client: modal.client.Client, task_id: str, world_size: int): ...
19
+
20
+ initialize_clustered_function: __initialize_clustered_function_spec
21
+
22
+ cluster_info: typing.Optional[ClusterInfo]