manta-node 0.5b0__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.
Files changed (43) hide show
  1. manta_node/__init__.py +5 -0
  2. manta_node/__main__.py +57 -0
  3. manta_node/cli/__init__.py +6 -0
  4. manta_node/cli/commands/__init__.py +21 -0
  5. manta_node/cli/commands/cluster.py +419 -0
  6. manta_node/cli/commands/config.py +490 -0
  7. manta_node/cli/commands/logs.py +168 -0
  8. manta_node/cli/commands/start.py +459 -0
  9. manta_node/cli/commands/status.py +204 -0
  10. manta_node/cli/commands/stop.py +253 -0
  11. manta_node/cli/config_manager.py +139 -0
  12. manta_node/cli/main.py +133 -0
  13. manta_node/cli/version.py +106 -0
  14. manta_node/domain/__init__.py +8 -0
  15. manta_node/domain/task_lifecycle.py +90 -0
  16. manta_node/infrastructure/__init__.py +13 -0
  17. manta_node/infrastructure/config/__init__.py +31 -0
  18. manta_node/infrastructure/config/node_config_manager.py +918 -0
  19. manta_node/infrastructure/container/__init__.py +11 -0
  20. manta_node/infrastructure/container/docker_adapter.py +253 -0
  21. manta_node/infrastructure/container/image_executor.py +222 -0
  22. manta_node/infrastructure/container/manager.py +549 -0
  23. manta_node/infrastructure/filesystem/__init__.py +7 -0
  24. manta_node/infrastructure/filesystem/dataset_manager.py +469 -0
  25. manta_node/infrastructure/grpc/__init__.py +11 -0
  26. manta_node/infrastructure/grpc/client.py +373 -0
  27. manta_node/infrastructure/grpc/local_servicer.py +151 -0
  28. manta_node/infrastructure/grpc/world_servicer.py +284 -0
  29. manta_node/infrastructure/metrics/__init__.py +10 -0
  30. manta_node/infrastructure/metrics/collector.py +94 -0
  31. manta_node/infrastructure/metrics/metrics_collector.py +351 -0
  32. manta_node/infrastructure/mqtt/__init__.py +7 -0
  33. manta_node/infrastructure/mqtt/command_handler.py +450 -0
  34. manta_node/node_orchestrator.py +462 -0
  35. manta_node/task_manager.py +677 -0
  36. manta_node/tasks.py +273 -0
  37. manta_node/utils.py +52 -0
  38. manta_node-0.5b0.dist-info/METADATA +794 -0
  39. manta_node-0.5b0.dist-info/RECORD +43 -0
  40. manta_node-0.5b0.dist-info/WHEEL +5 -0
  41. manta_node-0.5b0.dist-info/entry_points.txt +2 -0
  42. manta_node-0.5b0.dist-info/licenses/LICENSE +683 -0
  43. manta_node-0.5b0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,90 @@
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 status_from_exit(container_status: str, exit_code: int) -> TaskStatus:
68
+ """For image-mode tasks: exit code is the authoritative completion signal."""
69
+ if container_status == "exited":
70
+ return TaskStatus.COMPLETED if exit_code == 0 else TaskStatus.FAILED
71
+ return TaskLifecycleService.calculate_status_from_container(container_status)
72
+
73
+ @staticmethod
74
+ def should_restart_task(
75
+ current_iteration: int,
76
+ new_iteration: int,
77
+ current_circular: int,
78
+ new_circular: int,
79
+ ) -> bool:
80
+ """
81
+ Business rule: Should we restart a task based on iteration numbers?
82
+ """
83
+ return (new_iteration != current_iteration) or (
84
+ new_circular != current_circular
85
+ )
86
+
87
+ @staticmethod
88
+ def is_active(status: TaskStatus) -> bool:
89
+ """Business rule: Is this an active (non-terminal) task?"""
90
+ 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
+ ]