-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathupload.py
More file actions
84 lines (65 loc) · 2.53 KB
/
Copy pathupload.py
File metadata and controls
84 lines (65 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
Upload session related exceptions.
"""
from __future__ import annotations
from aiohttp import web
from ai.backend.common.exception import (
BackendAIError,
ErrorCode,
ErrorDetail,
ErrorDomain,
ErrorOperation,
)
class ChunkConflictError(BackendAIError, web.HTTPConflict):
"""
Raised when an incoming chunk targets an offset that already holds a
different chunk in the upload session (409 Conflict).
"""
error_type = "https://api.backend.ai/probs/storage/chunk-conflict"
error_title = "Upload Chunk Conflict"
def error_code(self) -> ErrorCode:
return ErrorCode(
domain=ErrorDomain.STORAGE_PROXY,
operation=ErrorOperation.UPDATE,
error_detail=ErrorDetail.CONFLICT,
)
class TusSessionNotFoundError(BackendAIError, web.HTTPNotFound):
"""
Raised when a TUS handler is invoked for a session that is not registered
in Valkey (never created, or its state expired by TTL).
"""
error_type = "https://api.backend.ai/probs/storage/no-such-upload-session"
error_title = "No such upload session"
def error_code(self) -> ErrorCode:
return ErrorCode(
domain=ErrorDomain.STORAGE_PROXY,
operation=ErrorOperation.READ,
error_detail=ErrorDetail.NOT_FOUND,
)
class UploadChunkExceedsTotalSizeError(BackendAIError, web.HTTPConflict):
"""
Raised when a PATCH chunk's offset+length would write past the declared
``Upload-Length`` (409 Conflict). The Upload-Offset header itself is in
range; the chunk's body simply overruns the remaining slot.
"""
error_type = "https://api.backend.ai/probs/storage/upload-chunk-exceeds-total-size"
error_title = "Upload Chunk Exceeds Total Size"
def error_code(self) -> ErrorCode:
return ErrorCode(
domain=ErrorDomain.STORAGE_PROXY,
operation=ErrorOperation.UPDATE,
error_detail=ErrorDetail.CONFLICT,
)
class UploadSessionCorruptedError(BackendAIError, web.HTTPInternalServerError):
"""
Raised when the upload session metadata stored in Valkey cannot be parsed,
is structurally invalid, or has gone missing at a stage that requires it.
"""
error_type = "https://api.backend.ai/probs/storage/upload-session-corrupted"
error_title = "Upload Session Corrupted"
def error_code(self) -> ErrorCode:
return ErrorCode(
domain=ErrorDomain.STORAGE_PROXY,
operation=ErrorOperation.READ,
error_detail=ErrorDetail.INTERNAL_ERROR,
)