Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

Add pipeline orchestration fixes and E2E tests

KaifAhmad188c12b18674c
diff --git a/semantica/core/orchestrator.py b/semantica/core/orchestrator.py
index 220ce5bb..475da752 100644
--- a/semantica/core/orchestrator.py
+++ b/semantica/core/orchestrator.py
@@ -302,7 +302,6 @@ class Semantica:
try:
self.logger.info("Executing processing pipeline")
- # Track pipeline execution
pipeline_tracking_id = self.progress_tracker.start_tracking(
file=str(data) if isinstance(data, (str, Path)) else None,
module="pipeline",
@@ -310,23 +309,39 @@ class Semantica:
message="Executing pipeline",
)
- # Validate pipeline
if isinstance(pipeline, dict):
pipeline = self._create_pipeline_from_dict(pipeline)
- # Validate pipeline object
- if not hasattr(pipeline, "execute"):
- raise ProcessingError("Pipeline must have execute() method")
+ execution_engine = None
+ execution_result = None
+
+ try:
+ from ..pipeline import ExecutionEngine, Pipeline
+
+ if isinstance(pipeline, Pipeline):
+ execution_engine = ExecutionEngine()
+ except ImportError:
+ execution_engine = None
+
+ if execution_engine is None and not hasattr(pipeline, "execute"):
+ raise ProcessingError(
+ "Pipeline must be a Pipeline object or have execute() method"
+ )
- # Allocate resources
resources = self._allocate_resources(pipeline)
try:
- # Execute pipeline
- result = pipeline.execute(data)
-
- # Collect metrics
- metrics = self._collect_metrics(pipeline)
+ if execution_engine is not None:
+ execution_result = execution_engine.execute_pipeline(
+ pipeline, data
+ )
+ success = execution_result.success
+ output = execution_result.output
+ metrics = execution_result.metrics
+ else:
+ output = pipeline.execute(data)
+ metrics = self._collect_metrics(pipeline)
+ success = True
if pipeline_tracking_id:
self.progress_tracker.stop_tracking(
@@ -334,8 +349,8 @@ class Semantica:
)
return {
- "success": True,
- "output": result,
+ "success": success,
+ "output": output,
"metrics": metrics,
"metadata": {
"pipeline": str(pipeline),
@@ -344,7 +359,6 @@ class Semantica:
}
finally:
- # Release resources
self._release_resources(resources)
except Exception as e:
@@ -567,13 +581,37 @@ class Semantica:
Pipeline object or configuration dict (if pipeline module not available)
"""
try:
- # Try to use PipelineBuilder if available
from ..pipeline import PipelineBuilder
pipeline_builder = PipelineBuilder()
- return pipeline_builder.build_from_config(pipeline_config)
+
+ if not pipeline_config:
+ pipeline_builder.add_step("default_step", "default")
+ return pipeline_builder.build("default_pipeline")
+
+ steps_config = pipeline_config.get("steps")
+
+ if isinstance(steps_config, list) and steps_config and isinstance(
+ steps_config[0], str
+ ):
+ converted_steps = [
+ {"name": name, "type": name, "config": {}}
+ for name in steps_config
+ ]
+ normalized_config: Dict[str, Any] = {
+ "name": pipeline_config.get("name", "default_pipeline"),
+ "steps": converted_steps,
+ }
+ if "parallelism" in pipeline_config:
+ normalized_config["parallelism"] = pipeline_config["parallelism"]
+ return pipeline_builder.build_pipeline(normalized_config)
+
+ if "steps" in pipeline_config:
+ return pipeline_builder.build_pipeline(pipeline_config)
+
+ pipeline_builder.add_step("default_step", "default")
+ return pipeline_builder.build("default_pipeline")
except ImportError:
- # Fallback: return config as-is if pipeline module not available
self.logger.debug("Pipeline module not available, using config directly")
return pipeline_config
diff --git a/tests/core/test_core_integration.py b/tests/core/test_core_integration.py
new file mode 100644
index 00000000..1fa85c90
--- /dev/null
+++ b/tests/core/test_core_integration.py
@@ -0,0 +1,98 @@
+import pytest
+
+from semantica import build as module_build
+from semantica.core import Semantica
+from semantica.core.methods import (
+ initialize_framework,
+ get_status,
+ run_pipeline,
+ build_knowledge_base,
+)
+
+
+pytestmark = pytest.mark.integration
+
+
+class DummyPipeline:
+ def __init__(self):
+ self.executed_with = None
+
+ def execute(self, data):
+ self.executed_with = data
+ return {"value": data}
+
+
+def test_initialize_and_get_status_integration():
+ framework = initialize_framework()
+ status = get_status(framework=framework, method="summary")
+ assert status["state"] in {"ready", "running", "initializing"}
+ assert "health" in status
+ framework.shutdown(graceful=True)
+
+
+def test_semantica_run_pipeline_with_dummy_pipeline():
+ pipeline = DummyPipeline()
+ framework = Semantica()
+ framework.initialize()
+ data = {"input": "value"}
+ result = framework.run_pipeline(pipeline, data)
+ assert result["success"] is True
+ assert result["output"] == {"value": data}
+ assert pipeline.executed_with == data
+ framework.shutdown(graceful=True)
+
+
+def test_core_methods_run_pipeline_with_dummy_pipeline():
+ pipeline = DummyPipeline()
+ data = "sample"
+ result = run_pipeline(pipeline, data)
+ assert result["success"] is True
+ assert result["output"] == {"value": data}
+
+
+def test_framework_build_knowledge_base_end_to_end(tmp_path):
+ source_path = tmp_path / "sample_e2e_framework.txt"
+ source_path.write_text("Apple Inc. is a technology company.")
+ framework = Semantica()
+ result = framework.build_knowledge_base(
+ sources=[str(source_path)],
+ embeddings=False,
+ graph=False,
+ pipeline={
+ "name": "e2e_pipeline",
+ "steps": [
+ {"name": "step1", "type": "default", "config": {}},
+ ],
+ },
+ )
+ stats = result["statistics"]
+ assert stats["sources_processed"] == 1
+ assert len(result["results"]) == 1
+ assert result["results"][0]["success"] is True
+ framework.shutdown(graceful=True)
+
+
+def test_core_methods_build_knowledge_base_end_to_end(tmp_path):
+ source_path = tmp_path / "sample_e2e_core_methods.txt"
+ source_path.write_text("Tim Cook leads Apple.")
+ result = build_knowledge_base(
+ sources=str(source_path),
+ method="minimal",
+ embeddings=False,
+ graph=False,
+ pipeline={"steps": ["step1", "step2"]},
+ )
+ stats = result["statistics"]
+ assert stats["sources_processed"] == 1
+ assert len(result["results"]) == 1
+ assert result["results"][0]["success"] is True
+
+
+def test_module_build_end_to_end_default_pipeline(tmp_path):
+ source_path = tmp_path / "sample_e2e_module_build.txt"
+ source_path.write_text("Sample data for end-to-end test.")
+ result = module_build(str(source_path), embeddings=False, graph=False)
+ stats = result["statistics"]
+ assert stats["sources_processed"] == 1
+ assert len(result["results"]) == 1
+ assert result["results"][0]["success"] is True
diff --git a/tests/ingest/test_cookbook_integration.py b/tests/ingest/test_cookbook_integration.py
index 92b32c16..c5120d65 100644
--- a/tests/ingest/test_cookbook_integration.py
+++ b/tests/ingest/test_cookbook_integration.py
@@ -4,6 +4,8 @@ from unittest.mock import MagicMock, patch
from semantica.ingest import MCPIngestor, ingest_mcp, DBIngestor, FileIngestor
from semantica.ingest.mcp_ingestor import MCPData
+pytestmark = pytest.mark.integration
+
class TestCookbookIntegration:
@pytest.fixture
diff --git a/tests/ingest/test_notebook_02.py b/tests/ingest/test_notebook_02.py
index 3db933f9..0cbb6a52 100644
--- a/tests/ingest/test_notebook_02.py
+++ b/tests/ingest/test_notebook_02.py
@@ -18,6 +18,8 @@ from semantica.ingest import (
MCPIngestor, IngestConfig, ingest_config
)
+pytestmark = pytest.mark.integration
+
class TestNotebook02DataIngestion:
def setup_method(self):
diff --git a/tests/ingest/test_notebook_06.py b/tests/ingest/test_notebook_06.py
index 38f4d1ee..61a46201 100644
--- a/tests/ingest/test_notebook_06.py
+++ b/tests/ingest/test_notebook_06.py
@@ -7,6 +7,8 @@ from semantica.ingest import FileIngestor, WebIngestor, DBIngestor, StreamIngest
from semantica.kg import GraphBuilder, EntityResolver, ProvenanceTracker
from semantica.conflicts import ConflictDetector
+pytestmark = pytest.mark.integration
+
class TestNotebook06MultiSourceIntegration:
def setup_method(self):
diff --git a/tests/normalize/test_integration.py b/tests/normalize/test_integration.py
index 01183083..073bf191 100644
--- a/tests/normalize/test_integration.py
+++ b/tests/normalize/test_integration.py
@@ -1,9 +1,14 @@
import unittest
import os
from datetime import datetime, timezone
+
+import pytest
+
from semantica.normalize import methods
from semantica.normalize.config import normalize_config
+pytestmark = pytest.mark.integration
+
class TestNormalizeIntegration(unittest.TestCase):
def test_normalize_text_integration(self):
text = "Hello World"
diff --git a/tests/ontology/test_notebook_14.py b/tests/ontology/test_notebook_14.py
index ed1e2b41..b2b9eb7d 100644
--- a/tests/ontology/test_notebook_14.py
+++ b/tests/ontology/test_notebook_14.py
@@ -1,5 +1,8 @@
import unittest
from unittest.mock import MagicMock, patch
+
+import pytest
+
from semantica.ontology import (
OntologyEngine,
ClassInferrer,
@@ -11,6 +14,8 @@ from semantica.ontology import (
)
from semantica.visualization import OntologyVisualizer
+pytestmark = pytest.mark.integration
+
class TestNotebook14(unittest.TestCase):
"""
Tests mirroring the steps in cookbook/introduction/14_Ontology.ipynb
diff --git a/tests/ontology/test_ontology_comprehensive.py b/tests/ontology/test_ontology_comprehensive.py
index e85ecf29..9541d9f3 100644
--- a/tests/ontology/test_ontology_comprehensive.py
+++ b/tests/ontology/test_ontology_comprehensive.py
@@ -1,7 +1,9 @@
-
import unittest
from unittest.mock import MagicMock, patch
from collections import defaultdict
+
+import pytest
+
from semantica.ontology.class_inferrer import ClassInferrer
from semantica.ontology.property_generator import PropertyGenerator
from semantica.ontology.naming_conventions import NamingConventions
@@ -10,6 +12,8 @@ from semantica.ontology.ontology_validator import OntologyValidator, ValidationR
from semantica.ontology.namespace_manager import NamespaceManager
from semantica.ontology.module_manager import ModuleManager
+pytestmark = pytest.mark.integration
+
class TestOntologyComprehensive(unittest.TestCase):
def setUp(self):
diff --git a/tests/parse/test_notebook_03.py b/tests/parse/test_notebook_03.py
index 5ad9dece..944f028f 100644
--- a/tests/parse/test_notebook_03.py
+++ b/tests/parse/test_notebook_03.py
@@ -1,10 +1,14 @@
-
import unittest
import os
import tempfile
import json
+
+import pytest
+
from semantica.parse import DocumentParser, CSVParser, JSONParser, XMLParser, HTMLParser, StructuredDataParser
+pytestmark = pytest.mark.integration
+
class TestNotebook03(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
diff --git a/tests/parse/test_parse_comprehensive.py b/tests/parse/test_parse_comprehensive.py
index f88dad21..9c7212ea 100644
--- a/tests/parse/test_parse_comprehensive.py
+++ b/tests/parse/test_parse_comprehensive.py
@@ -6,6 +6,8 @@ import json
import csv
from pathlib import Path
+import pytest
+
from semantica.parse.document_parser import DocumentParser, PDFParser, DOCXParser, HTMLParser
from semantica.parse.pptx_parser import PPTXParser
from semantica.parse.excel_parser import ExcelParser
@@ -17,6 +19,8 @@ from semantica.parse.web_parser import WebParser
from semantica.parse.registry import MethodRegistry
from semantica.parse.config import ParseConfig
+pytestmark = pytest.mark.integration
+
class TestParseComprehensive(unittest.TestCase):
def setUp(self):
diff --git a/tests/pipeline/test_notebook_07.py b/tests/pipeline/test_notebook_07.py
index f0d4800d..73f92afe 100644
--- a/tests/pipeline/test_notebook_07.py
+++ b/tests/pipeline/test_notebook_07.py
@@ -1,6 +1,9 @@
import unittest
from unittest.mock import MagicMock, patch
import time
+
+import pytest
+
from semantica.pipeline import (
PipelineBuilder,
ExecutionEngine,
@@ -10,6 +13,8 @@ from semantica.pipeline import (
RetryStrategy
)
+pytestmark = pytest.mark.integration
+
class TestNotebook07(unittest.TestCase):
def setUp(self):
diff --git a/tests/pipeline/test_pipeline_comprehensive.py b/tests/pipeline/test_pipeline_comprehensive.py
index 1792b431..a0b3f826 100644
--- a/tests/pipeline/test_pipeline_comprehensive.py
+++ b/tests/pipeline/test_pipeline_comprehensive.py
@@ -3,6 +3,8 @@ from unittest.mock import MagicMock, patch
import time
from typing import Dict, Any
+import pytest
+
from semantica.pipeline.pipeline_builder import PipelineBuilder, StepStatus, Pipeline
from semantica.pipeline.execution_engine import ExecutionEngine, PipelineStatus
from semantica.pipeline.failure_handler import (
@@ -11,6 +13,8 @@ from semantica.pipeline.failure_handler import (
from semantica.pipeline.parallelism_manager import ParallelismManager, Task
from semantica.pipeline.pipeline_validator import PipelineValidator
+pytestmark = pytest.mark.integration
+
class TestPipelineComprehensive(unittest.TestCase):
def setUp(self):
diff --git a/tests/test_all_features.py b/tests/test_all_features.py
index b0da7cf2..8225baa3 100644
--- a/tests/test_all_features.py
+++ b/tests/test_all_features.py
@@ -1,10 +1,10 @@
-
import unittest
import sys
import os
import numpy as np
-# Add project root to path
+import pytest
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from semantica.embeddings import EmbeddingGenerator, TextEmbedder
@@ -13,6 +13,8 @@ from semantica.vector_store import (
SearchRanker, NamespaceManager
)
+pytestmark = pytest.mark.integration
+
class TestSemanticaFeatures(unittest.TestCase):
def test_01_embedding_generation(self):
diff --git a/tests/test_notebook_15_export.py b/tests/test_notebook_15_export.py
index d3d32d57..bec2ad10 100644
--- a/tests/test_notebook_15_export.py
+++ b/tests/test_notebook_15_export.py
@@ -4,6 +4,8 @@ import tempfile
import unittest
from pathlib import Path
+import pytest
+
from semantica.kg import GraphBuilder
from semantica.export import (
JSONExporter,
@@ -12,6 +14,8 @@ from semantica.export import (
GraphExporter,
)
+pytestmark = pytest.mark.integration
+
class TestNotebook15Export(unittest.TestCase):
def setUp(self):
self.test_dir = tempfile.mkdtemp()
diff --git a/tests/test_notebooks_plain.py b/tests/test_notebooks_plain.py
index 026a11cd..cb446304 100644
--- a/tests/test_notebooks_plain.py
+++ b/tests/test_notebooks_plain.py
@@ -2,9 +2,12 @@ import sys
import os
import numpy as np
-# Add project root to path
+import pytest
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+pytestmark = pytest.mark.integration
+
def log(msg):
print(msg)
with open("test_progress.log", "a") as f:
diff --git a/tests/test_notebooks_repro.py b/tests/test_notebooks_repro.py
index 6684796e..c0915721 100644
--- a/tests/test_notebooks_repro.py
+++ b/tests/test_notebooks_repro.py
@@ -3,9 +3,12 @@ import sys
import os
import numpy as np
-# Add project root to path
+import pytest
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+pytestmark = pytest.mark.integration
+
class TestNotebooks(unittest.TestCase):
def test_12_embedding_generation(self):
diff --git a/tests/test_notebooks_simulation.py b/tests/test_notebooks_simulation.py
index 3848b391..7b414cea 100644
--- a/tests/test_notebooks_simulation.py
+++ b/tests/test_notebooks_simulation.py
@@ -6,6 +6,8 @@ import numpy as np
from pathlib import Path
from unittest.mock import MagicMock, patch
+import pytest
+
from semantica.kg import GraphBuilder
from semantica.export import (
JSONExporter,
@@ -24,6 +26,8 @@ from semantica.export import (
export_config
)
+pytestmark = pytest.mark.integration
+
class TestNotebooks(unittest.TestCase):
def setUp(self):
self.test_dir = tempfile.mkdtemp()
diff --git a/tests/test_notebooks_verification.py b/tests/test_notebooks_verification.py
index 2f1ad04c..0f0d8257 100644
--- a/tests/test_notebooks_verification.py
+++ b/tests/test_notebooks_verification.py
@@ -1,10 +1,10 @@
-
import unittest
import sys
import os
from pathlib import Path
-# Add project root to path
+import pytest
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from semantica.semantic_extract import (
@@ -17,6 +17,8 @@ from semantica.semantic_extract import (
)
from semantica.semantic_extract.methods import get_entity_method, get_relation_method
+pytestmark = pytest.mark.integration
+
class TestNotebooksVerification(unittest.TestCase):
"""
Test suite to verify the code snippets from the notebooks:
diff --git a/tests/test_pipeline_orchestration.py b/tests/test_pipeline_orchestration.py
index 2720735e..bfce1631 100644
--- a/tests/test_pipeline_orchestration.py
+++ b/tests/test_pipeline_orchestration.py
@@ -21,6 +21,8 @@ from semantica.pipeline import (
from semantica.pipeline.pipeline_builder import Pipeline, PipelineSerializer
from semantica.pipeline.execution_engine import ExecutionResult
+pytestmark = pytest.mark.integration
+
# --- Fixtures ---
@pytest.fixture
diff --git a/tests/test_semantic_extract_deepdive.py b/tests/test_semantic_extract_deepdive.py
index ecc587c7..c31d0f1e 100644
--- a/tests/test_semantic_extract_deepdive.py
+++ b/tests/test_semantic_extract_deepdive.py
@@ -3,7 +3,8 @@ import sys
import os
from unittest.mock import MagicMock, patch
-# Add project root to path
+import pytest
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")))
from semantica.semantic_extract.ner_extractor import NERExtractor, Entity
@@ -23,6 +24,8 @@ from semantica.semantic_extract.triple_extractor import (
)
from semantica.semantic_extract.methods import get_entity_method, get_relation_method
+pytestmark = pytest.mark.integration
+
class TestSemanticExtractDeepDive(unittest.TestCase):
def setUp(self):
diff --git a/tests/test_semantic_extract_deepdive_part2.py b/tests/test_semantic_extract_deepdive_part2.py
index 034a651f..a37eabdc 100644
--- a/tests/test_semantic_extract_deepdive_part2.py
+++ b/tests/test_semantic_extract_deepdive_part2.py
@@ -1,11 +1,11 @@
-
import unittest
import sys
import os
from unittest.mock import MagicMock, patch
from dataclasses import dataclass
-# Add project root to path
+import pytest
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from semantica.semantic_extract.named_entity_recognizer import (
@@ -22,6 +22,8 @@ from semantica.semantic_extract.methods import (
extract_triples_rules
)
+pytestmark = pytest.mark.integration
+
class TestSemanticExtractDeepDivePart2(unittest.TestCase):
def setUp(self):
diff --git a/tests/vector_store/test_vector_store_deepdive.py b/tests/vector_store/test_vector_store_deepdive.py
index c12dfc7c..5f579833 100644
--- a/tests/vector_store/test_vector_store_deepdive.py
+++ b/tests/vector_store/test_vector_store_deepdive.py
@@ -4,7 +4,8 @@ import numpy as np
import sys
from pathlib import Path
-# Add project root to path
+import pytest
+
sys.path.append(str(Path(__file__).parent.parent.parent))
from semantica.vector_store.vector_store import VectorStore, VectorIndexer, VectorRetriever, VectorManager
@@ -15,6 +16,8 @@ from semantica.vector_store.qdrant_adapter import QdrantAdapter
from semantica.vector_store.weaviate_adapter import WeaviateAdapter
from semantica.vector_store.hybrid_search import HybridSearch, MetadataFilter, SearchRanker
+pytestmark = pytest.mark.integration
+
class TestVectorStoreDeepDive(unittest.TestCase):
def setUp(self):
diff --git a/tests/verify_backends.py b/tests/verify_backends.py
index b04168fd..1982e6f5 100644
--- a/tests/verify_backends.py
+++ b/tests/verify_backends.py
@@ -5,7 +5,8 @@ import traceback
import logging
from typing import Any, Dict, List, Optional
-# Configure logging
+import pytest
+
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
logger = logging.getLogger("verify_backends")
@@ -15,6 +16,8 @@ except ImportError:
logger.error("Failed to import semantica. Make sure you are in the project root or semantica is installed.")
exit(1)
+pytestmark = pytest.mark.integration
+
def verify_backend(backend_name: str, config: Dict[str, Any]) -> bool:
logger.info(f"\n{'='*20} Verifying {backend_name.upper()} {'='*20}")
store = None
diff --git a/tests/verify_context_sync.py b/tests/verify_context_sync.py
index ff0b4b05..b9328912 100644
--- a/tests/verify_context_sync.py
+++ b/tests/verify_context_sync.py
@@ -3,11 +3,14 @@ import os
from typing import List, Dict, Any, Optional
from dataclasses import dataclass, field
-# Add project root to path
+import pytest
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from semantica.context import AgentContext, ContextGraph
+pytestmark = pytest.mark.integration
+
@dataclass
class VectorSearchResult:
id: str
diff --git a/tests/visualization/reproduce_notebooks.py b/tests/visualization/reproduce_notebooks.py
index 4437244b..db5ca9ac 100644
--- a/tests/visualization/reproduce_notebooks.py
+++ b/tests/visualization/reproduce_notebooks.py
@@ -1,4 +1,3 @@
-
import os
import sys
import unittest
@@ -6,6 +5,8 @@ import numpy as np
from datetime import datetime
import logging
+import pytest
+
# Add project root to path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
@@ -22,7 +23,8 @@ from semantica.kg import GraphBuilder, GraphAnalyzer, TemporalVersionManager
from semantica.ontology import OntologyGenerator
from semantica.embeddings import EmbeddingGenerator
-# Configure logging
+pytestmark = pytest.mark.integration
+
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("reproduce_notebooks")
diff --git a/tests/visualization/test_visualization_comprehensive.py b/tests/visualization/test_visualization_comprehensive.py
index c40027ad..82b79dd0 100644
--- a/tests/visualization/test_visualization_comprehensive.py
+++ b/tests/visualization/test_visualization_comprehensive.py
@@ -4,7 +4,8 @@ import sys
import numpy as np
from pathlib import Path
-# Mock heavy libraries before importing visualization modules
+import pytest
+
sys.modules['matplotlib'] = MagicMock()
sys.modules['matplotlib.pyplot'] = MagicMock()
sys.modules['matplotlib.colors'] = MagicMock()
@@ -31,6 +32,8 @@ from semantica.visualization.analytics_visualizer import AnalyticsVisualizer
from semantica.visualization.temporal_visualizer import TemporalVisualizer
from semantica.visualization.utils.color_schemes import ColorScheme
+pytestmark = pytest.mark.integration
+
class TestVisualizationComprehensive(unittest.TestCase):
def setUp(self):