manta-node 0.5b0.dev9__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.
- manta_node/__init__.py +5 -0
- manta_node/__main__.py +57 -0
- manta_node/cli/__init__.py +6 -0
- manta_node/cli/commands/__init__.py +21 -0
- manta_node/cli/commands/cluster.py +419 -0
- manta_node/cli/commands/config.py +490 -0
- manta_node/cli/commands/logs.py +168 -0
- manta_node/cli/commands/start.py +459 -0
- manta_node/cli/commands/status.py +204 -0
- manta_node/cli/commands/stop.py +253 -0
- manta_node/cli/config_manager.py +139 -0
- manta_node/cli/main.py +133 -0
- manta_node/cli/version.py +106 -0
- manta_node/domain/__init__.py +8 -0
- manta_node/domain/task_lifecycle.py +83 -0
- manta_node/infrastructure/__init__.py +13 -0
- manta_node/infrastructure/config/__init__.py +31 -0
- manta_node/infrastructure/config/node_config_manager.py +918 -0
- manta_node/infrastructure/container/__init__.py +9 -0
- manta_node/infrastructure/container/docker_adapter.py +253 -0
- manta_node/infrastructure/container/manager.py +536 -0
- manta_node/infrastructure/filesystem/__init__.py +7 -0
- manta_node/infrastructure/filesystem/dataset_manager.py +469 -0
- manta_node/infrastructure/grpc/__init__.py +11 -0
- manta_node/infrastructure/grpc/client.py +373 -0
- manta_node/infrastructure/grpc/local_servicer.py +151 -0
- manta_node/infrastructure/grpc/world_servicer.py +284 -0
- manta_node/infrastructure/metrics/__init__.py +10 -0
- manta_node/infrastructure/metrics/collector.py +94 -0
- manta_node/infrastructure/metrics/metrics_collector.py +351 -0
- manta_node/infrastructure/mqtt/__init__.py +7 -0
- manta_node/infrastructure/mqtt/command_handler.py +315 -0
- manta_node/node_orchestrator.py +462 -0
- manta_node/task_manager.py +519 -0
- manta_node/tasks.py +272 -0
- manta_node/utils.py +52 -0
- manta_node-0.5b0.dev9.dist-info/METADATA +799 -0
- manta_node-0.5b0.dev9.dist-info/RECORD +42 -0
- manta_node-0.5b0.dev9.dist-info/WHEEL +5 -0
- manta_node-0.5b0.dev9.dist-info/entry_points.txt +2 -0
- manta_node-0.5b0.dev9.dist-info/licenses/LICENSE +683 -0
- manta_node-0.5b0.dev9.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# domain/task_lifecycle.py
|
|
2
|
+
"""Pure business logic for task lifecycle management."""
|
|
3
|
+
|
|
4
|
+
# Import domain entities (no infrastructure!)
|
|
5
|
+
from manta_common.build.common.tasks import TaskStatus
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TaskTransitionRule:
|
|
9
|
+
"""Business rules for task state transitions."""
|
|
10
|
+
|
|
11
|
+
ALLOWED_TRANSITIONS = {
|
|
12
|
+
TaskStatus.PENDING: [TaskStatus.RUNNING, TaskStatus.FAILED],
|
|
13
|
+
TaskStatus.RUNNING: [
|
|
14
|
+
TaskStatus.COMPLETED,
|
|
15
|
+
TaskStatus.FAILED,
|
|
16
|
+
TaskStatus.STOPPED,
|
|
17
|
+
],
|
|
18
|
+
TaskStatus.COMPLETED: [], # Terminal state
|
|
19
|
+
TaskStatus.FAILED: [], # Terminal state
|
|
20
|
+
TaskStatus.STOPPED: [], # Terminal state
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def can_transition(from_status: TaskStatus, to_status: TaskStatus) -> bool:
|
|
25
|
+
"""Check if a state transition is valid."""
|
|
26
|
+
return to_status in TaskTransitionRule.ALLOWED_TRANSITIONS.get(from_status, [])
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def is_terminal(status: TaskStatus) -> bool:
|
|
30
|
+
"""
|
|
31
|
+
Check if a status is a terminal state.
|
|
32
|
+
|
|
33
|
+
Note: STOPPED is terminal for transitions but NOT for is_finished_task logic.
|
|
34
|
+
The original logic only considered COMPLETED and FAILED as "finished".
|
|
35
|
+
"""
|
|
36
|
+
return status in [TaskStatus.COMPLETED, TaskStatus.FAILED, TaskStatus.STOPPED]
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def is_finished(status: TaskStatus) -> bool:
|
|
40
|
+
"""
|
|
41
|
+
Check if a task is finished (ready to be marked as STOPPED).
|
|
42
|
+
This matches the original is_finished_task() logic.
|
|
43
|
+
"""
|
|
44
|
+
return status in [TaskStatus.COMPLETED, TaskStatus.FAILED]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class TaskLifecycleService:
|
|
48
|
+
"""Domain service for task lifecycle decisions (no infrastructure)."""
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def calculate_status_from_container(container_status: str) -> TaskStatus:
|
|
52
|
+
"""
|
|
53
|
+
Business logic: Map container status to task status.
|
|
54
|
+
No Docker dependency - just string input.
|
|
55
|
+
"""
|
|
56
|
+
status_map = {
|
|
57
|
+
"created": TaskStatus.PENDING,
|
|
58
|
+
"running": TaskStatus.RUNNING,
|
|
59
|
+
"exited": TaskStatus.COMPLETED,
|
|
60
|
+
"dead": TaskStatus.FAILED,
|
|
61
|
+
"paused": TaskStatus.FAILED,
|
|
62
|
+
"restarting": TaskStatus.FAILED,
|
|
63
|
+
}
|
|
64
|
+
return status_map.get(container_status, TaskStatus.FAILED)
|
|
65
|
+
|
|
66
|
+
@staticmethod
|
|
67
|
+
def should_restart_task(
|
|
68
|
+
current_iteration: int,
|
|
69
|
+
new_iteration: int,
|
|
70
|
+
current_circular: int,
|
|
71
|
+
new_circular: int,
|
|
72
|
+
) -> bool:
|
|
73
|
+
"""
|
|
74
|
+
Business rule: Should we restart a task based on iteration numbers?
|
|
75
|
+
"""
|
|
76
|
+
return (new_iteration != current_iteration) or (
|
|
77
|
+
new_circular != current_circular
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
@staticmethod
|
|
81
|
+
def is_active(status: TaskStatus) -> bool:
|
|
82
|
+
"""Business rule: Is this an active (non-terminal) task?"""
|
|
83
|
+
return not TaskTransitionRule.is_terminal(status)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Infrastructure layer - External service adapters and technical implementations."""
|
|
2
|
+
|
|
3
|
+
# Import submodules for convenient access
|
|
4
|
+
from . import config, container, filesystem, grpc, metrics, mqtt
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"config",
|
|
8
|
+
"container",
|
|
9
|
+
"filesystem",
|
|
10
|
+
"grpc",
|
|
11
|
+
"metrics",
|
|
12
|
+
"mqtt",
|
|
13
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Configuration infrastructure - Node configuration management."""
|
|
2
|
+
|
|
3
|
+
from .node_config_manager import (
|
|
4
|
+
ContainerConfig,
|
|
5
|
+
DatasetConfig,
|
|
6
|
+
IdentityConfig,
|
|
7
|
+
LoggingConfig,
|
|
8
|
+
MetadataConfig,
|
|
9
|
+
MQTTConfig,
|
|
10
|
+
NetworkConfig,
|
|
11
|
+
NodeConfiguration,
|
|
12
|
+
NodeConfigManager,
|
|
13
|
+
ResourceConfig,
|
|
14
|
+
SecurityConfig,
|
|
15
|
+
TaskConfig,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"NodeConfigManager",
|
|
20
|
+
"NodeConfiguration",
|
|
21
|
+
"IdentityConfig",
|
|
22
|
+
"NetworkConfig",
|
|
23
|
+
"MQTTConfig",
|
|
24
|
+
"ContainerConfig",
|
|
25
|
+
"DatasetConfig",
|
|
26
|
+
"TaskConfig",
|
|
27
|
+
"ResourceConfig",
|
|
28
|
+
"LoggingConfig",
|
|
29
|
+
"SecurityConfig",
|
|
30
|
+
"MetadataConfig",
|
|
31
|
+
]
|