Skip to content

Commit e224698

Browse files
committed
refactor(BA-2753): Move error classes to its own module
1 parent 64852fe commit e224698

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/ai/backend/agent/errors/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from ai.backend.common.exception import (
2+
BackendAIError,
3+
ErrorCode,
4+
ErrorDetail,
5+
ErrorDomain,
6+
ErrorOperation,
7+
)
8+
9+
10+
class AgentIdNotFoundError(BackendAIError):
11+
@classmethod
12+
def error_code(cls) -> ErrorCode:
13+
return ErrorCode(
14+
domain=ErrorDomain.AGENT,
15+
operation=ErrorOperation.ACCESS,
16+
error_detail=ErrorDetail.NOT_FOUND,
17+
)

src/ai/backend/agent/runtime.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,19 @@
55

66
from ai.backend.agent.agent import AbstractAgent
77
from ai.backend.agent.config.unified import AgentUnifiedConfig
8+
from ai.backend.agent.errors.runtime import AgentIdNotFoundError
89
from ai.backend.agent.etcd import AgentEtcdClientView
910
from ai.backend.agent.kernel import KernelRegistry
1011
from ai.backend.agent.monitor import AgentErrorPluginContext, AgentStatsPluginContext
1112
from ai.backend.agent.types import AgentBackend
1213
from ai.backend.common.auth import PublicKey
1314
from ai.backend.common.etcd import AsyncEtcd, ConfigScopes
14-
from ai.backend.common.exception import (
15-
BackendAIError,
16-
ErrorCode,
17-
ErrorDetail,
18-
ErrorDomain,
19-
ErrorOperation,
20-
)
2115
from ai.backend.common.types import AgentId
2216

2317
if TYPE_CHECKING:
2418
from .docker.metadata.server import MetadataServer
2519

2620

27-
class AgentIdNotFoundError(BackendAIError):
28-
@classmethod
29-
def error_code(cls) -> ErrorCode:
30-
return ErrorCode(
31-
domain=ErrorDomain.AGENT,
32-
operation=ErrorOperation.ACCESS,
33-
error_detail=ErrorDetail.NOT_FOUND,
34-
)
35-
36-
3721
class AgentRuntime:
3822
_local_config: AgentUnifiedConfig
3923
_agents: dict[AgentId, AbstractAgent]

0 commit comments

Comments
 (0)