Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
review: add export_arango convenience function and unified export support
KaifAhmad196cb80245f06
diff --git a/semantica/export/__init__.py b/semantica/export/__init__.pyindex 934d8543..9b21b92b 100644--- a/semantica/export/__init__.py+++ b/semantica/export/__init__.py@@ -162,6 +162,7 @@ from .graph_exporter import GraphExporterfrom .json_exporter import JSONExporterfrom .lpg_exporter import LPGExporterfrom .methods import (+ export_arango,export_arrow,export_csv,export_graph,@@ -212,6 +213,7 @@ __all__ = ["export_owl","export_vector","export_lpg",+ "export_arango","generate_report","get_export_method","list_available_methods",diff --git a/semantica/export/methods.py b/semantica/export/methods.pyindex a0eb0fc5..0138199c 100644--- a/semantica/export/methods.py+++ b/semantica/export/methods.py@@ -155,6 +155,7 @@ from typing import Any, Callable, Dict, List, Optional, Unionfrom ..utils.exceptions import ConfigurationError, ProcessingErrorfrom ..utils.logging import get_logger+from .arango_aql_exporter import ArangoAQLExporterfrom .arrow_exporter import ArrowExporterfrom .config import export_configfrom .csv_exporter import CSVExporter@@ -619,6 +620,56 @@ def export_lpg(raise+def export_arango(+ knowledge_graph: Dict[str, Any],+ file_path: Union[str, Path],+ method: str = "default",+ **kwargs,+) -> None:+ """+ Export knowledge graph to ArangoDB AQL format (convenience function).++ This is a user-friendly wrapper that exports knowledge graphs to ArangoDB+ multi-model databases via AQL INSERT statements.++ Args:+ knowledge_graph: Knowledge graph dictionary with entities and relationships+ file_path: Output AQL file path+ method: Export method (default: "default")+ **kwargs: Additional options passed to ArangoAQLExporter:+ - vertex_collection: Override default vertex collection name+ - edge_collection: Override default edge collection name+ - batch_size: Batch size for INSERT operations+ - include_collection_creation: Whether to include collection creation statements++ Examples:+ >>> from semantica.export.methods import export_arango+ >>> export_arango(kg, "output.aql")+ >>> export_arango(kg, "graph.aql", vertex_collection="nodes", edge_collection="links")+ """+ # Check for custom method in registry+ custom_method = method_registry.get("arango", method)+ if custom_method and custom_method is not export_arango:+ try:+ return custom_method(knowledge_graph, file_path, **kwargs)+ except Exception as e:+ logger.warning(+ f"Custom method {method} failed: {e}, falling back to default"+ )++ try:+ # Get config+ config = export_config.get_method_config("arango")+ config.update(kwargs)++ exporter = ArangoAQLExporter(**config)+ exporter.export_knowledge_graph(knowledge_graph, file_path, **kwargs)++ except Exception as e:+ logger.error(f"Failed to export ArangoDB AQL: {e}")+ raise++def generate_report(data: Dict[str, Any],file_path: Union[str, Path],@@ -698,6 +749,7 @@ def export_knowledge_graph(- "yaml", "yml": YAML exporters- "owl": OWLExporter- "cypher": LPGExporter+ - "aql": ArangoAQLExportermethod: Optional specific export method**kwargs: Additional options passed to exporter@@ -724,6 +776,7 @@ def export_knowledge_graph(".yml": "yaml",".owl": "owl-xml",".cypher": "cypher",+ ".aql": "aql",}format = format_map.get(ext, "json")@@ -742,6 +795,8 @@ def export_knowledge_graph(export_owl(knowledge_graph, file_path, format=format, method=method, **kwargs)elif format == "cypher":export_lpg(knowledge_graph, file_path, method=method, **kwargs)+ elif format == "aql":+ export_arango(knowledge_graph, file_path, method=method, **kwargs)else:raise ProcessingError(f"Unknown export format: {format}")@@ -809,6 +864,8 @@ method_registry.register("vector", "json", export_vector)method_registry.register("vector", "numpy", export_vector)method_registry.register("lpg", "default", export_lpg)method_registry.register("lpg", "cypher", export_lpg)+method_registry.register("arango", "default", export_arango)+method_registry.register("arango", "aql", export_arango)method_registry.register("report", "default", generate_report)method_registry.register("report", "html", generate_report)method_registry.register("report", "markdown", generate_report)