modal 0.67.42__py3-none-any.whl → 0.68.11__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.
Files changed (41) hide show
  1. modal/_container_entrypoint.py +4 -1
  2. modal/_runtime/container_io_manager.py +3 -0
  3. modal/_runtime/user_code_imports.py +4 -2
  4. modal/_traceback.py +16 -2
  5. modal/_utils/function_utils.py +5 -1
  6. modal/_utils/grpc_testing.py +6 -2
  7. modal/_utils/hash_utils.py +14 -2
  8. modal/cli/_traceback.py +11 -4
  9. modal/cli/container.py +16 -5
  10. modal/cli/run.py +23 -21
  11. modal/cli/utils.py +4 -0
  12. modal/client.py +6 -37
  13. modal/client.pyi +2 -6
  14. modal/cls.py +132 -62
  15. modal/cls.pyi +13 -7
  16. modal/container_process.py +10 -3
  17. modal/container_process.pyi +3 -3
  18. modal/exception.py +20 -0
  19. modal/file_io.py +380 -0
  20. modal/file_io.pyi +185 -0
  21. modal/functions.py +33 -11
  22. modal/functions.pyi +11 -9
  23. modal/object.py +4 -2
  24. modal/partial_function.py +14 -10
  25. modal/partial_function.pyi +2 -2
  26. modal/runner.py +19 -7
  27. modal/runner.pyi +11 -4
  28. modal/sandbox.py +50 -3
  29. modal/sandbox.pyi +18 -0
  30. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/METADATA +2 -2
  31. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/RECORD +41 -39
  32. modal_docs/gen_reference_docs.py +1 -0
  33. modal_proto/api.proto +25 -1
  34. modal_proto/api_pb2.py +758 -718
  35. modal_proto/api_pb2.pyi +95 -10
  36. modal_version/__init__.py +1 -1
  37. modal_version/_version_generated.py +1 -1
  38. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/LICENSE +0 -0
  39. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/WHEEL +0 -0
  40. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/entry_points.txt +0 -0
  41. {modal-0.67.42.dist-info → modal-0.68.11.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@ from modal._runtime.user_code_imports import Service, import_class_service, impo
6
6
 
7
7
  telemetry_socket = os.environ.get("MODAL_TELEMETRY_SOCKET")
8
8
  if telemetry_socket:
9
- from runtime._telemetry import instrument_imports
9
+ from ._runtime.telemetry import instrument_imports
10
10
 
11
11
  instrument_imports(telemetry_socket)
12
12
 
@@ -415,6 +415,9 @@ def main(container_args: api_pb2.ContainerArguments, client: Client):
415
415
 
416
416
  _client: _Client = synchronizer._translate_in(client) # TODO(erikbern): ugly
417
417
 
418
+ # Call ContainerHello - currently a noop but might be used later for things
419
+ container_io_manager.hello()
420
+
418
421
  with container_io_manager.heartbeats(is_snapshotting_function), UserCodeEventLoop() as event_loop:
419
422
  # If this is a serialized function, fetch the definition from the server
420
423
  if function_def.definition_type == api_pb2.Function.DEFINITION_TYPE_SERIALIZED:
@@ -335,6 +335,9 @@ class _ContainerIOManager:
335
335
  """Only used for tests."""
336
336
  cls._singleton = None
337
337
 
338
+ async def hello(self):
339
+ await self._client.stub.ContainerHello(Empty())
340
+
338
341
  async def _run_heartbeat_loop(self):
339
342
  while 1:
340
343
  t0 = time.monotonic()
@@ -269,10 +269,12 @@ def import_single_function_service(
269
269
  # The cls decorator is in global scope
270
270
  _cls = synchronizer._translate_in(cls)
271
271
  user_defined_callable = _cls._callables[fun_name]
272
- function = _cls._method_functions.get(fun_name)
272
+ function = _cls._method_functions.get(
273
+ fun_name
274
+ ) # bound to the class service function - there is no instance
273
275
  active_app = _cls._app
274
276
  else:
275
- # This is a raw class
277
+ # This is non-decorated class
276
278
  user_defined_callable = getattr(cls, fun_name)
277
279
  else:
278
280
  raise InvalidError(f"Invalid function qualname {qual_name}")
modal/_traceback.py CHANGED
@@ -1,16 +1,21 @@
1
1
  # Copyright Modal Labs 2022
2
- """Helper functions related to operating on traceback objects.
2
+ """Helper functions related to operating on exceptions, warnings, and traceback objects.
3
3
 
4
4
  Functions related to *displaying* tracebacks should go in `modal/cli/_traceback.py`
5
5
  so that Rich is not a dependency of the container Client.
6
6
  """
7
+
7
8
  import re
8
9
  import sys
9
10
  import traceback
11
+ import warnings
10
12
  from types import TracebackType
11
- from typing import Any, Optional
13
+ from typing import Any, Iterable, Optional
14
+
15
+ from modal_proto import api_pb2
12
16
 
13
17
  from ._vendor.tblib import Traceback as TBLibTraceback
18
+ from .exception import ServerWarning
14
19
 
15
20
  TBDictType = dict[str, Any]
16
21
  LineCacheType = dict[tuple[str, str], str]
@@ -109,3 +114,12 @@ def print_exception(exc: Optional[type[BaseException]], value: Optional[BaseExce
109
114
  if sys.version_info < (3, 11) and value is not None:
110
115
  notes = getattr(value, "__notes__", [])
111
116
  print(*notes, sep="\n", file=sys.stderr)
117
+
118
+
119
+ def print_server_warnings(server_warnings: Iterable[api_pb2.Warning]):
120
+ """Issue a warning originating from the server with empty metadata about local origin.
121
+
122
+ When using the Modal CLI, these warnings should get caught and coerced into Rich panels.
123
+ """
124
+ for warning in server_warnings:
125
+ warnings.warn_explicit(warning.message, ServerWarning, "<modal-server>", 0)
@@ -99,7 +99,11 @@ def get_function_type(is_generator: Optional[bool]) -> "api_pb2.Function.Functio
99
99
 
100
100
 
101
101
  class FunctionInfo:
102
- """Class that helps us extract a bunch of information about a function."""
102
+ """Class that helps us extract a bunch of information about a locally defined function.
103
+
104
+ Used for populating the definition of a remote function, and for making .local() calls
105
+ on a host with the local definition available.
106
+ """
103
107
 
104
108
  raw_f: Optional[Callable[..., Any]] # if None - this is a "class service function"
105
109
  function_name: str
@@ -50,7 +50,7 @@ def patch_mock_servicer(cls):
50
50
 
51
51
  @contextlib.contextmanager
52
52
  def intercept(servicer):
53
- ctx = InterceptionContext()
53
+ ctx = InterceptionContext(servicer)
54
54
  servicer.interception_context = ctx
55
55
  yield ctx
56
56
  ctx._assert_responses_consumed()
@@ -101,7 +101,8 @@ class ResponseNotConsumed(Exception):
101
101
 
102
102
 
103
103
  class InterceptionContext:
104
- def __init__(self):
104
+ def __init__(self, servicer):
105
+ self._servicer = servicer
105
106
  self.calls: list[tuple[str, Any]] = [] # List[Tuple[method_name, message]]
106
107
  self.custom_responses: dict[str, list[tuple[Callable[[Any], bool], list[Any]]]] = defaultdict(list)
107
108
  self.custom_defaults: dict[str, Callable[["MockClientServicer", grpclib.server.Stream], Awaitable[None]]] = {}
@@ -149,6 +150,9 @@ class InterceptionContext:
149
150
  raise KeyError(f"No message of that type in call list: {self.calls}")
150
151
 
151
152
  def get_requests(self, method_name: str) -> list[Any]:
153
+ if not hasattr(self._servicer, method_name):
154
+ # we check this to prevent things like `assert ctx.get_requests("ASdfFunctionCreate") == 0` passing
155
+ raise ValueError(f"{method_name} not in MockServicer - did you spell it right?")
152
156
  return [msg for _method_name, msg in self.calls if _method_name == method_name]
153
157
 
154
158
  def _add_recv(self, method_name: str, msg):
@@ -2,9 +2,12 @@
2
2
  import base64
3
3
  import dataclasses
4
4
  import hashlib
5
+ import time
5
6
  from typing import BinaryIO, Callable, Union
6
7
 
7
- HASH_CHUNK_SIZE = 4096
8
+ from modal.config import logger
9
+
10
+ HASH_CHUNK_SIZE = 65536
8
11
 
9
12
 
10
13
  def _update(hashers: list[Callable[[bytes], None]], data: Union[bytes, BinaryIO]) -> None:
@@ -26,20 +29,26 @@ def _update(hashers: list[Callable[[bytes], None]], data: Union[bytes, BinaryIO]
26
29
 
27
30
 
28
31
  def get_sha256_hex(data: Union[bytes, BinaryIO]) -> str:
32
+ t0 = time.monotonic()
29
33
  hasher = hashlib.sha256()
30
34
  _update([hasher.update], data)
35
+ logger.debug("get_sha256_hex took %.3fs", time.monotonic() - t0)
31
36
  return hasher.hexdigest()
32
37
 
33
38
 
34
39
  def get_sha256_base64(data: Union[bytes, BinaryIO]) -> str:
40
+ t0 = time.monotonic()
35
41
  hasher = hashlib.sha256()
36
42
  _update([hasher.update], data)
43
+ logger.debug("get_sha256_base64 took %.3fs", time.monotonic() - t0)
37
44
  return base64.b64encode(hasher.digest()).decode("ascii")
38
45
 
39
46
 
40
47
  def get_md5_base64(data: Union[bytes, BinaryIO]) -> str:
48
+ t0 = time.monotonic()
41
49
  hasher = hashlib.md5()
42
50
  _update([hasher.update], data)
51
+ logger.debug("get_md5_base64 took %.3fs", time.monotonic() - t0)
43
52
  return base64.b64encode(hasher.digest()).decode("utf-8")
44
53
 
45
54
 
@@ -50,10 +59,13 @@ class UploadHashes:
50
59
 
51
60
 
52
61
  def get_upload_hashes(data: Union[bytes, BinaryIO]) -> UploadHashes:
62
+ t0 = time.monotonic()
53
63
  md5 = hashlib.md5()
54
64
  sha256 = hashlib.sha256()
55
65
  _update([md5.update, sha256.update], data)
56
- return UploadHashes(
66
+ hashes = UploadHashes(
57
67
  md5_base64=base64.b64encode(md5.digest()).decode("ascii"),
58
68
  sha256_base64=base64.b64encode(sha256.digest()).decode("ascii"),
59
69
  )
70
+ logger.debug("get_upload_hashes took %.3fs", time.monotonic() - t0)
71
+ return hashes
modal/cli/_traceback.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # Copyright Modal Labs 2024
2
2
  """Helper functions related to displaying tracebacks in the CLI."""
3
+
3
4
  import functools
4
5
  import re
5
6
  import warnings
@@ -11,7 +12,7 @@ from rich.syntax import Syntax
11
12
  from rich.text import Text
12
13
  from rich.traceback import PathHighlighter, Stack, Traceback, install
13
14
 
14
- from ..exception import DeprecationError, PendingDeprecationError
15
+ from ..exception import DeprecationError, PendingDeprecationError, ServerWarning
15
16
 
16
17
 
17
18
  @group()
@@ -165,7 +166,7 @@ def highlight_modal_deprecation_warnings() -> None:
165
166
  base_showwarning = warnings.showwarning
166
167
 
167
168
  def showwarning(warning, category, filename, lineno, file=None, line=None):
168
- if issubclass(category, (DeprecationError, PendingDeprecationError)):
169
+ if issubclass(category, (DeprecationError, PendingDeprecationError, ServerWarning)):
169
170
  content = str(warning)
170
171
  if re.match(r"^\d{4}-\d{2}-\d{2}", content):
171
172
  date = content[:10]
@@ -180,10 +181,16 @@ def highlight_modal_deprecation_warnings() -> None:
180
181
  except OSError:
181
182
  # e.g., when filename is "<unknown>"; raises FileNotFoundError on posix but OSError on windows
182
183
  pass
184
+ if issubclass(category, ServerWarning):
185
+ title = "Modal Warning"
186
+ else:
187
+ title = "Modal Deprecation Warning"
188
+ if date:
189
+ title += f" ({date})"
183
190
  panel = Panel(
184
191
  message,
185
- style="yellow",
186
- title=f"Modal Deprecation Warning ({date})" if date else "Modal Deprecation Warning",
192
+ border_style="yellow",
193
+ title=title,
187
194
  title_align="left",
188
195
  )
189
196
  Console().print(panel)
modal/cli/container.py CHANGED
@@ -1,5 +1,4 @@
1
1
  # Copyright Modal Labs 2022
2
-
3
2
  from typing import Optional, Union
4
3
 
5
4
  import typer
@@ -8,12 +7,13 @@ from rich.text import Text
8
7
  from modal._pty import get_pty_info
9
8
  from modal._utils.async_utils import synchronizer
10
9
  from modal._utils.grpc_utils import retry_transient_errors
11
- from modal.cli.utils import ENV_OPTION, display_table, stream_app_logs, timestamp_to_local
10
+ from modal.cli.utils import ENV_OPTION, display_table, is_tty, stream_app_logs, timestamp_to_local
12
11
  from modal.client import _Client
13
12
  from modal.config import config
14
13
  from modal.container_process import _ContainerProcess
15
14
  from modal.environments import ensure_env
16
15
  from modal.object import _get_environment_name
16
+ from modal.stream_type import StreamType
17
17
  from modal_proto import api_pb2
18
18
 
19
19
  container_cli = typer.Typer(name="container", help="Manage and connect to running containers.", no_args_is_help=True)
@@ -55,12 +55,19 @@ def logs(container_id: str = typer.Argument(help="Container ID")):
55
55
  @container_cli.command("exec")
56
56
  @synchronizer.create_blocking
57
57
  async def exec(
58
+ pty: Optional[bool] = typer.Option(default=None, help="Run the command using a PTY."),
58
59
  container_id: str = typer.Argument(help="Container ID"),
59
- command: list[str] = typer.Argument(help="A command to run inside the container."),
60
- pty: bool = typer.Option(default=True, help="Run the command using a PTY."),
60
+ command: list[str] = typer.Argument(
61
+ help="A command to run inside the container.\n\n"
62
+ "To pass command-line flags or options, add `--` before the start of your commands. "
63
+ "For example: `modal container exec <id> -- /bin/bash -c 'echo hi'`"
64
+ ),
61
65
  ):
62
66
  """Execute a command in a container."""
63
67
 
68
+ if pty is None:
69
+ pty = is_tty()
70
+
64
71
  client = await _Client.from_env()
65
72
 
66
73
  req = api_pb2.ContainerExecRequest(
@@ -71,7 +78,11 @@ async def exec(
71
78
  )
72
79
  res: api_pb2.ContainerExecResponse = await client.stub.ContainerExec(req)
73
80
 
74
- await _ContainerProcess(res.exec_id, client).attach(pty=pty)
81
+ if pty:
82
+ await _ContainerProcess(res.exec_id, client).attach()
83
+ else:
84
+ # TODO: redirect stderr to its own stream?
85
+ await _ContainerProcess(res.exec_id, client, stdout=StreamType.STDOUT, stderr=StreamType.STDOUT).wait()
75
86
 
76
87
 
77
88
  @container_cli.command("stop")
modal/cli/run.py CHANGED
@@ -13,8 +13,6 @@ from typing import Any, Callable, Optional, get_type_hints
13
13
 
14
14
  import click
15
15
  import typer
16
- from rich.console import Console
17
- from rich.panel import Panel
18
16
  from typing_extensions import TypedDict
19
17
 
20
18
  from .. import Cls
@@ -29,7 +27,7 @@ from ..runner import deploy_app, interactive_shell, run_app
29
27
  from ..serving import serve_app
30
28
  from ..volume import Volume
31
29
  from .import_refs import import_app, import_function
32
- from .utils import ENV_OPTION, ENV_OPTION_HELP, stream_app_logs
30
+ from .utils import ENV_OPTION, ENV_OPTION_HELP, is_tty, stream_app_logs
33
31
 
34
32
 
35
33
  class ParameterMetadata(TypedDict):
@@ -308,11 +306,6 @@ def deploy(
308
306
 
309
307
  with enable_output():
310
308
  res = deploy_app(app, name=name, environment_name=env or "", tag=tag)
311
- if res.warnings:
312
- console = Console()
313
- for warning in res.warnings:
314
- panel = Panel(warning, title="Warning", title_align="left", border_style="yellow")
315
- console.print(panel, highlight=False)
316
309
 
317
310
  if stream_logs:
318
311
  stream_app_logs(app_id=res.app_id, app_logs_url=res.app_logs_url)
@@ -392,40 +385,47 @@ def shell(
392
385
  "Can be a single region or a comma-separated list to choose from (if not using REF)."
393
386
  ),
394
387
  ),
388
+ pty: Optional[bool] = typer.Option(default=None, help="Run the command using a PTY."),
395
389
  ):
396
- """Run an interactive shell inside a Modal container.
390
+ """Run a command or interactive shell inside a Modal container.
397
391
 
398
- **Examples:**
392
+ \b**Examples:**
399
393
 
400
- Start a shell inside the default Debian-based image:
394
+ \bStart an interactive shell inside the default Debian-based image:
401
395
 
402
- ```
396
+ \b```
403
397
  modal shell
404
398
  ```
405
399
 
406
- Start a bash shell using the spec for `my_function` in your App:
400
+ \bStart an interactive shell with the spec for `my_function` in your App
401
+ (uses the same image, volumes, mounts, etc.):
407
402
 
408
- ```
403
+ \b```
409
404
  modal shell hello_world.py::my_function
410
405
  ```
411
406
 
412
- Or, if you're using a [modal.Cls](/docs/reference/modal.Cls), you can refer to a `@modal.method` directly:
407
+ \bOr, if you're using a [modal.Cls](/docs/reference/modal.Cls), you can refer to a `@modal.method` directly:
413
408
 
414
- ```
409
+ \b```
415
410
  modal shell hello_world.py::MyClass.my_method
416
411
  ```
417
412
 
418
413
  Start a `python` shell:
419
414
 
420
- ```
415
+ \b```
421
416
  modal shell hello_world.py --cmd=python
422
417
  ```
418
+
419
+ \bRun a command with your function's spec and pipe the output to a file:
420
+
421
+ \b```
422
+ modal shell hello_world.py -c 'uv pip list' > env.txt
423
+ ```
423
424
  """
424
425
  env = ensure_env(env)
425
426
 
426
- console = Console()
427
- if not console.is_terminal:
428
- raise click.UsageError("`modal shell` can only be run from a terminal.")
427
+ if pty is None:
428
+ pty = is_tty()
429
429
 
430
430
  if platform.system() == "Windows":
431
431
  raise InvalidError("`modal shell` is currently not supported on Windows")
@@ -441,7 +441,7 @@ def shell(
441
441
  ):
442
442
  from .container import exec
443
443
 
444
- exec(container_id=container_or_function, command=shlex.split(cmd), pty=True)
444
+ exec(container_id=container_or_function, command=shlex.split(cmd))
445
445
  return
446
446
 
447
447
  function = import_function(
@@ -461,6 +461,7 @@ def shell(
461
461
  memory=function_spec.memory,
462
462
  volumes=function_spec.volumes,
463
463
  region=function_spec.scheduler_placement.proto.regions if function_spec.scheduler_placement else None,
464
+ pty=pty,
464
465
  )
465
466
  else:
466
467
  modal_image = Image.from_registry(image, add_python=add_python) if image else None
@@ -474,6 +475,7 @@ def shell(
474
475
  cloud=cloud,
475
476
  volumes=volumes,
476
477
  region=region.split(",") if region else [],
478
+ pty=pty,
477
479
  )
478
480
 
479
481
  # NB: invoking under bash makes --cmd a lot more flexible.
modal/cli/utils.py CHANGED
@@ -77,6 +77,10 @@ def _plain(text: Union[Text, str]) -> str:
77
77
  return text.plain if isinstance(text, Text) else text
78
78
 
79
79
 
80
+ def is_tty() -> bool:
81
+ return Console().is_terminal
82
+
83
+
80
84
  def display_table(
81
85
  columns: Sequence[Union[Column, str]],
82
86
  rows: Sequence[Sequence[Union[Text, str]]],
modal/client.py CHANGED
@@ -16,23 +16,21 @@ from typing import (
16
16
  import grpclib.client
17
17
  from google.protobuf import empty_pb2
18
18
  from google.protobuf.message import Message
19
- from grpclib import GRPCError, Status
20
19
  from synchronicity.async_wrap import asynccontextmanager
21
20
 
22
21
  from modal._utils.async_utils import synchronizer
23
22
  from modal_proto import api_grpc, api_pb2, modal_api_grpc
24
23
  from modal_version import __version__
25
24
 
25
+ from ._traceback import print_server_warnings
26
26
  from ._utils import async_utils
27
27
  from ._utils.async_utils import TaskContext, synchronize_api
28
28
  from ._utils.grpc_utils import connect_channel, create_channel, retry_transient_errors
29
29
  from .config import _check_config, _is_remote, config, logger
30
- from .exception import AuthError, ClientClosed, ConnectionError, DeprecationError, VersionError
30
+ from .exception import AuthError, ClientClosed, ConnectionError
31
31
 
32
32
  HEARTBEAT_INTERVAL: float = config.get("heartbeat_interval")
33
33
  HEARTBEAT_TIMEOUT: float = HEARTBEAT_INTERVAL + 0.1
34
- CLIENT_CREATE_ATTEMPT_TIMEOUT: float = 4.0
35
- CLIENT_CREATE_TOTAL_TIMEOUT: float = 15.0
36
34
 
37
35
 
38
36
  def _get_metadata(client_type: int, credentials: Optional[tuple[str, str]], version: str) -> dict[str, str]:
@@ -137,32 +135,11 @@ class _Client:
137
135
  async def hello(self):
138
136
  """Connect to server and retrieve version information; raise appropriate error for various failures."""
139
137
  logger.debug(f"Client ({id(self)}): Starting")
140
- try:
141
- req = empty_pb2.Empty()
142
- resp = await retry_transient_errors(
143
- self.stub.ClientHello,
144
- req,
145
- attempt_timeout=CLIENT_CREATE_ATTEMPT_TIMEOUT,
146
- total_timeout=CLIENT_CREATE_TOTAL_TIMEOUT,
147
- )
148
- if resp.warning:
149
- ALARM_EMOJI = chr(0x1F6A8)
150
- warnings.warn_explicit(f"{ALARM_EMOJI} {resp.warning} {ALARM_EMOJI}", DeprecationError, "<unknown>", 0)
151
- except GRPCError as exc:
152
- if exc.status == Status.FAILED_PRECONDITION:
153
- raise VersionError(
154
- f"The client version ({self.version}) is too old. Please update (pip install --upgrade modal)."
155
- )
156
- else:
157
- raise exc
138
+ resp = await retry_transient_errors(self.stub.ClientHello, empty_pb2.Empty())
139
+ print_server_warnings(resp.server_warnings)
158
140
 
159
141
  async def __aenter__(self):
160
142
  await self._open()
161
- try:
162
- await self.hello()
163
- except BaseException:
164
- await self._close()
165
- raise
166
143
  return self
167
144
 
168
145
  async def __aexit__(self, exc_type, exc, tb):
@@ -178,7 +155,6 @@ class _Client:
178
155
  client = cls(server_url, api_pb2.CLIENT_TYPE_CLIENT, credentials=None)
179
156
  try:
180
157
  await client._open()
181
- # Skip client.hello
182
158
  yield client
183
159
  finally:
184
160
  await client._close()
@@ -229,7 +205,6 @@ class _Client:
229
205
  client = _Client(server_url, client_type, credentials)
230
206
  await client._open()
231
207
  async_utils.on_shutdown(client._close())
232
- await client.hello()
233
208
  cls._client_from_env = client
234
209
  return client
235
210
 
@@ -252,11 +227,6 @@ class _Client:
252
227
  credentials = (token_id, token_secret)
253
228
  client = _Client(server_url, client_type, credentials)
254
229
  await client._open()
255
- try:
256
- await client.hello()
257
- except BaseException:
258
- await client._close()
259
- raise
260
230
  async_utils.on_shutdown(client._close())
261
231
  return client
262
232
 
@@ -265,8 +235,8 @@ class _Client:
265
235
  """mdmd:hidden
266
236
  Check whether can the client can connect to this server with these credentials; raise if not.
267
237
  """
268
- async with cls(server_url, api_pb2.CLIENT_TYPE_CLIENT, credentials):
269
- pass # Will call ClientHello RPC and possibly raise AuthError or ConnectionError
238
+ async with cls(server_url, api_pb2.CLIENT_TYPE_CLIENT, credentials) as client:
239
+ client.hello() # Will call ClientHello RPC and possibly raise AuthError or ConnectionError
270
240
 
271
241
  @classmethod
272
242
  def set_env_client(cls, client: Optional["_Client"]):
@@ -316,7 +286,6 @@ class _Client:
316
286
  self.set_env_client(None)
317
287
  # TODO(elias): reset _cancellation_context in case ?
318
288
  await self._open()
319
- # intentionally not doing self.hello since we should already be authenticated etc.
320
289
 
321
290
  async def _get_grpclib_method(self, method_name: str) -> Any:
322
291
  # safely get grcplib method that is bound to a valid channel
modal/client.pyi CHANGED
@@ -26,7 +26,7 @@ class _Client:
26
26
  _stub: typing.Optional[modal_proto.api_grpc.ModalClientStub]
27
27
 
28
28
  def __init__(
29
- self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.67.42"
29
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.11"
30
30
  ): ...
31
31
  def is_closed(self) -> bool: ...
32
32
  @property
@@ -81,7 +81,7 @@ class Client:
81
81
  _stub: typing.Optional[modal_proto.api_grpc.ModalClientStub]
82
82
 
83
83
  def __init__(
84
- self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.67.42"
84
+ self, server_url: str, client_type: int, credentials: typing.Optional[tuple[str, str]], version: str = "0.68.11"
85
85
  ): ...
86
86
  def is_closed(self) -> bool: ...
87
87
  @property
@@ -194,7 +194,3 @@ class UnaryStreamWrapper(typing.Generic[RequestType, ResponseType]):
194
194
  HEARTBEAT_INTERVAL: float
195
195
 
196
196
  HEARTBEAT_TIMEOUT: float
197
-
198
- CLIENT_CREATE_ATTEMPT_TIMEOUT: float
199
-
200
- CLIENT_CREATE_TOTAL_TIMEOUT: float