-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexceptions.py
More file actions
118 lines (89 loc) · 2.81 KB
/
exceptions.py
File metadata and controls
118 lines (89 loc) · 2.81 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""
DGN Client Exception Hierarchy
Custom exceptions for the DGN (Distributed GPU Network) client that provide
better error categorization and enable proper retry logic.
Exception Hierarchy:
DGNError (base)
├── TransientError (retryable - network issues, 503, timeouts)
├── PermanentError (not retryable)
│ ├── AuthError (token expired, invalid API key)
│ └── ProviderError (provider not found/expired)
│ └── UpgradeRequiredError (client must be updated)
└── WorkflowError (workflow file issues)
"""
class DGNError(Exception):
"""Base exception for all DGN client errors."""
pass
class TransientError(DGNError):
"""
Transient errors that may succeed on retry.
Examples:
- Network connectivity issues
- Server temporarily unavailable (503)
- Request timeouts
- Rate limiting (429)
"""
pass
class InfrastructureError(TransientError):
"""
Provider-side infrastructure errors that should requeue the job.
Raised when:
- Docker/container runtime fails
- GPU runtime hits CUDA out-of-memory or a broken CUDA context
- A local model server fails in a way that is provider-specific
"""
pass
class PermanentError(DGNError):
"""
Permanent errors that will not succeed on retry.
Examples:
- Invalid credentials
- Resource not found
- Permission denied
"""
pass
class AuthError(PermanentError):
"""
Authentication/authorization errors.
Raised when:
- Access token has expired
- Refresh token is invalid
- API key is revoked
"""
pass
class ProviderError(PermanentError):
"""
Provider-related errors.
Raised when:
- Provider registration has expired
- Provider not found in database
- Provider cleanup by stale provider cron
"""
pass
class UpgradeRequiredError(PermanentError):
"""
Client version/protocol is below the orchestrator's required policy.
Raised when the control plane returns HTTP 426. The client should stop
processing and let the desktop app or operator install an update.
"""
def __init__(self, payload=None):
self.payload = payload if isinstance(payload, dict) else {}
message = self.payload.get("message") or "OpenFork update required"
super().__init__(message)
class WorkflowError(DGNError):
"""
Workflow file errors.
Raised when:
- Workflow file not found
- Invalid workflow JSON format
- Missing required workflow nodes
"""
pass
class ConfigurationError(DGNError):
"""
Configuration errors.
Raised when:
- Invalid configuration values
- Missing required configuration
"""
pass