truss 0.11.1rc6__py3-none-any.whl → 0.11.1rc8__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.

Potentially problematic release.


This version of truss might be problematic. Click here for more details.

@@ -11,7 +11,8 @@ from starlette.requests import ClientDisconnect, Request
11
11
  from starlette.responses import Response
12
12
  from starlette.websockets import WebSocketDisconnect as StartletteWebSocketDisconnect
13
13
  from tenacity import RetryCallState, Retrying, retry_if_exception_type, wait_fixed
14
- from wsproto.events import BytesMessage, TextMessage
14
+ from wsproto.connection import ConnectionState
15
+ from wsproto.events import BytesMessage, CloseConnection, TextMessage
15
16
 
16
17
  from truss.templates.control.control.helpers.errors import (
17
18
  ModelLoadFailed,
@@ -158,7 +159,13 @@ async def forward_to_server(
158
159
  async def forward_to_client(client_ws: WebSocket, server_ws: AsyncWebSocketSession):
159
160
  while True:
160
161
  message = await server_ws.receive()
161
- if isinstance(message, TextMessage):
162
+ if isinstance(message, CloseConnection):
163
+ # NB(nikhil): httpx requires explicit confirmation of the close frame.
164
+ if server_ws.connection.state == ConnectionState.REMOTE_CLOSING:
165
+ await server_ws.send(message.response()) # type: ignore[arg-type]
166
+
167
+ raise WebSocketDisconnect(code=message.code, reason=message.reason)
168
+ elif isinstance(message, TextMessage):
162
169
  await client_ws.send_text(message.data)
163
170
  elif isinstance(message, BytesMessage):
164
171
  await client_ws.send_bytes(message.data)
@@ -6,7 +6,7 @@ loguru>=0.7.2
6
6
  python-json-logger>=2.0.2
7
7
  tenacity>=8.1.0
8
8
  # To avoid divergence, this should follow the latest release.
9
- truss==0.11.1rc6
9
+ truss==0.11.1rc7
10
10
  uvicorn>=0.24.0
11
11
  uvloop>=0.19.0
12
12
  websockets>=10.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: truss
3
- Version: 0.11.1rc6
3
+ Version: 0.11.1rc8
4
4
  Summary: A seamless bridge from model development to model delivery
5
5
  Project-URL: Repository, https://github.com/basetenlabs/truss
6
6
  Project-URL: Homepage, https://truss.baseten.co
@@ -72,9 +72,9 @@ truss/templates/cache_requirements.txt,sha256=xoPoJ-OVnf1z6oq_RVM3vCr3ionByyqMLj
72
72
  truss/templates/copy_cache_files.Dockerfile.jinja,sha256=Os5zFdYLZ_AfCRGq4RcpVTObOTwL7zvmwYcvOzd_Zqo,126
73
73
  truss/templates/docker_server_requirements.txt,sha256=PyhOPKAmKW1N2vLvTfLMwsEtuGpoRrbWuNo7tT6v2Mc,18
74
74
  truss/templates/server.Dockerfile.jinja,sha256=CUYnF_hgxPGq2re7__0UPWlwzOHMoFkxp6NVKi3U16s,7071
75
- truss/templates/control/requirements.txt,sha256=MiVoU5n8GTj5ygN-iL6neTD1AIqhVYIaJAHkcnsHGvA,253
75
+ truss/templates/control/requirements.txt,sha256=Mgqjo6vKoDS-mJNKx0V3UUDspYnB-Y6ti0VTee7n99k,253
76
76
  truss/templates/control/control/application.py,sha256=jYeta6hWe1SkfLL3W4IDmdYjg3ZuKqI_UagWYs5RB_E,3793
77
- truss/templates/control/control/endpoints.py,sha256=VQ1lvZjFvR091yRkiFdvXw1Q7PiNGXT9rJwY7_sX6yg,11828
77
+ truss/templates/control/control/endpoints.py,sha256=hW1fw19tPLNPV9cW1Jio4tt-uvCbJDUxDdNe7vcvNe4,12267
78
78
  truss/templates/control/control/server.py,sha256=R4Y219i1dcz0kkksN8obLoX-YXWGo9iW1igindyG50c,3128
79
79
  truss/templates/control/control/helpers/context_managers.py,sha256=W6dyFgLBhPa5meqrOb3w_phMtKfaJI-GhwUfpiycDc8,413
80
80
  truss/templates/control/control/helpers/custom_types.py,sha256=n_lTudtLTpy4oPV3aDdJ4X2rh3KCV5btYO9UnTeUouQ,5471
@@ -361,14 +361,14 @@ truss_chains/reference_code/reference_model.py,sha256=emH3hb23E_nbP98I37PGp1Xk1h
361
361
  truss_chains/remote_chainlet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
362
362
  truss_chains/remote_chainlet/model_skeleton.py,sha256=8ZReLOO2MLcdg7bNZ61C-6j-e68i2Z-fFlyV3sz0qH8,2376
363
363
  truss_chains/remote_chainlet/stub.py,sha256=Y2gDUzMY9WRaQNHIz-o4dfLUfFyYV9dUhIRQcfgrY8g,17209
364
- truss_chains/remote_chainlet/utils.py,sha256=RJ74JeB_jzq0wjzxkkVrcnoh_fdWhiq5-FtZTYQdgyQ,23260
364
+ truss_chains/remote_chainlet/utils.py,sha256=nnJQG3hXIoGghWEGPIAqKfRaueCLgSdwNI2x9B7BSaY,23080
365
365
  truss_train/__init__.py,sha256=7hE6j6-u6UGzCGaNp3CsCN0kAVjBus1Ekups-Bk0fi4,837
366
366
  truss_train/definitions.py,sha256=V985HhY4rdXL10DZxpFEpze9ScxzWErMht4WwaPknGU,6789
367
367
  truss_train/deployment.py,sha256=lWWANSuzBWu2M4oK4qD7n-oVR1JKdmw2Pn5BJQHg-Ck,3074
368
368
  truss_train/loader.py,sha256=0o66EjBaHc2YY4syxxHVR4ordJWs13lNXnKjKq2wq0U,1630
369
369
  truss_train/public_api.py,sha256=9N_NstiUlmBuLUwH_fNG_1x7OhGCytZLNvqKXBlStrM,1220
370
- truss-0.11.1rc6.dist-info/METADATA,sha256=FpPBQ0BmRG8IPSDsYnA7f9Su_I3L0dqTycCIsC7tKv4,6672
371
- truss-0.11.1rc6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
372
- truss-0.11.1rc6.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
373
- truss-0.11.1rc6.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
374
- truss-0.11.1rc6.dist-info/RECORD,,
370
+ truss-0.11.1rc8.dist-info/METADATA,sha256=dd9uyZ92UZODbZliBCxANNIqni-Mnap4kazJA2elp40,6672
371
+ truss-0.11.1rc8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
372
+ truss-0.11.1rc8.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
373
+ truss-0.11.1rc8.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
374
+ truss-0.11.1rc8.dist-info/RECORD,,
@@ -382,20 +382,13 @@ def pydantic_set_field_dict(obj: pydantic.BaseModel) -> dict[str, pydantic.BaseM
382
382
  # Error Propagation Utils. #############################################################
383
383
 
384
384
 
385
- # NB(nikhil): Deployed chainlets have access to FastAPI, but local testing doesn't necessarily
386
- # have that dependency. We have a helpful error message via `utils.make_optional_import_error`
387
- # for those cases.
388
- def _safe_import_fastapi():
385
+ def _handle_exception(exception: Exception) -> NoReturn:
386
+ """Raises `HTTPException` with `RemoteErrorDetail`."""
389
387
  try:
390
- import fastapi # noqa: F401
388
+ import fastapi
391
389
  except ImportError:
392
390
  raise utils.make_optional_import_error("fastapi")
393
391
 
394
-
395
- def _handle_exception(exception: Exception) -> NoReturn:
396
- """Raises `HTTPException` with `RemoteErrorDetail`."""
397
- _safe_import_fastapi()
398
-
399
392
  if hasattr(exception, "__module__"):
400
393
  exception_module_name = exception.__module__
401
394
  else:
@@ -595,7 +588,11 @@ class WebsocketWrapperFastAPI:
595
588
  await self._websocket.close(code=code, reason=reason)
596
589
 
597
590
  async def receive(self) -> Union[str, bytes]:
598
- _safe_import_fastapi()
591
+ try:
592
+ import fastapi
593
+ except ImportError:
594
+ raise utils.make_optional_import_error("fastapi")
595
+
599
596
  message = await self._websocket.receive()
600
597
 
601
598
  if message.get("type") == "websocket.disconnect":