forked from genewildish/Mainline
docs(graph): Add DSL documentation and examples
Add comprehensive documentation for the graph-based pipeline DSL: - docs/graph-dsl.md: Complete DSL reference with TOML, Python, and CLI syntax - docs/GRAPH_SYSTEM_SUMMARY.md: Implementation overview and architecture - examples/graph_dsl_demo.py: Demonstrates imperative Python API usage - examples/test_graph_integration.py: Integration test verifying pipeline execution The documentation follows a wiki-like approach with navigable structure: - Overview section explaining the concept - Syntax examples for each format (TOML, Python, CLI) - Node type reference table - Advanced features section - Comparison with old XYZStage approach This provides users with multiple entry points to understand and use the new graph-based pipeline system.
This commit is contained in:
110
examples/test_graph_integration.py
Normal file
110
examples/test_graph_integration.py
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify graph-based pipeline integration.
|
||||
|
||||
This script tests that the graph DSL can be used to create working pipelines
|
||||
that produce output similar to preset-based pipelines.
|
||||
"""
|
||||
|
||||
from engine.effects.plugins import discover_plugins
|
||||
from engine.pipeline.graph_toml import load_pipeline_from_toml
|
||||
from engine.pipeline.params import PipelineParams
|
||||
|
||||
|
||||
def test_graph_pipeline_execution():
|
||||
"""Test that a graph-based pipeline can execute and produce output."""
|
||||
print("=== Testing Graph Pipeline Execution ===")
|
||||
|
||||
# Discover plugins
|
||||
discover_plugins()
|
||||
|
||||
# Load pipeline from TOML
|
||||
pipeline = load_pipeline_from_toml(
|
||||
"examples/pipeline_graph.toml", viewport_width=80, viewport_height=24
|
||||
)
|
||||
|
||||
print(f"Pipeline loaded with {len(pipeline._stages)} stages")
|
||||
print(f"Stages: {list(pipeline._stages.keys())}")
|
||||
|
||||
# Initialize pipeline
|
||||
if not pipeline.initialize():
|
||||
print("Failed to initialize pipeline")
|
||||
return False
|
||||
|
||||
print("Pipeline initialized successfully")
|
||||
|
||||
# Set up context
|
||||
ctx = pipeline.context
|
||||
params = PipelineParams(viewport_width=80, viewport_height=24)
|
||||
ctx.params = params
|
||||
|
||||
# Execute pipeline with empty items (source will provide content)
|
||||
result = pipeline.execute([])
|
||||
|
||||
if result.success:
|
||||
print(f"Pipeline executed successfully")
|
||||
print(f"Output type: {type(result.data)}")
|
||||
if isinstance(result.data, list):
|
||||
print(f"Output lines: {len(result.data)}")
|
||||
if len(result.data) > 0:
|
||||
print(f"First line: {result.data[0][:50]}...")
|
||||
return True
|
||||
else:
|
||||
print(f"Pipeline execution failed: {result.error}")
|
||||
return False
|
||||
|
||||
|
||||
def test_graph_vs_preset():
|
||||
"""Compare graph-based and preset-based pipelines."""
|
||||
print("\n=== Comparing Graph vs Preset ===")
|
||||
|
||||
from engine.pipeline import get_preset
|
||||
|
||||
# Load graph-based pipeline
|
||||
graph_pipeline = load_pipeline_from_toml(
|
||||
"examples/pipeline_graph.toml", viewport_width=80, viewport_height=24
|
||||
)
|
||||
|
||||
# Load preset-based pipeline (using test-basic as a base)
|
||||
preset = get_preset("test-basic")
|
||||
if not preset:
|
||||
print("test-basic preset not found")
|
||||
return False
|
||||
|
||||
# Create pipeline from preset config
|
||||
from engine.pipeline import Pipeline
|
||||
|
||||
preset_pipeline = Pipeline(config=preset.to_config())
|
||||
|
||||
print(f"Graph pipeline stages: {len(graph_pipeline._stages)}")
|
||||
print(f"Preset pipeline stages: {len(preset_pipeline._stages)}")
|
||||
|
||||
# Compare stage types
|
||||
graph_stage_types = {
|
||||
name: stage.__class__.__name__ for name, stage in graph_pipeline._stages.items()
|
||||
}
|
||||
preset_stage_types = {
|
||||
name: stage.__class__.__name__
|
||||
for name, stage in preset_pipeline._stages.items()
|
||||
}
|
||||
|
||||
print("\nGraph pipeline stages:")
|
||||
for name, stage_type in graph_stage_types.items():
|
||||
print(f" - {name}: {stage_type}")
|
||||
|
||||
print("\nPreset pipeline stages:")
|
||||
for name, stage_type in preset_stage_types.items():
|
||||
print(f" - {name}: {stage_type}")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success1 = test_graph_pipeline_execution()
|
||||
success2 = test_graph_vs_preset()
|
||||
|
||||
if success1 and success2:
|
||||
print("\n✓ All tests passed!")
|
||||
else:
|
||||
print("\n✗ Some tests failed")
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user