Browse Source

refactor(graph_engine): rename Layer to GraphEngineLayer

Signed-off-by: -LAN- <laipz8200@outlook.com>
tags/2.0.0-beta.1
-LAN- 2 months ago
parent
commit
8332472944
No account linked to committer's email address

+ 3
- 3
api/core/workflow/graph_engine/event_management/event_manager.py View File

@@ -9,7 +9,7 @@ from typing import final

from core.workflow.graph_events import GraphEngineEvent

from ..layers.base import Layer
from ..layers.base import GraphEngineLayer


@final
@@ -104,10 +104,10 @@ class EventManager:
"""Initialize the event manager."""
self._events: list[GraphEngineEvent] = []
self._lock = ReadWriteLock()
self._layers: list[Layer] = []
self._layers: list[GraphEngineLayer] = []
self._execution_complete = threading.Event()

def set_layers(self, layers: list[Layer]) -> None:
def set_layers(self, layers: list[GraphEngineLayer]) -> None:
"""
Set the layers to notify on event collection.


+ 3
- 3
api/core/workflow/graph_engine/graph_engine.py View File

@@ -33,7 +33,7 @@ from .entities.commands import AbortCommand
from .error_handling import ErrorHandler
from .event_management import EventHandler, EventManager
from .graph_traversal import EdgeProcessor, SkipPropagator
from .layers.base import Layer
from .layers.base import GraphEngineLayer
from .orchestration import Dispatcher, ExecutionCoordinator
from .protocols.command_channel import CommandChannel
from .response_coordinator import ResponseStreamCoordinator
@@ -221,7 +221,7 @@ class GraphEngine:

# === Extensibility ===
# Layers allow plugins to extend engine functionality
self._layers: list[Layer] = []
self._layers: list[GraphEngineLayer] = []

# === Validation ===
# Ensure all nodes share the same GraphRuntimeState instance
@@ -234,7 +234,7 @@ class GraphEngine:
if id(node.graph_runtime_state) != expected_state_id:
raise ValueError(f"GraphRuntimeState consistency violation: Node '{node.id}' has a different instance")

def layer(self, layer: Layer) -> "GraphEngine":
def layer(self, layer: GraphEngineLayer) -> "GraphEngine":
"""Add a layer for extending functionality."""
self._layers.append(layer)
return self

+ 2
- 2
api/core/workflow/graph_engine/layers/__init__.py View File

@@ -5,12 +5,12 @@ This module provides the layer infrastructure for extending GraphEngine function
with middleware-like components that can observe events and interact with execution.
"""

from .base import Layer
from .base import GraphEngineLayer
from .debug_logging import DebugLoggingLayer
from .execution_limits import ExecutionLimitsLayer

__all__ = [
"DebugLoggingLayer",
"ExecutionLimitsLayer",
"Layer",
"GraphEngineLayer",
]

+ 1
- 1
api/core/workflow/graph_engine/layers/base.py View File

@@ -12,7 +12,7 @@ from core.workflow.graph_engine.protocols.command_channel import CommandChannel
from core.workflow.graph_events import GraphEngineEvent


class Layer(ABC):
class GraphEngineLayer(ABC):
"""
Abstract base class for GraphEngine layers.


+ 2
- 2
api/core/workflow/graph_engine/layers/debug_logging.py View File

@@ -33,11 +33,11 @@ from core.workflow.graph_events import (
NodeRunSucceededEvent,
)

from .base import Layer
from .base import GraphEngineLayer


@final
class DebugLoggingLayer(Layer):
class DebugLoggingLayer(GraphEngineLayer):
"""
A layer that provides comprehensive logging of GraphEngine execution.


+ 2
- 2
api/core/workflow/graph_engine/layers/execution_limits.py View File

@@ -16,7 +16,7 @@ from typing import final
from typing_extensions import override

from core.workflow.graph_engine.entities.commands import AbortCommand, CommandType
from core.workflow.graph_engine.layers import Layer
from core.workflow.graph_engine.layers import GraphEngineLayer
from core.workflow.graph_events import (
GraphEngineEvent,
NodeRunStartedEvent,
@@ -32,7 +32,7 @@ class LimitType(Enum):


@final
class ExecutionLimitsLayer(Layer):
class ExecutionLimitsLayer(GraphEngineLayer):
"""
Layer that enforces execution limits for workflows.


Loading…
Cancel
Save