Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix: break pipeline circular import (#192, #193) and update changelog

KaifAhmad18671385cbf8b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33a01fe9..9823f725 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,12 +17,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **API Parameter Handling**:
- Limited kwargs forwarded in chunked extraction helper to prevent parameter leakage
- Ensured minimal, safe parameters are passed to provider calls
+- **Pipeline Circular Import (Issues #192, #193)**:
+ - Fixed circular import between `pipeline_builder` and `pipeline_validator` triggered during `semantica.pipeline` import
+ - Lazy-loaded `PipelineValidator` inside `PipelineBuilder.__init__` and guarded type hints with `TYPE_CHECKING`
+ - Ensured `from semantica.deduplication import DuplicateDetector` no longer fails even when pipeline module is imported
### Added
- **Comprehensive Test Suite**:
- Added unit tests (`tests/test_relations_llm.py`) with mocked LLM provider covering both typed and structured response paths
- Added integration tests (`tests/integration/test_relations_groq.py`) for real Groq API calls with environment variable API key
- Tests validate relation extraction completion and result parsing across different response formats
+- **Amazon Neptune Dev Environment**:
+ - Added CloudFormation template (`cookbook/introduction/neptune-setup.yaml`) to provision a dev Neptune cluster with public endpoint and IAM auth enabled
+ - Documented deployment, cost estimates, and IAM User vs IAM Role best practices in `cookbook/introduction/21_Amazon_Neptune_Store.ipynb`
+ - Added `cfn-lint` to `.pre-commit-config.yaml` for validating CloudFormation templates while excluding `neptune-setup.yaml` from generic YAML linters
### Changed
- **Relation Extraction API**:
diff --git a/semantica/pipeline/pipeline_builder.py b/semantica/pipeline/pipeline_builder.py
index 29d2de0a..22a2e21c 100644
--- a/semantica/pipeline/pipeline_builder.py
+++ b/semantica/pipeline/pipeline_builder.py
@@ -32,12 +32,14 @@ License: MIT
from dataclasses import dataclass, field
from enum import Enum
-from typing import Any, Callable, Dict, List, Optional, Union
+from typing import Any, Callable, Dict, List, Optional, Union, TYPE_CHECKING
from ..utils.exceptions import ProcessingError, ValidationError
from ..utils.logging import get_logger
from ..utils.progress_tracker import get_progress_tracker
-from .pipeline_validator import PipelineValidator
+
+if TYPE_CHECKING:
+ from .pipeline_validator import PipelineValidator
class StepStatus(Enum):
@@ -104,6 +106,8 @@ class PipelineBuilder:
if not self.progress_tracker.enabled:
self.progress_tracker.enabled = True
+ from .pipeline_validator import PipelineValidator
+
self.validator = PipelineValidator(**self.config)
self.steps: List[PipelineStep] = []
self.step_registry: Dict[str, Callable] = {}
diff --git a/tests/pipeline/test_pipeline.py b/tests/pipeline/test_pipeline.py
index 56368c90..3dc7f530 100644
--- a/tests/pipeline/test_pipeline.py
+++ b/tests/pipeline/test_pipeline.py
@@ -107,5 +107,25 @@ class TestPipelineModule(unittest.TestCase):
self.assertEqual(execution_order, ["A", "B", "C"])
+ def test_imports_no_circular_dependencies(self):
+ import semantica
+
+ _ = semantica.pipeline
+
+ from semantica.pipeline import PipelineBuilder, PipelineValidator
+ from semantica.deduplication import DuplicateDetector
+
+ builder = PipelineBuilder()
+ builder.add_step("step1", "dummy")
+ pipeline = builder.build("import_test_pipeline")
+
+ validator = PipelineValidator()
+ result = validator.validate_pipeline(pipeline)
+
+ self.assertTrue(result.valid)
+
+ detector = DuplicateDetector()
+ self.assertIsNotNone(detector)
+
if __name__ == "__main__":
unittest.main()