Commit
·
06e7156
1
Parent(s):
7e91f1d
Fix Mermaid syntax error and enhance hero section
Browse files- Add sanitize_mermaid_text() to escape special characters in node names
- Fixes "Syntax error in text" when using Local Demo MCP with parentheses in names
- Update hero section with feature table and quick start guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
|
@@ -378,6 +378,21 @@ def parse_metadata_to_graph(metadata_text: str, source_type: str) -> Tuple[Linea
|
|
| 378 |
return graph, f"Error parsing metadata: {str(e)}"
|
| 379 |
|
| 380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
def generate_mermaid_from_graph(graph: LineageGraph) -> str:
|
| 382 |
"""Generate Mermaid diagram code from a LineageGraph."""
|
| 383 |
if not graph.nodes:
|
|
@@ -414,18 +429,21 @@ def generate_mermaid_from_graph(graph: LineageGraph) -> str:
|
|
| 414 |
if len(categories) > 1:
|
| 415 |
for cat, nodes in categories.items():
|
| 416 |
if cat != "default":
|
| 417 |
-
lines.append(f" subgraph {cat.replace('_', ' ').title()}")
|
| 418 |
for node in nodes:
|
| 419 |
-
|
|
|
|
| 420 |
lines.append(f" {node.id}{shape}")
|
| 421 |
lines.append(" end")
|
| 422 |
else:
|
| 423 |
for node in nodes:
|
| 424 |
-
|
|
|
|
| 425 |
lines.append(f" {node.id}{shape}")
|
| 426 |
else:
|
| 427 |
for node in graph.nodes:
|
| 428 |
-
|
|
|
|
| 429 |
lines.append(f" {node.id}{shape}")
|
| 430 |
|
| 431 |
# Add edges
|
|
@@ -755,8 +773,21 @@ with gr.Blocks(
|
|
| 755 |
|
| 756 |
**AI-powered data lineage extraction and visualization for modern data platforms**
|
| 757 |
|
| 758 |
-
|
| 759 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 760 |
|
| 761 |
---
|
| 762 |
""")
|
|
|
|
| 378 |
return graph, f"Error parsing metadata: {str(e)}"
|
| 379 |
|
| 380 |
|
| 381 |
+
def sanitize_mermaid_text(text: str) -> str:
|
| 382 |
+
"""Sanitize text for use in Mermaid diagrams by escaping special characters."""
|
| 383 |
+
if not text:
|
| 384 |
+
return "Unknown"
|
| 385 |
+
# Replace characters that conflict with Mermaid syntax
|
| 386 |
+
# Parentheses conflict with node shapes, brackets with labels
|
| 387 |
+
text = text.replace("(", " - ").replace(")", "")
|
| 388 |
+
text = text.replace("[", " ").replace("]", " ")
|
| 389 |
+
text = text.replace("{", " ").replace("}", " ")
|
| 390 |
+
text = text.replace('"', "'")
|
| 391 |
+
text = text.replace("<", "").replace(">", "")
|
| 392 |
+
text = text.replace("#", "")
|
| 393 |
+
return text.strip()
|
| 394 |
+
|
| 395 |
+
|
| 396 |
def generate_mermaid_from_graph(graph: LineageGraph) -> str:
|
| 397 |
"""Generate Mermaid diagram code from a LineageGraph."""
|
| 398 |
if not graph.nodes:
|
|
|
|
| 429 |
if len(categories) > 1:
|
| 430 |
for cat, nodes in categories.items():
|
| 431 |
if cat != "default":
|
| 432 |
+
lines.append(f" subgraph {sanitize_mermaid_text(cat.replace('_', ' ').title())}")
|
| 433 |
for node in nodes:
|
| 434 |
+
safe_name = sanitize_mermaid_text(node.name)
|
| 435 |
+
shape = f"[{safe_name}]" if node.type in ["table", "model"] else f"({safe_name})"
|
| 436 |
lines.append(f" {node.id}{shape}")
|
| 437 |
lines.append(" end")
|
| 438 |
else:
|
| 439 |
for node in nodes:
|
| 440 |
+
safe_name = sanitize_mermaid_text(node.name)
|
| 441 |
+
shape = f"[{safe_name}]" if node.type in ["table", "model"] else f"({safe_name})"
|
| 442 |
lines.append(f" {node.id}{shape}")
|
| 443 |
else:
|
| 444 |
for node in graph.nodes:
|
| 445 |
+
safe_name = sanitize_mermaid_text(node.name)
|
| 446 |
+
shape = f"[{safe_name}]" if node.type in ["table", "model"] else f"({safe_name})"
|
| 447 |
lines.append(f" {node.id}{shape}")
|
| 448 |
|
| 449 |
# Add edges
|
|
|
|
| 773 |
|
| 774 |
**AI-powered data lineage extraction and visualization for modern data platforms**
|
| 775 |
|
| 776 |
+
### What You Can Do
|
| 777 |
+
|
| 778 |
+
| Feature | Description |
|
| 779 |
+
|---------|-------------|
|
| 780 |
+
| **Extract Lineage** | Parse metadata from dbt manifests, Airflow DAGs, SQL DDL, BigQuery, and custom JSON |
|
| 781 |
+
| **Visualize** | Generate interactive Mermaid diagrams with color-coded nodes and relationship labels |
|
| 782 |
+
| **Export** | Export to enterprise data catalogs: OpenLineage, Collibra, Microsoft Purview, Alation |
|
| 783 |
+
| **MCP Integration** | Connect to MCP servers for AI-powered metadata extraction |
|
| 784 |
+
|
| 785 |
+
### Quick Start
|
| 786 |
+
|
| 787 |
+
1. **Try the Demo**: Enable "Use MCP Server" and select "Local Demo MCP" to fetch sample lineage metadata
|
| 788 |
+
2. **Use Your Data**: Paste your dbt manifest, Airflow DAG, or custom JSON in the Text/File tab
|
| 789 |
+
3. **Load Samples**: Click "Load Sample" in the Demo Gallery to explore pre-built examples
|
| 790 |
+
4. **Export**: Use the Export section to generate catalog-ready JSON
|
| 791 |
|
| 792 |
---
|
| 793 |
""")
|