|
23 | 23 |
|
24 | 24 | from google.protobuf.message import Message |
25 | 25 | from grpclib.exceptions import GRPCError, StreamTerminatedError |
| 26 | +from typing_extensions import Self |
26 | 27 |
|
27 | 28 | from modal_proto import api_pb2 |
28 | 29 |
|
|
42 | 43 | from .cloud_bucket_mount import _CloudBucketMount |
43 | 44 | from .config import config, logger, user_config_path |
44 | 45 | from .environments import _get_environment_cached |
45 | | -from .exception import InvalidError, NotFoundError, RemoteError, VersionError |
| 46 | +from .exception import ExecutionError, InvalidError, NotFoundError, RemoteError, VersionError |
46 | 47 | from .file_pattern_matcher import NON_PYTHON_FILES, FilePatternMatcher, _ignore_fn |
47 | 48 | from .gpu import GPU_T, parse_gpu_config |
48 | 49 | from .mount import _Mount, python_standalone_mount_name |
@@ -2295,5 +2296,15 @@ async def _logs(self) -> typing.AsyncGenerator[str, None]: |
2295 | 2296 | if task_log.data: |
2296 | 2297 | yield task_log.data |
2297 | 2298 |
|
| 2299 | + async def hydrate(self, client: Optional[_Client] = None) -> Self: |
| 2300 | + """mdmd:hidden""" |
| 2301 | + # Image inherits hydrate() from Object but can't be hydrated on demand |
| 2302 | + # Overriding the method lets us hide it from the docs and raise a better error message |
| 2303 | + if not self.is_hydrated: |
| 2304 | + raise ExecutionError( |
| 2305 | + "Images cannot currently be hydrated on demand; you can build an Image by running an App that uses it." |
| 2306 | + ) |
| 2307 | + return self |
| 2308 | + |
2298 | 2309 |
|
2299 | 2310 | Image = synchronize_api(_Image) |
0 commit comments