Skip to content

Commit c629be1

Browse files
committed
feat(pipeline): add high-level import→normalize→validate→MLIR API; add UIR normalizer; tests; keep ours in conflicts
1 parent a458ce3 commit c629be1

41 files changed

Lines changed: 13073 additions & 20 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/api/services/parser_service.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from parser import EdgeFlowParserError, parse_edgeflow_string, validate_config
44
from typing import Any, Dict, Tuple
55

6+
from edgeflow_ast import create_program_from_dict
7+
from edgeflow_ir import create_ir_from_config
8+
from error_reporter import EdgeFlowErrorReporter
9+
from static_validator import validate_edgeflow_config_static
10+
611

712
class ParserService:
813
"""Service for parsing EdgeFlow configurations in API context."""
@@ -26,3 +31,62 @@ def parse_config_content(content: str) -> Tuple[bool, Dict[str, Any], str]:
2631
return False, {}, str(e)
2732
except Exception as e: # noqa: BLE001
2833
return False, {}, f"Unexpected error: {str(e)}"
34+
35+
@staticmethod
36+
def parse_config_with_diagnostics(content: str) -> Dict[str, Any]:
37+
"""Parse content and return config, IR placeholder, and structured diagnostics.
38+
39+
This method is additive and does not change existing behavior.
40+
"""
41+
result: Dict[str, Any] = {
42+
"ok": False,
43+
"config": {},
44+
"diagnostics": [],
45+
"errors": "",
46+
"ast": None,
47+
"ir": None,
48+
}
49+
try:
50+
cfg = parse_edgeflow_string(content)
51+
result["config"] = cfg
52+
# Build AST from config dict
53+
try:
54+
program = create_program_from_dict(cfg)
55+
result["ast"] = program.to_dict()
56+
except Exception:
57+
result["ast"] = None
58+
# Run existing simple validation
59+
is_valid, errors = validate_config(cfg)
60+
if not is_valid:
61+
result["errors"] = "; ".join(errors)
62+
# Run static validator for richer issues
63+
static = validate_edgeflow_config_static(cfg)
64+
reporter = EdgeFlowErrorReporter()
65+
diags = []
66+
for issue in static.issues + static.warnings:
67+
rep = reporter.generate_error_report(issue)
68+
diags.append(
69+
{
70+
"id": rep.error_id,
71+
"severity": rep.severity.value,
72+
"category": rep.category.value,
73+
"title": rep.title,
74+
"message": rep.message,
75+
"hint": rep.suggestions[0] if rep.suggestions else None,
76+
}
77+
)
78+
result["diagnostics"] = diags
79+
# Build IR graph dictionary if parsing was okay
80+
try:
81+
graph = create_ir_from_config(cfg)
82+
result["ir"] = graph.to_dict()
83+
except Exception:
84+
result["ir"] = None
85+
result["ok"] = is_valid and static.is_valid
86+
return result
87+
except EdgeFlowParserError as e:
88+
result["errors"] = str(e)
89+
return result
90+
except Exception as e: # noqa: BLE001
91+
result["errors"] = f"Unexpected error: {str(e)}"
92+
return result

0 commit comments

Comments
 (0)