Skip to content

feat: document-graph — structured data ETL complement to lexical-graph#365

Open
evanerwee wants to merge 5 commits into
awslabs:mainfrom
evanerwee:add-document-graph-and-codeproperty-graph
Open

feat: document-graph — structured data ETL complement to lexical-graph#365
evanerwee wants to merge 5 commits into
awslabs:mainfrom
evanerwee:add-document-graph-and-codeproperty-graph

Conversation

@evanerwee

@evanerwee evanerwee commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds document-graph as a companion package to lexical-graph, providing deterministic schema-driven ETL of structured data (CSV, Excel, JSON, Parquet) into the same Neptune database. Addresses #356.

Changes

New package (document-graph/):

  • Namespace: graphrag_toolkit.document_graph (dist: graphrag-toolkit-document-graph)
  • 20+ transformers (normalizers, field, document, filter, graph constructors)
  • Schema providers (CSV, JSON, S3, Glue, static)
  • Graph build with Cypher generation + tenant-scoped labels
  • Query engine for typed node lookups with tenant isolation
  • Hybrid search integration with lexical-graph

Examples (examples/document-graph/):

  • 24 notebooks covering setup, pipelines, transformers, hybrid search
  • All outputs stripped

Alignment with Noel's Feedback (#356)

Item Status
1. Namespace under graphrag_toolkit/document_graph ✅ Done
2. Tenant labels via TenantId.format_label() ✅ Fixed — cypher_builder.py now uses lexical-graph's format
3. Lexical as optional dependency ✅ Standalone ETL works without lexical installed
4. Notebook outputs stripped ✅ All 24 notebooks clean

Tenant Label Fix (Key Change)

cypher_builder.py previously produced __Label__tenant__ format. Now uses TenantId.format_label() which produces `Label{tenant}__` — identical to lexical-graph. Falls back to same format when lexical-graph is not installed.

Testing

cd document-graph
pip install -e .
python -m pytest tests/

Ownership Commitment

We are actively using document-graph for a client engagement and will maintain it in lockstep with lexical-graph (API changes, versioning, bug fixes).

Checklist

  • Namespace matches graphrag-toolkit pattern
  • Tenant model aligned with lexical-graph
  • Lexical dependency is optional
  • Notebook outputs stripped
  • No sample/output data committed

Document-graph extends graphrag-toolkit with typed node support for structured
formats (CSV, Excel, JSON, Parquet, XML). It complements lexical-graph by handling
deterministic ETL while lexical-graph handles LLM-based extraction.

Key features:
- Schema providers (CSV, JSON, S3, Static, Glue) with auto-discovery
- 20+ transformers (normalizers, field, document, filter, graph, truncators)
- Cypher generation with tenant-scoped labels
- Query engine for typed node retrieval
- Multi-tenancy (same Neptune cluster, isolated by labels)
- Hybrid integration: index structured data into lexical-graph for semantic search

Coexists with lexical-graph in the same Neptune database:
- lexical-graph: unstructured text → Source/Chunk/Topic/Entity
- document-graph: structured data → typed nodes (__User__, __Account__, etc.)

59 tests passing. 100% docstring coverage. Sphinx docs included.
- 11 documentation pages (getting-started, lexical-graph-integration, pipeline,
  ingestors, schema-providers, transformers, graph-build, query-engine,
  multi-tenancy, examples index, API reference)
- 19 tested SageMaker notebooks covering all features
- Includes hybrid integration demos (document-graph + lexical-graph)
Two new packages for the graphrag-toolkit, following the existing namespace
and packaging pattern (byokg-rag):

document-graph: Structured data ingestion into Neptune
- Schema-driven pipeline: Extract → Transform → Load → Build
- Supports CSV, JSON, Parquet, Excel, XML, YAML
- Tenant-scoped labels via lexical-graph's TenantId.format_label()
- Batch-optimized Neptune writes (UNWIND)
- Plugin system (pluggy-based extension points)
- 58 unit tests passing
- 24 example notebooks (standalone ETL through hybrid graph)

codeproperty-graph: Delta-aware code analysis ingestion
- Full Joern CPG schema (20 node types, 14+ edge types, 9 languages)
- Delta comparison: skip Neptune writes when code unchanged
- S3 manifest-based state tracking
- from_joern() factory methods for parsing Joern exports
- Built on document-graph (DRY — ~200 lines domain code)
- 17 unit tests passing
- 2 example notebooks

Both packages:
- Apache-2.0 licensed
- AWS copyright headers on all source files
- graphrag_toolkit namespace (shared with lexical-graph, byokg-rag)
- No hardcoded account numbers, endpoints, or credentials
- CI workflows (license header check + pytest matrix)
- docs-site pages (Starlight/Astro MDX)
- Registered in root README, examples/README, docs-site index
- cypher_builder.py now uses lexical-graph's TenantId.format_label()
  producing backtick-quoted labels (`Label{tenant}__`) consistent
  with lexical-graph's format
- Falls back to same format when lexical-graph not installed (standalone ETL)
- Stripped notebook outputs from 11a/11b examples

Addresses feedback from noel-improv on awslabs#356 item 2 (tenant model alignment).
@evanerwee evanerwee changed the title Add document-graph and codeproperty-graph packages feat: document-graph — structured data ETL complement to lexical-graph Jul 6, 2026
- graph_loader.py: default batch_size 100→500
- delta_ingestor.py: accepts batch_size param, passes to GraphLoader
- pyproject.toml: version 0.4.2
- Added all modules from working 0.4.1 (artifact_reader, validator, etc.)
- __init__.py: full exports matching deployed wheel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant