truss 0.11.8rc4__py3-none-any.whl → 0.11.8rc6__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.
- truss/templates/control/control/application.py +33 -28
- {truss-0.11.8rc4.dist-info → truss-0.11.8rc6.dist-info}/METADATA +1 -1
- {truss-0.11.8rc4.dist-info → truss-0.11.8rc6.dist-info}/RECORD +6 -6
- {truss-0.11.8rc4.dist-info → truss-0.11.8rc6.dist-info}/WHEEL +0 -0
- {truss-0.11.8rc4.dist-info → truss-0.11.8rc6.dist-info}/entry_points.txt +0 -0
- {truss-0.11.8rc4.dist-info → truss-0.11.8rc6.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,14 +3,13 @@ import logging
|
|
|
3
3
|
import logging.config
|
|
4
4
|
import re
|
|
5
5
|
import traceback
|
|
6
|
-
from functools import wraps
|
|
7
6
|
from pathlib import Path
|
|
8
|
-
from typing import
|
|
7
|
+
from typing import Awaitable, Callable, Dict
|
|
9
8
|
|
|
10
9
|
import httpx
|
|
11
10
|
from endpoints import control_app
|
|
12
|
-
from fastapi import FastAPI, Request
|
|
13
|
-
from fastapi.responses import JSONResponse
|
|
11
|
+
from fastapi import FastAPI, Request, Response
|
|
12
|
+
from fastapi.responses import JSONResponse
|
|
14
13
|
from helpers.errors import ModelLoadFailed, PatchApplicatonError
|
|
15
14
|
from helpers.inference_server_controller import InferenceServerController
|
|
16
15
|
from helpers.inference_server_process_controller import InferenceServerProcessController
|
|
@@ -19,46 +18,52 @@ from helpers.truss_patch.model_container_patch_applier import ModelContainerPatc
|
|
|
19
18
|
from shared import log_config
|
|
20
19
|
from starlette.datastructures import State
|
|
21
20
|
|
|
21
|
+
SANITIZED_EXCEPTION_FRAMES = 2
|
|
22
22
|
|
|
23
|
-
def sanitized_exception_logging(
|
|
24
|
-
original_handler: Callable[[Request, Any], Coroutine[Any, Any, Response]],
|
|
25
|
-
) -> Callable[[Request, Any], Coroutine[Any, Any, Response]]:
|
|
26
|
-
@wraps(original_handler)
|
|
27
|
-
async def wrapper(request: Request, error: Exception) -> Response:
|
|
28
|
-
logger = request.app.state.logger
|
|
29
|
-
traceback_error = traceback.extract_tb(error.__traceback__)
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
def create_sanitized_traceback(error: Exception, num_frames: int) -> str:
|
|
25
|
+
tb_lines = traceback.format_tb(error.__traceback__)
|
|
26
|
+
if tb_lines and num_frames > 0:
|
|
27
|
+
selected_frames = tb_lines[-num_frames:]
|
|
28
|
+
return "".join(selected_frames).rstrip()
|
|
29
|
+
else:
|
|
30
|
+
return f"{type(error).__name__}: {error}"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def sanitize_exception(num_frames=SANITIZED_EXCEPTION_FRAMES):
|
|
34
|
+
def decorator(
|
|
35
|
+
handler_func: Callable[[Request, Exception], Awaitable[Response]],
|
|
36
|
+
) -> Callable[[Request, Exception], Awaitable[Response]]:
|
|
37
|
+
async def wrapper(request: Request, exc: Exception) -> Response:
|
|
38
|
+
sanitized_traceback = create_sanitized_traceback(exc, num_frames)
|
|
39
|
+
if hasattr(request.app.state, "logger"):
|
|
40
|
+
request.app.state.logger.error(sanitized_traceback)
|
|
41
|
+
|
|
42
|
+
return await handler_func(request, exc)
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
return await original_handler(request, error)
|
|
44
|
+
return wrapper
|
|
42
45
|
|
|
43
|
-
return
|
|
46
|
+
return decorator
|
|
44
47
|
|
|
45
48
|
|
|
46
|
-
@
|
|
47
|
-
async def handle_patch_error(
|
|
49
|
+
@sanitize_exception()
|
|
50
|
+
async def handle_patch_error(request, exc):
|
|
48
51
|
error_type = _camel_to_snake_case(type(exc).__name__)
|
|
49
52
|
return JSONResponse(content={"error": {"type": error_type, "msg": str(exc)}})
|
|
50
53
|
|
|
51
54
|
|
|
52
|
-
@
|
|
53
|
-
async def generic_error_handler(
|
|
55
|
+
@sanitize_exception()
|
|
56
|
+
async def generic_error_handler(request, exc):
|
|
57
|
+
print("CALLED GENERIC ========== ")
|
|
54
58
|
return JSONResponse(
|
|
55
59
|
content={"error": {"type": "unknown", "msg": f"{type(exc)}: {exc}"}}
|
|
56
60
|
)
|
|
57
61
|
|
|
58
62
|
|
|
59
|
-
@
|
|
60
|
-
async def handle_model_load_failed(
|
|
63
|
+
@sanitize_exception()
|
|
64
|
+
async def handle_model_load_failed(request, error):
|
|
61
65
|
# Model load failures should result in 503 status
|
|
66
|
+
print("CALLED MODEL LOAD ========== ")
|
|
62
67
|
return JSONResponse({"error": str(error)}, 503)
|
|
63
68
|
|
|
64
69
|
|
|
@@ -73,7 +73,7 @@ truss/templates/copy_cache_files.Dockerfile.jinja,sha256=Os5zFdYLZ_AfCRGq4RcpVTO
|
|
|
73
73
|
truss/templates/docker_server_requirements.txt,sha256=PyhOPKAmKW1N2vLvTfLMwsEtuGpoRrbWuNo7tT6v2Mc,18
|
|
74
74
|
truss/templates/server.Dockerfile.jinja,sha256=CUYnF_hgxPGq2re7__0UPWlwzOHMoFkxp6NVKi3U16s,7071
|
|
75
75
|
truss/templates/control/requirements.txt,sha256=nqqNmlTwFeV8sV4fqwItwzzd_egADBP_e-cEopXBJ4k,358
|
|
76
|
-
truss/templates/control/control/application.py,sha256=
|
|
76
|
+
truss/templates/control/control/application.py,sha256=FuL4DibeWy9ux81B5JhUnXuyu0Ro1t4UnmE-_W89gg4,4967
|
|
77
77
|
truss/templates/control/control/endpoints.py,sha256=VQ1lvZjFvR091yRkiFdvXw1Q7PiNGXT9rJwY7_sX6yg,11828
|
|
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
|
|
@@ -368,8 +368,8 @@ truss_train/deployment.py,sha256=lWWANSuzBWu2M4oK4qD7n-oVR1JKdmw2Pn5BJQHg-Ck,307
|
|
|
368
368
|
truss_train/loader.py,sha256=0o66EjBaHc2YY4syxxHVR4ordJWs13lNXnKjKq2wq0U,1630
|
|
369
369
|
truss_train/public_api.py,sha256=9N_NstiUlmBuLUwH_fNG_1x7OhGCytZLNvqKXBlStrM,1220
|
|
370
370
|
truss_train/restore_from_checkpoint.py,sha256=8hdPm-WSgkt74HDPjvCjZMBpvA9MwtoYsxVjOoa7BaM,1176
|
|
371
|
-
truss-0.11.
|
|
372
|
-
truss-0.11.
|
|
373
|
-
truss-0.11.
|
|
374
|
-
truss-0.11.
|
|
375
|
-
truss-0.11.
|
|
371
|
+
truss-0.11.8rc6.dist-info/METADATA,sha256=d2tJzaGAOT3N68nSAYVF3DmmN4SMdm29LYpmnvkjqmo,6680
|
|
372
|
+
truss-0.11.8rc6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
373
|
+
truss-0.11.8rc6.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
|
|
374
|
+
truss-0.11.8rc6.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
|
|
375
|
+
truss-0.11.8rc6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|