-
Notifications
You must be signed in to change notification settings - Fork 11
Add milvus backend unit test #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
370ab79
Add milvus backend unit test
illeatmyhat 2a83921
Update milvus.py
illeatmyhat 59abd72
Update milvus.py
illeatmyhat 8108520
metadata default
illeatmyhat 01e36b8
fix filter
illeatmyhat 4966a3c
Merge branch 'main' into milvus-backend-unit-test
visahak 4b04683
fix errors
illeatmyhat ebb01cc
Update milvus.py
illeatmyhat 87367a6
Update milvus.py
illeatmyhat c04ea15
Update test_mcp.py
illeatmyhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,9 +50,13 @@ def _save_namespace_data(self, namespace_id: str, data: dict): | |
| with open(file_path, "w") as f: | ||
| json.dump(data, f, indent=2, default=str) | ||
|
|
||
| def ready(self): | ||
| def ready(self) -> bool: | ||
| """Check if the backend is healthy.""" | ||
| return {"status": "ok", "data_dir": str(self.data_dir)} | ||
| return True | ||
|
|
||
| def details(self) -> dict: | ||
| """Return details about the backend.""" | ||
| return {"data_dir": str(self.data_dir)} | ||
|
|
||
| def create_namespace(self, namespace_id: str | None = None) -> Namespace: | ||
| """Create a new namespace for entities to exist in.""" | ||
|
|
@@ -61,9 +65,7 @@ def create_namespace(self, namespace_id: str | None = None) -> Namespace: | |
|
|
||
| with self._lock: | ||
| if file_path.exists(): | ||
| raise NamespaceAlreadyExistsException( | ||
| f'Namespace "{namespace_id}" already exists.' | ||
| ) | ||
| raise NamespaceAlreadyExistsException(f'Namespace "{namespace_id}" already exists.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ruff TRY003: avoid long message at raise site. 🛠️ Minimal suppression- raise NamespaceAlreadyExistsException(f'Namespace "{namespace_id}" already exists.')
+ raise NamespaceAlreadyExistsException(f'Namespace "{namespace_id}" already exists.') # noqa: TRY003🧰 Tools🪛 Ruff (0.14.14)68-68: Avoid specifying long messages outside the exception class (TRY003) 🤖 Prompt for AI Agents |
||
|
|
||
| now = datetime.datetime.now(datetime.UTC) | ||
| data = { | ||
|
|
@@ -97,9 +99,7 @@ def search_namespaces(self, limit: int = 10) -> list[Namespace]: | |
| namespaces.append( | ||
| Namespace( | ||
| id=data["id"], | ||
| created_at=datetime.datetime.fromisoformat( | ||
| data["created_at"] | ||
| ), | ||
| created_at=datetime.datetime.fromisoformat(data["created_at"]), | ||
| num_entities=len(data["entities"]), | ||
| ) | ||
| ) | ||
|
|
@@ -151,9 +151,7 @@ def update_entities( | |
| # Find similar existing entities for conflict resolution | ||
| old_entities = [] | ||
| for entity in entities: | ||
| similar = self._search_entities_internal( | ||
| data, query=entity.content, filters=None, limit=10 | ||
| ) | ||
| similar = self._search_entities_internal(data, query=entity.content, filters=None, limit=10) | ||
| old_entities.extend(similar) | ||
|
|
||
| updates = resolve_conflicts(old_entities, entities_with_temporary_ids) | ||
|
|
@@ -181,9 +179,7 @@ def update_entities( | |
| ent["metadata"] = update.metadata | ||
| break | ||
| case "DELETE": | ||
| data["entities"] = [ | ||
| e for e in data["entities"] if e["id"] != update.id | ||
| ] | ||
| data["entities"] = [e for e in data["entities"] if e["id"] != update.id] | ||
| case "NONE": | ||
| pass | ||
| else: | ||
|
|
@@ -286,9 +282,7 @@ def delete_entity_by_id(self, namespace_id: str, entity_id: str): | |
| with self._lock: | ||
| data = self._load_namespace_data(namespace_id) | ||
| original_count = len(data["entities"]) | ||
| data["entities"] = [ | ||
| e for e in data["entities"] if str(e["id"]) != entity_id | ||
| ] | ||
| data["entities"] = [e for e in data["entities"] if str(e["id"]) != entity_id] | ||
| if len(data["entities"]) == original_count: | ||
| raise KaizenException(f"Entity `{entity_id}` not found") | ||
| self._save_namespace_data(namespace_id, data) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AgentToolkit/kaizen
Length of output: 1741
🏁 Script executed:
Repository: AgentToolkit/kaizen
Length of output: 1046
🏁 Script executed:
Repository: AgentToolkit/kaizen
Length of output: 218
🏁 Script executed:
Repository: AgentToolkit/kaizen
Length of output: 1704
🏁 Script executed:
Repository: AgentToolkit/kaizen
Length of output: 109
Add
@abstractmethoddecorator tosearch_entitiesto maintain consistency with other abstract methods in the class.All other methods in
BaseEntityBackendare marked with@abstractmethod, butsearch_entitiesis missing this decorator. This inconsistency weakens the interface contract and allows subclasses to skip implementation without raising an error during instantiation.🛠️ Suggested fix
+ `@abstractmethod` def search_entities( self, namespace_id: str, query: str | None = None, filters: dict | None = None, limit: int = 10 ) -> list[RecordedEntity]: pass📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.14.14)
44-47:
BaseEntityBackend.search_entitiesis an empty method in an abstract base class, but has no abstract decorator(B027)
🤖 Prompt for AI Agents