modal 1.0.5.dev2__py3-none-any.whl → 1.0.5.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
modal/mount.pyi CHANGED
@@ -10,8 +10,13 @@ import pathlib
10
10
  import typing
11
11
  import typing_extensions
12
12
 
13
- def client_mount_name() -> str: ...
14
- def python_standalone_mount_name(version: str) -> str: ...
13
+ def client_mount_name() -> str:
14
+ """Get the deployed name of the client package mount."""
15
+ ...
16
+
17
+ def python_standalone_mount_name(version: str) -> str:
18
+ """Get the deployed name of the python-build-standalone mount."""
19
+ ...
15
20
 
16
21
  class _MountEntry:
17
22
  def description(self) -> str: ...
@@ -22,6 +27,8 @@ class _MountEntry:
22
27
  def _select_files(entries: list[_MountEntry]) -> list[tuple[pathlib.Path, pathlib.PurePosixPath]]: ...
23
28
 
24
29
  class _MountFile(_MountEntry):
30
+ """_MountFile(local_file: pathlib.Path, remote_path: pathlib.PurePosixPath)"""
31
+
25
32
  local_file: pathlib.Path
26
33
  remote_path: pathlib.PurePosixPath
27
34
 
@@ -29,11 +36,21 @@ class _MountFile(_MountEntry):
29
36
  def get_files_to_upload(self): ...
30
37
  def watch_entry(self): ...
31
38
  def top_level_paths(self) -> list[tuple[pathlib.Path, pathlib.PurePosixPath]]: ...
32
- def __init__(self, local_file: pathlib.Path, remote_path: pathlib.PurePosixPath) -> None: ...
33
- def __repr__(self): ...
34
- def __eq__(self, other): ...
39
+ def __init__(self, local_file: pathlib.Path, remote_path: pathlib.PurePosixPath) -> None:
40
+ """Initialize self. See help(type(self)) for accurate signature."""
41
+ ...
42
+
43
+ def __repr__(self):
44
+ """Return repr(self)."""
45
+ ...
46
+
47
+ def __eq__(self, other):
48
+ """Return self==value."""
49
+ ...
35
50
 
36
51
  class _MountDir(_MountEntry):
52
+ """_MountDir(local_dir: pathlib.Path, remote_path: pathlib.PurePosixPath, ignore: Callable[[pathlib.Path], bool], recursive: bool)"""
53
+
37
54
  local_dir: pathlib.Path
38
55
  remote_path: pathlib.PurePosixPath
39
56
  ignore: collections.abc.Callable[[pathlib.Path], bool]
@@ -49,14 +66,24 @@ class _MountDir(_MountEntry):
49
66
  remote_path: pathlib.PurePosixPath,
50
67
  ignore: collections.abc.Callable[[pathlib.Path], bool],
51
68
  recursive: bool,
52
- ) -> None: ...
53
- def __repr__(self): ...
54
- def __eq__(self, other): ...
69
+ ) -> None:
70
+ """Initialize self. See help(type(self)) for accurate signature."""
71
+ ...
72
+
73
+ def __repr__(self):
74
+ """Return repr(self)."""
75
+ ...
76
+
77
+ def __eq__(self, other):
78
+ """Return self==value."""
79
+ ...
55
80
 
56
81
  def module_mount_condition(module_base: pathlib.Path): ...
57
82
  def module_mount_ignore_condition(module_base: pathlib.Path): ...
58
83
 
59
84
  class _MountedPythonModule(_MountEntry):
85
+ """_MountedPythonModule(module_name: str, remote_dir: Union[pathlib.PurePosixPath, str] = '/root', ignore: Optional[Callable[[pathlib.Path], bool]] = None)"""
86
+
60
87
  module_name: str
61
88
  remote_dir: typing.Union[pathlib.PurePosixPath, str]
62
89
  ignore: typing.Optional[collections.abc.Callable[[pathlib.Path], bool]]
@@ -71,13 +98,46 @@ class _MountedPythonModule(_MountEntry):
71
98
  module_name: str,
72
99
  remote_dir: typing.Union[pathlib.PurePosixPath, str] = "/root",
73
100
  ignore: typing.Optional[collections.abc.Callable[[pathlib.Path], bool]] = None,
74
- ) -> None: ...
75
- def __repr__(self): ...
76
- def __eq__(self, other): ...
101
+ ) -> None:
102
+ """Initialize self. See help(type(self)) for accurate signature."""
103
+ ...
77
104
 
78
- class NonLocalMountError(Exception): ...
105
+ def __repr__(self):
106
+ """Return repr(self)."""
107
+ ...
108
+
109
+ def __eq__(self, other):
110
+ """Return self==value."""
111
+ ...
112
+
113
+ class NonLocalMountError(Exception):
114
+ """Common base class for all non-exit exceptions."""
115
+
116
+ ...
79
117
 
80
118
  class _Mount(modal._object._Object):
119
+ """**Deprecated**: Mounts should not be used explicitly anymore, use `Image.add_local_*` commands instead.
120
+
121
+ Create a mount for a local directory or file that can be attached
122
+ to one or more Modal functions.
123
+
124
+ **Usage**
125
+
126
+ ```python notest
127
+ import modal
128
+ import os
129
+ app = modal.App()
130
+
131
+ @app.function(mounts=[modal.Mount.from_local_dir("~/foo", remote_path="/root/foo")])
132
+ def f():
133
+ # `/root/foo` has the contents of `~/foo`.
134
+ print(os.listdir("/root/foo/"))
135
+ ```
136
+
137
+ Modal syncs the contents of the local directory every time the app runs, but uses the hash of
138
+ the file's contents to skip uploading files that have been uploaded before.
139
+ """
140
+
81
141
  _entries: typing.Optional[list[_MountEntry]]
82
142
  _deployment_name: typing.Optional[str]
83
143
  _namespace: typing.Optional[int]
@@ -89,10 +149,16 @@ class _Mount(modal._object._Object):
89
149
  def _new(entries: list[_MountEntry] = []) -> _Mount: ...
90
150
  def _extend(self, entry: _MountEntry) -> _Mount: ...
91
151
  @property
92
- def entries(self): ...
152
+ def entries(self):
153
+ """mdmd:hidden"""
154
+ ...
155
+
93
156
  def _hydrate_metadata(self, handle_metadata: typing.Optional[google.protobuf.message.Message]): ...
94
157
  def _top_level_paths(self) -> list[tuple[pathlib.Path, pathlib.PurePosixPath]]: ...
95
- def is_local(self) -> bool: ...
158
+ def is_local(self) -> bool:
159
+ """mdmd:hidden"""
160
+ ...
161
+
96
162
  @staticmethod
97
163
  def _add_local_dir(
98
164
  local_path: pathlib.Path,
@@ -106,7 +172,10 @@ class _Mount(modal._object._Object):
106
172
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
107
173
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
108
174
  recursive: bool = True,
109
- ) -> _Mount: ...
175
+ ) -> _Mount:
176
+ """Add a local directory to the `Mount` object."""
177
+ ...
178
+
110
179
  @staticmethod
111
180
  def from_local_dir(
112
181
  local_path: typing.Union[str, pathlib.Path],
@@ -114,7 +183,23 @@ class _Mount(modal._object._Object):
114
183
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
115
184
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
116
185
  recursive: bool = True,
117
- ) -> _Mount: ...
186
+ ) -> _Mount:
187
+ """**Deprecated:** Use image.add_local_dir() instead
188
+
189
+ Create a `Mount` from a local directory.
190
+
191
+ **Usage**
192
+
193
+ ```python notest
194
+ assets = modal.Mount.from_local_dir(
195
+ "~/assets",
196
+ condition=lambda pth: not ".venv" in pth,
197
+ remote_path="/assets",
198
+ )
199
+ ```
200
+ """
201
+ ...
202
+
118
203
  @staticmethod
119
204
  def _from_local_dir(
120
205
  local_path: typing.Union[str, pathlib.Path],
@@ -127,11 +212,30 @@ class _Mount(modal._object._Object):
127
212
  self,
128
213
  local_path: typing.Union[str, pathlib.Path],
129
214
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
130
- ) -> _Mount: ...
215
+ ) -> _Mount:
216
+ """Add a local file to the `Mount` object."""
217
+ ...
218
+
131
219
  @staticmethod
132
220
  def from_local_file(
133
221
  local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None
134
- ) -> _Mount: ...
222
+ ) -> _Mount:
223
+ """**Deprecated**: Use image.add_local_file() instead
224
+
225
+ Create a `Mount` mounting a single local file.
226
+
227
+ **Usage**
228
+
229
+ ```python notest
230
+ # Mount the DBT profile in user's home directory into container.
231
+ dbt_profiles = modal.Mount.from_local_file(
232
+ local_path="~/profiles.yml",
233
+ remote_path="/root/dbt_profile/profiles.yml",
234
+ )
235
+ ```
236
+ """
237
+ ...
238
+
135
239
  @staticmethod
136
240
  def _from_local_file(
137
241
  local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None
@@ -151,7 +255,30 @@ class _Mount(modal._object._Object):
151
255
  remote_dir: typing.Union[str, pathlib.PurePosixPath] = "/root",
152
256
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
153
257
  ignore: typing.Union[typing.Sequence[str], collections.abc.Callable[[pathlib.Path], bool], None] = None,
154
- ) -> _Mount: ...
258
+ ) -> _Mount:
259
+ """**Deprecated**: Use image.add_local_python_source instead
260
+
261
+ Returns a `modal.Mount` that makes local modules listed in `module_names` available inside the container.
262
+ This works by mounting the local path of each module's package to a directory inside the container
263
+ that's on `PYTHONPATH`.
264
+
265
+ **Usage**
266
+
267
+ ```python notest
268
+ import modal
269
+ import my_local_module
270
+
271
+ app = modal.App()
272
+
273
+ @app.function(mounts=[
274
+ modal.Mount.from_local_python_packages("my_local_module", "my_other_module"),
275
+ ])
276
+ def f():
277
+ my_local_module.do_stuff()
278
+ ```
279
+ """
280
+ ...
281
+
155
282
  @staticmethod
156
283
  def _from_local_python_packages(
157
284
  *module_names: str,
@@ -160,7 +287,10 @@ class _Mount(modal._object._Object):
160
287
  ignore: typing.Union[typing.Sequence[str], collections.abc.Callable[[pathlib.Path], bool], None] = None,
161
288
  ) -> _Mount: ...
162
289
  @staticmethod
163
- def from_name(name: str, *, namespace=1, environment_name: typing.Optional[str] = None) -> _Mount: ...
290
+ def from_name(name: str, *, namespace=1, environment_name: typing.Optional[str] = None) -> _Mount:
291
+ """mdmd:hidden"""
292
+ ...
293
+
164
294
  @classmethod
165
295
  async def lookup(
166
296
  cls: type[_Mount],
@@ -168,7 +298,10 @@ class _Mount(modal._object._Object):
168
298
  namespace=1,
169
299
  client: typing.Optional[modal.client._Client] = None,
170
300
  environment_name: typing.Optional[str] = None,
171
- ) -> _Mount: ...
301
+ ) -> _Mount:
302
+ """mdmd:hidden"""
303
+ ...
304
+
172
305
  async def _deploy(
173
306
  self: _Mount,
174
307
  deployment_name: typing.Optional[str] = None,
@@ -183,6 +316,28 @@ class _Mount(modal._object._Object):
183
316
  SUPERSELF = typing.TypeVar("SUPERSELF", covariant=True)
184
317
 
185
318
  class Mount(modal.object.Object):
319
+ """**Deprecated**: Mounts should not be used explicitly anymore, use `Image.add_local_*` commands instead.
320
+
321
+ Create a mount for a local directory or file that can be attached
322
+ to one or more Modal functions.
323
+
324
+ **Usage**
325
+
326
+ ```python notest
327
+ import modal
328
+ import os
329
+ app = modal.App()
330
+
331
+ @app.function(mounts=[modal.Mount.from_local_dir("~/foo", remote_path="/root/foo")])
332
+ def f():
333
+ # `/root/foo` has the contents of `~/foo`.
334
+ print(os.listdir("/root/foo/"))
335
+ ```
336
+
337
+ Modal syncs the contents of the local directory every time the app runs, but uses the hash of
338
+ the file's contents to skip uploading files that have been uploaded before.
339
+ """
340
+
186
341
  _entries: typing.Optional[list[_MountEntry]]
187
342
  _deployment_name: typing.Optional[str]
188
343
  _namespace: typing.Optional[int]
@@ -190,15 +345,24 @@ class Mount(modal.object.Object):
190
345
  _allow_overwrite: bool
191
346
  _content_checksum_sha256_hex: typing.Optional[str]
192
347
 
193
- def __init__(self, *args, **kwargs): ...
348
+ def __init__(self, *args, **kwargs):
349
+ """mdmd:hidden"""
350
+ ...
351
+
194
352
  @staticmethod
195
353
  def _new(entries: list[_MountEntry] = []) -> Mount: ...
196
354
  def _extend(self, entry: _MountEntry) -> Mount: ...
197
355
  @property
198
- def entries(self): ...
356
+ def entries(self):
357
+ """mdmd:hidden"""
358
+ ...
359
+
199
360
  def _hydrate_metadata(self, handle_metadata: typing.Optional[google.protobuf.message.Message]): ...
200
361
  def _top_level_paths(self) -> list[tuple[pathlib.Path, pathlib.PurePosixPath]]: ...
201
- def is_local(self) -> bool: ...
362
+ def is_local(self) -> bool:
363
+ """mdmd:hidden"""
364
+ ...
365
+
202
366
  @staticmethod
203
367
  def _add_local_dir(
204
368
  local_path: pathlib.Path,
@@ -212,7 +376,10 @@ class Mount(modal.object.Object):
212
376
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
213
377
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
214
378
  recursive: bool = True,
215
- ) -> Mount: ...
379
+ ) -> Mount:
380
+ """Add a local directory to the `Mount` object."""
381
+ ...
382
+
216
383
  @staticmethod
217
384
  def from_local_dir(
218
385
  local_path: typing.Union[str, pathlib.Path],
@@ -220,7 +387,23 @@ class Mount(modal.object.Object):
220
387
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
221
388
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
222
389
  recursive: bool = True,
223
- ) -> Mount: ...
390
+ ) -> Mount:
391
+ """**Deprecated:** Use image.add_local_dir() instead
392
+
393
+ Create a `Mount` from a local directory.
394
+
395
+ **Usage**
396
+
397
+ ```python notest
398
+ assets = modal.Mount.from_local_dir(
399
+ "~/assets",
400
+ condition=lambda pth: not ".venv" in pth,
401
+ remote_path="/assets",
402
+ )
403
+ ```
404
+ """
405
+ ...
406
+
224
407
  @staticmethod
225
408
  def _from_local_dir(
226
409
  local_path: typing.Union[str, pathlib.Path],
@@ -233,11 +416,30 @@ class Mount(modal.object.Object):
233
416
  self,
234
417
  local_path: typing.Union[str, pathlib.Path],
235
418
  remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None,
236
- ) -> Mount: ...
419
+ ) -> Mount:
420
+ """Add a local file to the `Mount` object."""
421
+ ...
422
+
237
423
  @staticmethod
238
424
  def from_local_file(
239
425
  local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None
240
- ) -> Mount: ...
426
+ ) -> Mount:
427
+ """**Deprecated**: Use image.add_local_file() instead
428
+
429
+ Create a `Mount` mounting a single local file.
430
+
431
+ **Usage**
432
+
433
+ ```python notest
434
+ # Mount the DBT profile in user's home directory into container.
435
+ dbt_profiles = modal.Mount.from_local_file(
436
+ local_path="~/profiles.yml",
437
+ remote_path="/root/dbt_profile/profiles.yml",
438
+ )
439
+ ```
440
+ """
441
+ ...
442
+
241
443
  @staticmethod
242
444
  def _from_local_file(
243
445
  local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.PurePosixPath, None] = None
@@ -267,7 +469,30 @@ class Mount(modal.object.Object):
267
469
  remote_dir: typing.Union[str, pathlib.PurePosixPath] = "/root",
268
470
  condition: typing.Optional[collections.abc.Callable[[str], bool]] = None,
269
471
  ignore: typing.Union[typing.Sequence[str], collections.abc.Callable[[pathlib.Path], bool], None] = None,
270
- ) -> Mount: ...
472
+ ) -> Mount:
473
+ """**Deprecated**: Use image.add_local_python_source instead
474
+
475
+ Returns a `modal.Mount` that makes local modules listed in `module_names` available inside the container.
476
+ This works by mounting the local path of each module's package to a directory inside the container
477
+ that's on `PYTHONPATH`.
478
+
479
+ **Usage**
480
+
481
+ ```python notest
482
+ import modal
483
+ import my_local_module
484
+
485
+ app = modal.App()
486
+
487
+ @app.function(mounts=[
488
+ modal.Mount.from_local_python_packages("my_local_module", "my_other_module"),
489
+ ])
490
+ def f():
491
+ my_local_module.do_stuff()
492
+ ```
493
+ """
494
+ ...
495
+
271
496
  @staticmethod
272
497
  def _from_local_python_packages(
273
498
  *module_names: str,
@@ -276,7 +501,10 @@ class Mount(modal.object.Object):
276
501
  ignore: typing.Union[typing.Sequence[str], collections.abc.Callable[[pathlib.Path], bool], None] = None,
277
502
  ) -> Mount: ...
278
503
  @staticmethod
279
- def from_name(name: str, *, namespace=1, environment_name: typing.Optional[str] = None) -> Mount: ...
504
+ def from_name(name: str, *, namespace=1, environment_name: typing.Optional[str] = None) -> Mount:
505
+ """mdmd:hidden"""
506
+ ...
507
+
280
508
  @classmethod
281
509
  def lookup(
282
510
  cls: type[Mount],
@@ -284,7 +512,9 @@ class Mount(modal.object.Object):
284
512
  namespace=1,
285
513
  client: typing.Optional[modal.client.Client] = None,
286
514
  environment_name: typing.Optional[str] = None,
287
- ) -> Mount: ...
515
+ ) -> Mount:
516
+ """mdmd:hidden"""
517
+ ...
288
518
 
289
519
  class ___deploy_spec(typing_extensions.Protocol[SUPERSELF]):
290
520
  def __call__(