Simple Pipeline
When to Use
Basic Pattern
from hypergraph import Graph, node, SyncRunner
@node(output_name="cleaned")
def clean(raw_data: str) -> str:
"""Remove whitespace and normalize."""
return raw_data.strip().lower()
@node(output_name="features")
def extract_features(cleaned: str) -> dict:
"""Extract features from cleaned text."""
return {
"length": len(cleaned),
"word_count": len(cleaned.split()),
"has_numbers": any(c.isdigit() for c in cleaned),
}
@node(output_name="result")
def classify(features: dict) -> str:
"""Classify based on features."""
if features["word_count"] > 100:
return "long_form"
return "short_form"
# Build the pipeline
pipeline = Graph([clean, extract_features, classify])
# Run it
runner = SyncRunner()
result = runner.run(pipeline, {"raw_data": " Hello World "})
print(result["cleaned"]) # "hello world"
print(result["features"]) # {"length": 11, "word_count": 2, "has_numbers": False}
print(result["result"]) # "short_form"How Edges Are Inferred
Inspecting the Graph
Multiple Inputs
Parallel Branches
Binding Values
Type Validation
What's Next?
Last updated