digitalkin 0.2.25rc0__py3-none-any.whl → 0.3.2.dev14__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.
- base_server/server_async_insecure.py +6 -5
- base_server/server_async_secure.py +6 -5
- base_server/server_sync_insecure.py +5 -4
- base_server/server_sync_secure.py +5 -4
- digitalkin/__version__.py +1 -1
- digitalkin/core/__init__.py +1 -0
- digitalkin/core/common/__init__.py +9 -0
- digitalkin/core/common/factories.py +156 -0
- digitalkin/core/job_manager/__init__.py +1 -0
- digitalkin/{modules → core}/job_manager/base_job_manager.py +138 -32
- digitalkin/core/job_manager/single_job_manager.py +373 -0
- digitalkin/{modules → core}/job_manager/taskiq_broker.py +121 -26
- digitalkin/core/job_manager/taskiq_job_manager.py +541 -0
- digitalkin/core/task_manager/__init__.py +1 -0
- digitalkin/core/task_manager/base_task_manager.py +539 -0
- digitalkin/core/task_manager/local_task_manager.py +108 -0
- digitalkin/core/task_manager/remote_task_manager.py +87 -0
- digitalkin/core/task_manager/surrealdb_repository.py +266 -0
- digitalkin/core/task_manager/task_executor.py +249 -0
- digitalkin/core/task_manager/task_session.py +368 -0
- digitalkin/grpc_servers/__init__.py +1 -19
- digitalkin/grpc_servers/_base_server.py +3 -3
- digitalkin/grpc_servers/module_server.py +120 -195
- digitalkin/grpc_servers/module_servicer.py +81 -44
- digitalkin/grpc_servers/utils/__init__.py +1 -0
- digitalkin/grpc_servers/utils/exceptions.py +0 -8
- digitalkin/grpc_servers/utils/grpc_client_wrapper.py +25 -9
- digitalkin/grpc_servers/utils/grpc_error_handler.py +53 -0
- digitalkin/grpc_servers/utils/utility_schema_extender.py +100 -0
- digitalkin/logger.py +64 -27
- digitalkin/mixins/__init__.py +19 -0
- digitalkin/mixins/base_mixin.py +10 -0
- digitalkin/mixins/callback_mixin.py +24 -0
- digitalkin/mixins/chat_history_mixin.py +110 -0
- digitalkin/mixins/cost_mixin.py +76 -0
- digitalkin/mixins/file_history_mixin.py +93 -0
- digitalkin/mixins/filesystem_mixin.py +46 -0
- digitalkin/mixins/logger_mixin.py +51 -0
- digitalkin/mixins/storage_mixin.py +79 -0
- digitalkin/models/__init__.py +1 -1
- digitalkin/models/core/__init__.py +1 -0
- digitalkin/{modules/job_manager → models/core}/job_manager_models.py +3 -11
- digitalkin/models/core/task_monitor.py +74 -0
- digitalkin/models/grpc_servers/__init__.py +1 -0
- digitalkin/{grpc_servers/utils → models/grpc_servers}/models.py +92 -7
- digitalkin/models/module/__init__.py +18 -11
- digitalkin/models/module/base_types.py +61 -0
- digitalkin/models/module/module.py +9 -1
- digitalkin/models/module/module_context.py +282 -6
- digitalkin/models/module/module_types.py +29 -105
- digitalkin/models/module/setup_types.py +490 -0
- digitalkin/models/module/tool_cache.py +68 -0
- digitalkin/models/module/tool_reference.py +117 -0
- digitalkin/models/module/utility.py +167 -0
- digitalkin/models/services/__init__.py +9 -0
- digitalkin/models/services/cost.py +1 -0
- digitalkin/models/services/registry.py +35 -0
- digitalkin/models/services/storage.py +39 -5
- digitalkin/modules/__init__.py +5 -1
- digitalkin/modules/_base_module.py +265 -167
- digitalkin/modules/archetype_module.py +6 -1
- digitalkin/modules/tool_module.py +16 -3
- digitalkin/modules/trigger_handler.py +7 -6
- digitalkin/modules/triggers/__init__.py +8 -0
- digitalkin/modules/triggers/healthcheck_ping_trigger.py +45 -0
- digitalkin/modules/triggers/healthcheck_services_trigger.py +63 -0
- digitalkin/modules/triggers/healthcheck_status_trigger.py +52 -0
- digitalkin/services/__init__.py +4 -0
- digitalkin/services/communication/__init__.py +7 -0
- digitalkin/services/communication/communication_strategy.py +76 -0
- digitalkin/services/communication/default_communication.py +101 -0
- digitalkin/services/communication/grpc_communication.py +234 -0
- digitalkin/services/cost/__init__.py +9 -2
- digitalkin/services/cost/grpc_cost.py +9 -42
- digitalkin/services/filesystem/default_filesystem.py +0 -2
- digitalkin/services/filesystem/grpc_filesystem.py +10 -39
- digitalkin/services/registry/__init__.py +22 -1
- digitalkin/services/registry/default_registry.py +135 -4
- digitalkin/services/registry/exceptions.py +47 -0
- digitalkin/services/registry/grpc_registry.py +306 -0
- digitalkin/services/registry/registry_models.py +15 -0
- digitalkin/services/registry/registry_strategy.py +88 -4
- digitalkin/services/services_config.py +25 -3
- digitalkin/services/services_models.py +5 -1
- digitalkin/services/setup/default_setup.py +6 -7
- digitalkin/services/setup/grpc_setup.py +52 -15
- digitalkin/services/storage/grpc_storage.py +4 -4
- digitalkin/services/user_profile/__init__.py +12 -0
- digitalkin/services/user_profile/default_user_profile.py +55 -0
- digitalkin/services/user_profile/grpc_user_profile.py +69 -0
- digitalkin/services/user_profile/user_profile_strategy.py +25 -0
- digitalkin/utils/__init__.py +28 -0
- digitalkin/utils/arg_parser.py +1 -1
- digitalkin/utils/development_mode_action.py +2 -2
- digitalkin/utils/dynamic_schema.py +483 -0
- digitalkin/utils/package_discover.py +1 -2
- digitalkin/utils/schema_splitter.py +207 -0
- {digitalkin-0.2.25rc0.dist-info → digitalkin-0.3.2.dev14.dist-info}/METADATA +11 -30
- digitalkin-0.3.2.dev14.dist-info/RECORD +143 -0
- {digitalkin-0.2.25rc0.dist-info → digitalkin-0.3.2.dev14.dist-info}/top_level.txt +1 -0
- modules/archetype_with_tools_module.py +244 -0
- modules/cpu_intensive_module.py +1 -1
- modules/dynamic_setup_module.py +338 -0
- modules/minimal_llm_module.py +1 -1
- modules/text_transform_module.py +1 -1
- monitoring/digitalkin_observability/__init__.py +46 -0
- monitoring/digitalkin_observability/http_server.py +150 -0
- monitoring/digitalkin_observability/interceptors.py +176 -0
- monitoring/digitalkin_observability/metrics.py +201 -0
- monitoring/digitalkin_observability/prometheus.py +137 -0
- monitoring/tests/test_metrics.py +172 -0
- services/filesystem_module.py +7 -5
- services/storage_module.py +4 -2
- digitalkin/grpc_servers/registry_server.py +0 -65
- digitalkin/grpc_servers/registry_servicer.py +0 -456
- digitalkin/grpc_servers/utils/factory.py +0 -180
- digitalkin/modules/job_manager/single_job_manager.py +0 -294
- digitalkin/modules/job_manager/taskiq_job_manager.py +0 -290
- digitalkin-0.2.25rc0.dist-info/RECORD +0 -89
- /digitalkin/{grpc_servers/utils → models/grpc_servers}/types.py +0 -0
- {digitalkin-0.2.25rc0.dist-info → digitalkin-0.3.2.dev14.dist-info}/WHEEL +0 -0
- {digitalkin-0.2.25rc0.dist-info → digitalkin-0.3.2.dev14.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Utility protocols for SDK-provided functionality.
|
|
2
|
+
|
|
3
|
+
These protocols are automatically available to all modules and don't need to be
|
|
4
|
+
explicitly included in module output unions.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from datetime import datetime, timezone
|
|
8
|
+
from typing import Any, ClassVar, Literal
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
11
|
+
|
|
12
|
+
from digitalkin.models.module.base_types import DataTrigger
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class UtilityProtocol(DataTrigger):
|
|
16
|
+
"""Base class for SDK-provided utility protocols.
|
|
17
|
+
|
|
18
|
+
All SDK utility protocols inherit from this class to enable:
|
|
19
|
+
- Easy identification of SDK vs user-defined protocols
|
|
20
|
+
- Auto-injection capability
|
|
21
|
+
- Consistent behavior across the SDK
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EndOfStreamOutput(UtilityProtocol):
|
|
26
|
+
"""Signal that the stream has ended."""
|
|
27
|
+
|
|
28
|
+
protocol: Literal["end_of_stream"] = "end_of_stream" # type: ignore
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ModuleStartInfoOutput(UtilityProtocol):
|
|
32
|
+
"""Output sent when module starts with execution context.
|
|
33
|
+
|
|
34
|
+
This protocol is sent as the first message when a module starts,
|
|
35
|
+
providing the client with essential execution context information.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
protocol: Literal["module_start_info"] = "module_start_info" # type: ignore
|
|
39
|
+
job_id: str = Field(..., description="Unique job identifier")
|
|
40
|
+
mission_id: str = Field(..., description="Mission identifier")
|
|
41
|
+
setup_id: str = Field(..., description="Setup identifier")
|
|
42
|
+
setup_version_id: str = Field(..., description="Setup version identifier")
|
|
43
|
+
module_id: str = Field(..., description="Module identifier")
|
|
44
|
+
module_name: str = Field(..., description="Human-readable module name")
|
|
45
|
+
started_at: str = Field(
|
|
46
|
+
default_factory=lambda: datetime.now(tz=timezone.utc).isoformat(),
|
|
47
|
+
description="ISO timestamp when module started",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class HealthcheckPingInput(UtilityProtocol):
|
|
52
|
+
"""Input for healthcheck ping request."""
|
|
53
|
+
|
|
54
|
+
protocol: Literal["healthcheck_ping"] = "healthcheck_ping" # type: ignore
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class HealthcheckPingOutput(UtilityProtocol):
|
|
58
|
+
"""Output for healthcheck ping response.
|
|
59
|
+
|
|
60
|
+
Simple alive check that returns "pong" status.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
protocol: Literal["healthcheck_ping"] = "healthcheck_ping" # type: ignore
|
|
64
|
+
status: Literal["pong"] = "pong"
|
|
65
|
+
latency_ms: float | None = Field(
|
|
66
|
+
default=None,
|
|
67
|
+
description="Round-trip latency in milliseconds",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ServiceHealthStatus(BaseModel):
|
|
72
|
+
"""Health status of a single service."""
|
|
73
|
+
|
|
74
|
+
name: str = Field(..., description="Name of the service")
|
|
75
|
+
status: Literal["healthy", "unhealthy", "unknown"] = Field(
|
|
76
|
+
...,
|
|
77
|
+
description="Health status of the service",
|
|
78
|
+
)
|
|
79
|
+
message: str | None = Field(
|
|
80
|
+
default=None,
|
|
81
|
+
description="Optional message about the service status",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class HealthcheckServicesInput(UtilityProtocol):
|
|
86
|
+
"""Input for healthcheck services request."""
|
|
87
|
+
|
|
88
|
+
protocol: Literal["healthcheck_services"] = "healthcheck_services" # type: ignore
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class HealthcheckServicesOutput(UtilityProtocol):
|
|
92
|
+
"""Output for healthcheck services response.
|
|
93
|
+
|
|
94
|
+
Reports the health status of all configured services.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
protocol: Literal["healthcheck_services"] = "healthcheck_services" # type: ignore
|
|
98
|
+
services: list[ServiceHealthStatus] = Field(
|
|
99
|
+
...,
|
|
100
|
+
description="List of service health statuses",
|
|
101
|
+
)
|
|
102
|
+
overall_status: Literal["healthy", "degraded", "unhealthy"] = Field(
|
|
103
|
+
...,
|
|
104
|
+
description="Overall health status based on all services",
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class HealthcheckStatusInput(UtilityProtocol):
|
|
109
|
+
"""Input for healthcheck status request."""
|
|
110
|
+
|
|
111
|
+
protocol: Literal["healthcheck_status"] = "healthcheck_status" # type: ignore
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class HealthcheckStatusOutput(UtilityProtocol):
|
|
115
|
+
"""Output for healthcheck status response.
|
|
116
|
+
|
|
117
|
+
Comprehensive module status including uptime, active jobs, and metadata.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
protocol: Literal["healthcheck_status"] = "healthcheck_status" # type: ignore
|
|
121
|
+
module_name: str = Field(..., description="Name of the module")
|
|
122
|
+
module_status: str = Field(..., description="Current status of the module")
|
|
123
|
+
uptime_seconds: float | None = Field(
|
|
124
|
+
default=None,
|
|
125
|
+
description="Module uptime in seconds",
|
|
126
|
+
)
|
|
127
|
+
active_jobs: int = Field(
|
|
128
|
+
default=0,
|
|
129
|
+
description="Number of currently active jobs",
|
|
130
|
+
)
|
|
131
|
+
metadata: dict[str, Any] = Field(
|
|
132
|
+
default_factory=dict,
|
|
133
|
+
description="Additional metadata about the module",
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class UtilityRegistry:
|
|
138
|
+
"""Registry for SDK-provided built-in triggers.
|
|
139
|
+
|
|
140
|
+
Example:
|
|
141
|
+
builtin_triggers = UtilityRegistry.get_builtin_triggers()
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
_builtin_triggers: ClassVar[tuple | None] = None
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def get_builtin_triggers(cls) -> tuple:
|
|
148
|
+
"""Get all SDK-provided built-in trigger handlers.
|
|
149
|
+
|
|
150
|
+
Uses lazy loading to avoid circular imports with the modules package.
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
Tuple of TriggerHandler subclasses for built-in functionality.
|
|
154
|
+
"""
|
|
155
|
+
if cls._builtin_triggers is None:
|
|
156
|
+
from digitalkin.modules.triggers.healthcheck_ping_trigger import HealthcheckPingTrigger # noqa: PLC0415
|
|
157
|
+
from digitalkin.modules.triggers.healthcheck_services_trigger import ( # noqa: PLC0415
|
|
158
|
+
HealthcheckServicesTrigger,
|
|
159
|
+
)
|
|
160
|
+
from digitalkin.modules.triggers.healthcheck_status_trigger import HealthcheckStatusTrigger # noqa: PLC0415
|
|
161
|
+
|
|
162
|
+
cls._builtin_triggers = (
|
|
163
|
+
HealthcheckPingTrigger,
|
|
164
|
+
HealthcheckServicesTrigger,
|
|
165
|
+
HealthcheckStatusTrigger,
|
|
166
|
+
)
|
|
167
|
+
return cls._builtin_triggers
|
|
@@ -38,6 +38,7 @@ class CostConfig(BaseModel):
|
|
|
38
38
|
class CostEvent(BaseModel):
|
|
39
39
|
"""Pydantic model that represents a cost event registered during service execution.
|
|
40
40
|
|
|
41
|
+
# DEPRECATED
|
|
41
42
|
:param cost_name: Identifier for the cost configuration.
|
|
42
43
|
:param cost_type: The type of cost.
|
|
43
44
|
:param usage: The amount or units consumed.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Registry data models."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RegistryModuleStatus(str, Enum):
|
|
9
|
+
"""Module status in the registry."""
|
|
10
|
+
|
|
11
|
+
UNSPECIFIED = "unspecified"
|
|
12
|
+
READY = "ready"
|
|
13
|
+
ACTIVE = "active"
|
|
14
|
+
ARCHIVED = "archived"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RegistryModuleType(str, Enum):
|
|
18
|
+
"""Module type in the registry."""
|
|
19
|
+
|
|
20
|
+
UNSPECIFIED = "unspecified"
|
|
21
|
+
ARCHETYPE = "archetype"
|
|
22
|
+
TOOL = "tool"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ModuleInfo(BaseModel):
|
|
26
|
+
"""Module information from registry."""
|
|
27
|
+
|
|
28
|
+
module_id: str
|
|
29
|
+
module_type: RegistryModuleType
|
|
30
|
+
address: str
|
|
31
|
+
port: int
|
|
32
|
+
version: str
|
|
33
|
+
name: str = ""
|
|
34
|
+
documentation: str | None = None
|
|
35
|
+
status: RegistryModuleStatus | None = None
|
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
"""Storage model."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any
|
|
4
5
|
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
5
7
|
|
|
6
|
-
class StorageModel(BaseModel):
|
|
7
|
-
"""Storage model."""
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
class BaseRole(str, Enum):
|
|
10
|
+
"""Officially supported Role Enum for chat messages."""
|
|
11
|
+
|
|
12
|
+
ASSISTANT = "assistant"
|
|
13
|
+
USER = "user"
|
|
14
|
+
SYSTEM = "system"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Role = BaseRole | str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BaseMessage(BaseModel):
|
|
21
|
+
"""Base Model representing a simple message in the chat history."""
|
|
22
|
+
|
|
23
|
+
role: Role = Field(..., description="Role of the message sender")
|
|
24
|
+
content: Any = Field(..., description="The content of the message | preferably a BaseModel.")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ChatHistory(BaseModel):
|
|
28
|
+
"""Storage chat history model for the OpenAI Archetype module."""
|
|
29
|
+
|
|
30
|
+
messages: list[BaseMessage] = Field(..., description="List of messages in the chat history")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class FileModel(BaseModel):
|
|
34
|
+
"""File model."""
|
|
35
|
+
|
|
36
|
+
file_id: str = Field(..., description="ID of the file")
|
|
37
|
+
name: str = Field(..., description="Name of the file")
|
|
38
|
+
metadata: dict[str, Any] = Field(..., description="Metadata of the file")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class FileHistory(BaseModel):
|
|
42
|
+
"""File history model."""
|
|
43
|
+
|
|
44
|
+
files: list[FileModel] = Field(..., description="List of files")
|
digitalkin/modules/__init__.py
CHANGED
|
@@ -4,4 +4,8 @@ from digitalkin.modules.archetype_module import ArchetypeModule
|
|
|
4
4
|
from digitalkin.modules.tool_module import ToolModule
|
|
5
5
|
from digitalkin.modules.trigger_handler import TriggerHandler
|
|
6
6
|
|
|
7
|
-
__all__ = [
|
|
7
|
+
__all__ = [
|
|
8
|
+
"ArchetypeModule",
|
|
9
|
+
"ToolModule",
|
|
10
|
+
"TriggerHandler",
|
|
11
|
+
]
|