forked from genewildish/Mainline
Add REPL effect detection and input handling to pipeline runner
- Detect REPL effect in pipeline and enable interactive mode - Enable raw terminal mode for REPL input capture - Add keyboard input loop for REPL commands (return, up/down arrows, backspace) - Process commands and handle pipeline mutations from REPL - Fix lint issues in graph and REPL modules (type annotations, imports)
This commit is contained in:
@@ -22,8 +22,8 @@ Usage:
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
|
||||
class NodeType(Enum):
|
||||
@@ -45,7 +45,7 @@ class Node:
|
||||
|
||||
name: str
|
||||
type: NodeType
|
||||
config: Dict[str, Any] = field(default_factory=dict)
|
||||
config: dict[str, Any] = field(default_factory=dict)
|
||||
enabled: bool = True
|
||||
optional: bool = False
|
||||
|
||||
@@ -59,17 +59,17 @@ class Connection:
|
||||
|
||||
source: str
|
||||
target: str
|
||||
data_type: Optional[str] = None # Optional data type constraint
|
||||
data_type: str | None = None # Optional data type constraint
|
||||
|
||||
|
||||
@dataclass
|
||||
class Graph:
|
||||
"""Pipeline graph representation."""
|
||||
|
||||
nodes: Dict[str, Node] = field(default_factory=dict)
|
||||
connections: List[Connection] = field(default_factory=list)
|
||||
nodes: dict[str, Node] = field(default_factory=dict)
|
||||
connections: list[Connection] = field(default_factory=list)
|
||||
|
||||
def node(self, name: str, node_type: Union[NodeType, str], **config) -> "Graph":
|
||||
def node(self, name: str, node_type: NodeType | str, **config) -> "Graph":
|
||||
"""Add a node to the graph."""
|
||||
if isinstance(node_type, str):
|
||||
# Try to parse as NodeType
|
||||
@@ -82,7 +82,7 @@ class Graph:
|
||||
return self
|
||||
|
||||
def connect(
|
||||
self, source: str, target: str, data_type: Optional[str] = None
|
||||
self, source: str, target: str, data_type: str | None = None
|
||||
) -> "Graph":
|
||||
"""Add a connection between nodes."""
|
||||
if source not in self.nodes:
|
||||
@@ -99,7 +99,7 @@ class Graph:
|
||||
self.connect(names[i], names[i + 1])
|
||||
return self
|
||||
|
||||
def from_dict(self, data: Dict[str, Any]) -> "Graph":
|
||||
def from_dict(self, data: dict[str, Any]) -> "Graph":
|
||||
"""Load graph from dictionary (TOML-compatible)."""
|
||||
# Parse nodes
|
||||
nodes_data = data.get("nodes", {})
|
||||
@@ -127,7 +127,7 @@ class Graph:
|
||||
|
||||
return self
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
"""Convert graph to dictionary."""
|
||||
return {
|
||||
"nodes": {
|
||||
@@ -140,7 +140,7 @@ class Graph:
|
||||
],
|
||||
}
|
||||
|
||||
def validate(self) -> List[str]:
|
||||
def validate(self) -> list[str]:
|
||||
"""Validate graph structure and return list of errors."""
|
||||
errors = []
|
||||
|
||||
@@ -166,9 +166,8 @@ class Graph:
|
||||
|
||||
temp.add(node_name)
|
||||
for conn in self.connections:
|
||||
if conn.source == node_name:
|
||||
if has_cycle(conn.target):
|
||||
return True
|
||||
if conn.source == node_name and has_cycle(conn.target):
|
||||
return True
|
||||
temp.remove(node_name)
|
||||
visited.add(node_name)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user