kailash 0.8.4__py3-none-any.whl → 0.8.5__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.
- kailash/__init__.py +1 -7
- kailash/cli/__init__.py +11 -1
- kailash/cli/validation_audit.py +570 -0
- kailash/core/actors/supervisor.py +1 -1
- kailash/core/resilience/circuit_breaker.py +71 -1
- kailash/core/resilience/health_monitor.py +172 -0
- kailash/edge/compliance.py +33 -0
- kailash/edge/consistency.py +609 -0
- kailash/edge/coordination/__init__.py +30 -0
- kailash/edge/coordination/global_ordering.py +355 -0
- kailash/edge/coordination/leader_election.py +217 -0
- kailash/edge/coordination/partition_detector.py +296 -0
- kailash/edge/coordination/raft.py +485 -0
- kailash/edge/discovery.py +63 -1
- kailash/edge/migration/__init__.py +19 -0
- kailash/edge/migration/edge_migrator.py +832 -0
- kailash/edge/monitoring/__init__.py +21 -0
- kailash/edge/monitoring/edge_monitor.py +736 -0
- kailash/edge/prediction/__init__.py +10 -0
- kailash/edge/prediction/predictive_warmer.py +591 -0
- kailash/edge/resource/__init__.py +102 -0
- kailash/edge/resource/cloud_integration.py +796 -0
- kailash/edge/resource/cost_optimizer.py +949 -0
- kailash/edge/resource/docker_integration.py +919 -0
- kailash/edge/resource/kubernetes_integration.py +893 -0
- kailash/edge/resource/platform_integration.py +913 -0
- kailash/edge/resource/predictive_scaler.py +959 -0
- kailash/edge/resource/resource_analyzer.py +824 -0
- kailash/edge/resource/resource_pools.py +610 -0
- kailash/integrations/dataflow_edge.py +261 -0
- kailash/mcp_server/registry_integration.py +1 -1
- kailash/monitoring/__init__.py +18 -0
- kailash/monitoring/alerts.py +646 -0
- kailash/monitoring/metrics.py +677 -0
- kailash/nodes/__init__.py +2 -0
- kailash/nodes/ai/semantic_memory.py +2 -2
- kailash/nodes/base.py +545 -0
- kailash/nodes/edge/__init__.py +36 -0
- kailash/nodes/edge/base.py +240 -0
- kailash/nodes/edge/cloud_node.py +710 -0
- kailash/nodes/edge/coordination.py +239 -0
- kailash/nodes/edge/docker_node.py +825 -0
- kailash/nodes/edge/edge_data.py +582 -0
- kailash/nodes/edge/edge_migration_node.py +392 -0
- kailash/nodes/edge/edge_monitoring_node.py +421 -0
- kailash/nodes/edge/edge_state.py +673 -0
- kailash/nodes/edge/edge_warming_node.py +393 -0
- kailash/nodes/edge/kubernetes_node.py +652 -0
- kailash/nodes/edge/platform_node.py +766 -0
- kailash/nodes/edge/resource_analyzer_node.py +378 -0
- kailash/nodes/edge/resource_optimizer_node.py +501 -0
- kailash/nodes/edge/resource_scaler_node.py +397 -0
- kailash/nodes/ports.py +676 -0
- kailash/runtime/local.py +344 -1
- kailash/runtime/validation/__init__.py +20 -0
- kailash/runtime/validation/connection_context.py +119 -0
- kailash/runtime/validation/enhanced_error_formatter.py +202 -0
- kailash/runtime/validation/error_categorizer.py +164 -0
- kailash/runtime/validation/metrics.py +380 -0
- kailash/runtime/validation/performance.py +615 -0
- kailash/runtime/validation/suggestion_engine.py +212 -0
- kailash/testing/fixtures.py +2 -2
- kailash/workflow/builder.py +230 -4
- kailash/workflow/contracts.py +418 -0
- kailash/workflow/edge_infrastructure.py +369 -0
- kailash/workflow/migration.py +3 -3
- kailash/workflow/type_inference.py +669 -0
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/METADATA +43 -27
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/RECORD +73 -27
- kailash/nexus/__init__.py +0 -21
- kailash/nexus/cli/__init__.py +0 -5
- kailash/nexus/cli/__main__.py +0 -6
- kailash/nexus/cli/main.py +0 -176
- kailash/nexus/factory.py +0 -413
- kailash/nexus/gateway.py +0 -545
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/WHEEL +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/entry_points.txt +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/licenses/LICENSE +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,261 @@
|
|
1
|
+
"""DataFlow edge integration for Kailash SDK.
|
2
|
+
|
3
|
+
This module provides integration between DataFlow models and edge computing
|
4
|
+
infrastructure, allowing models to specify edge requirements that are
|
5
|
+
automatically propagated to generated nodes.
|
6
|
+
"""
|
7
|
+
|
8
|
+
import logging
|
9
|
+
from typing import Any, Dict, Optional
|
10
|
+
|
11
|
+
logger = logging.getLogger(__name__)
|
12
|
+
|
13
|
+
|
14
|
+
class DataFlowEdgeIntegration:
|
15
|
+
"""Integration layer between DataFlow and edge infrastructure."""
|
16
|
+
|
17
|
+
@staticmethod
|
18
|
+
def extract_edge_config(model_class: type) -> Optional[Dict[str, Any]]:
|
19
|
+
"""Extract edge configuration from a DataFlow model.
|
20
|
+
|
21
|
+
Args:
|
22
|
+
model_class: The DataFlow model class
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
Edge configuration dictionary or None
|
26
|
+
"""
|
27
|
+
# Check for __dataflow__ attribute
|
28
|
+
dataflow_config = getattr(model_class, "__dataflow__", {})
|
29
|
+
|
30
|
+
# Look for edge_config in the __dataflow__ dictionary
|
31
|
+
edge_config = dataflow_config.get("edge_config", None)
|
32
|
+
|
33
|
+
if edge_config:
|
34
|
+
logger.debug(
|
35
|
+
f"Found edge config for model {model_class.__name__}: {edge_config}"
|
36
|
+
)
|
37
|
+
|
38
|
+
return edge_config
|
39
|
+
|
40
|
+
@staticmethod
|
41
|
+
def enhance_node_config(
|
42
|
+
node_config: Dict[str, Any], edge_config: Dict[str, Any]
|
43
|
+
) -> Dict[str, Any]:
|
44
|
+
"""Enhance node configuration with edge requirements.
|
45
|
+
|
46
|
+
Args:
|
47
|
+
node_config: Base node configuration
|
48
|
+
edge_config: Edge configuration from model
|
49
|
+
|
50
|
+
Returns:
|
51
|
+
Enhanced node configuration
|
52
|
+
"""
|
53
|
+
enhanced = node_config.copy()
|
54
|
+
|
55
|
+
# Map DataFlow edge config to node parameters
|
56
|
+
if "compliance_classification" in edge_config:
|
57
|
+
enhanced["data_classification"] = edge_config["compliance_classification"]
|
58
|
+
|
59
|
+
if "preferred_regions" in edge_config:
|
60
|
+
enhanced["preferred_locations"] = edge_config["preferred_regions"]
|
61
|
+
|
62
|
+
if "required_compliance" in edge_config:
|
63
|
+
enhanced["compliance_zones"] = edge_config["required_compliance"]
|
64
|
+
|
65
|
+
if "replication_strategy" in edge_config:
|
66
|
+
# Map to edge data node parameters
|
67
|
+
enhanced["replication_factor"] = edge_config.get("replication_factor", 3)
|
68
|
+
enhanced["consistency"] = edge_config.get("consistency_model", "eventual")
|
69
|
+
|
70
|
+
if "encryption_required" in edge_config:
|
71
|
+
enhanced["enable_encryption"] = edge_config["encryption_required"]
|
72
|
+
|
73
|
+
# Mark as edge-enabled for WorkflowBuilder detection
|
74
|
+
enhanced["_edge_enabled"] = True
|
75
|
+
|
76
|
+
logger.debug(f"Enhanced node config with edge capabilities: {enhanced}")
|
77
|
+
|
78
|
+
return enhanced
|
79
|
+
|
80
|
+
@staticmethod
|
81
|
+
def should_use_edge_node(operation: str, edge_config: Dict[str, Any]) -> bool:
|
82
|
+
"""Determine if an operation should use edge nodes.
|
83
|
+
|
84
|
+
Args:
|
85
|
+
operation: The CRUD operation (create, read, update, delete, list)
|
86
|
+
edge_config: Edge configuration from model
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
True if edge nodes should be used
|
90
|
+
"""
|
91
|
+
# Always use edge nodes if compliance is required
|
92
|
+
if edge_config.get("required_compliance"):
|
93
|
+
return True
|
94
|
+
|
95
|
+
# Use edge nodes for geo-distributed operations
|
96
|
+
if edge_config.get("geo_distributed", False):
|
97
|
+
return True
|
98
|
+
|
99
|
+
# Use edge nodes for operations requiring low latency
|
100
|
+
if edge_config.get("low_latency_required", False):
|
101
|
+
return True
|
102
|
+
|
103
|
+
# Check operation-specific settings
|
104
|
+
edge_operations = edge_config.get("edge_operations", [])
|
105
|
+
if operation in edge_operations:
|
106
|
+
return True
|
107
|
+
|
108
|
+
# Default to using edge nodes if any edge config is present
|
109
|
+
return bool(edge_config)
|
110
|
+
|
111
|
+
@staticmethod
|
112
|
+
def create_edge_workflow_config(
|
113
|
+
model_name: str, edge_config: Dict[str, Any]
|
114
|
+
) -> Dict[str, Any]:
|
115
|
+
"""Create workflow-level edge configuration for a model.
|
116
|
+
|
117
|
+
Args:
|
118
|
+
model_name: Name of the DataFlow model
|
119
|
+
edge_config: Edge configuration from model
|
120
|
+
|
121
|
+
Returns:
|
122
|
+
Workflow edge configuration
|
123
|
+
"""
|
124
|
+
workflow_edge_config = {
|
125
|
+
"discovery": {
|
126
|
+
"locations": edge_config.get("edge_locations", []),
|
127
|
+
"selection_strategy": edge_config.get("selection_strategy", "balanced"),
|
128
|
+
},
|
129
|
+
"compliance": {
|
130
|
+
"strict_mode": edge_config.get("strict_compliance", True),
|
131
|
+
"default_classification": edge_config.get(
|
132
|
+
"compliance_classification", "pii"
|
133
|
+
),
|
134
|
+
},
|
135
|
+
"performance": {
|
136
|
+
"connection_pool_size": edge_config.get("connection_pool_size", 10),
|
137
|
+
"health_check_interval": edge_config.get("health_check_interval", 60),
|
138
|
+
},
|
139
|
+
}
|
140
|
+
|
141
|
+
# Add model-specific metadata
|
142
|
+
workflow_edge_config["dataflow_model"] = model_name
|
143
|
+
|
144
|
+
return workflow_edge_config
|
145
|
+
|
146
|
+
|
147
|
+
# Monkey-patch helper for DataFlow NodeGenerator
|
148
|
+
def enhance_dataflow_node_generator():
|
149
|
+
"""Enhance DataFlow's NodeGenerator to support edge configuration.
|
150
|
+
|
151
|
+
This function should be called during DataFlow initialization to add
|
152
|
+
edge support to generated nodes.
|
153
|
+
"""
|
154
|
+
try:
|
155
|
+
from dataflow.core.nodes import NodeGenerator
|
156
|
+
|
157
|
+
# Store original _create_node_class method
|
158
|
+
original_create_node_class = NodeGenerator._create_node_class
|
159
|
+
|
160
|
+
def _create_node_class_with_edge(
|
161
|
+
self, model_name: str, operation: str, fields: Dict[str, Any]
|
162
|
+
):
|
163
|
+
"""Enhanced node creation with edge support."""
|
164
|
+
# Get the model class if available
|
165
|
+
model_class = getattr(self.dataflow_instance, f"_{model_name}_model", None)
|
166
|
+
|
167
|
+
if model_class:
|
168
|
+
# Extract edge configuration
|
169
|
+
edge_config = DataFlowEdgeIntegration.extract_edge_config(model_class)
|
170
|
+
|
171
|
+
if edge_config and DataFlowEdgeIntegration.should_use_edge_node(
|
172
|
+
operation, edge_config
|
173
|
+
):
|
174
|
+
# Create edge-enabled node
|
175
|
+
logger.info(
|
176
|
+
f"Creating edge-enabled node for {model_name}.{operation}"
|
177
|
+
)
|
178
|
+
|
179
|
+
# Create base node class
|
180
|
+
node_class = original_create_node_class(
|
181
|
+
self, model_name, operation, fields
|
182
|
+
)
|
183
|
+
|
184
|
+
# Enhance node class with edge capabilities
|
185
|
+
original_init = node_class.__init__
|
186
|
+
|
187
|
+
def edge_enhanced_init(node_self, **config):
|
188
|
+
# Enhance config with edge settings
|
189
|
+
enhanced_config = DataFlowEdgeIntegration.enhance_node_config(
|
190
|
+
config, edge_config
|
191
|
+
)
|
192
|
+
|
193
|
+
# Determine if this should be an EdgeDataNode
|
194
|
+
if operation in ["create", "read", "update", "delete"]:
|
195
|
+
# These operations benefit from EdgeDataNode
|
196
|
+
enhanced_config["_preferred_node_type"] = "EdgeDataNode"
|
197
|
+
|
198
|
+
original_init(node_self, **enhanced_config)
|
199
|
+
|
200
|
+
node_class.__init__ = edge_enhanced_init
|
201
|
+
|
202
|
+
return node_class
|
203
|
+
|
204
|
+
# Fall back to original implementation
|
205
|
+
return original_create_node_class(self, model_name, operation, fields)
|
206
|
+
|
207
|
+
# Replace the method
|
208
|
+
NodeGenerator._create_node_class = _create_node_class_with_edge
|
209
|
+
|
210
|
+
logger.info("DataFlow NodeGenerator enhanced with edge support")
|
211
|
+
|
212
|
+
except ImportError:
|
213
|
+
logger.warning("DataFlow not available, edge integration not applied")
|
214
|
+
|
215
|
+
|
216
|
+
# Example usage in DataFlow model
|
217
|
+
"""
|
218
|
+
Example DataFlow model with edge configuration:
|
219
|
+
|
220
|
+
```python
|
221
|
+
from dataflow import DataFlow
|
222
|
+
|
223
|
+
db = DataFlow()
|
224
|
+
|
225
|
+
@db.model
|
226
|
+
class SensitiveData:
|
227
|
+
user_id: int
|
228
|
+
personal_info: dict
|
229
|
+
location: str
|
230
|
+
|
231
|
+
__dataflow__ = {
|
232
|
+
'multi_tenant': True,
|
233
|
+
'soft_delete': True,
|
234
|
+
'edge_config': {
|
235
|
+
'compliance_classification': 'pii',
|
236
|
+
'required_compliance': ['GDPR', 'CCPA'],
|
237
|
+
'preferred_regions': ['eu-west-1', 'us-west-2'],
|
238
|
+
'replication_strategy': 'multi-region',
|
239
|
+
'replication_factor': 3,
|
240
|
+
'consistency_model': 'strong',
|
241
|
+
'encryption_required': True,
|
242
|
+
'edge_operations': ['create', 'read', 'update'], # Use edge for these
|
243
|
+
'geo_distributed': True,
|
244
|
+
'low_latency_required': True
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
# When using generated nodes in workflows:
|
249
|
+
workflow = WorkflowBuilder(edge_config=DataFlowEdgeIntegration.create_edge_workflow_config(
|
250
|
+
'SensitiveData',
|
251
|
+
SensitiveData.__dataflow__['edge_config']
|
252
|
+
))
|
253
|
+
|
254
|
+
# Nodes will automatically use edge infrastructure
|
255
|
+
workflow.add_node("SensitiveDataCreateNode", "create", {
|
256
|
+
"user_id": 123,
|
257
|
+
"personal_info": {"name": "John Doe"},
|
258
|
+
"location": "EU"
|
259
|
+
})
|
260
|
+
```
|
261
|
+
"""
|
@@ -475,7 +475,7 @@ class NetworkAnnouncer:
|
|
475
475
|
break
|
476
476
|
except Exception as e:
|
477
477
|
logger.error(f"Error in network announcement: {e}")
|
478
|
-
await asyncio.sleep(
|
478
|
+
await asyncio.sleep(0.1) # Fast retry for tests
|
479
479
|
|
480
480
|
async def _send_announcement(self):
|
481
481
|
"""Send UDP announcement."""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Monitoring and alerting system for Kailash SDK.
|
3
|
+
|
4
|
+
Provides comprehensive monitoring for validation failures, security violations,
|
5
|
+
performance metrics, and alerting for critical events.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .alerts import AlertManager, AlertRule, AlertSeverity
|
9
|
+
from .metrics import PerformanceMetrics, SecurityMetrics, ValidationMetrics
|
10
|
+
|
11
|
+
__all__ = [
|
12
|
+
"ValidationMetrics",
|
13
|
+
"SecurityMetrics",
|
14
|
+
"PerformanceMetrics",
|
15
|
+
"AlertManager",
|
16
|
+
"AlertRule",
|
17
|
+
"AlertSeverity",
|
18
|
+
]
|