Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix: align doctor AGFS check with bundled pyagfs (#1044)

Jiahui Zhouca9a6ccc9d00
diff --git a/openviking/__init__.py b/openviking/__init__.py
index b107a2c80..d0ada80d5 100644
--- a/openviking/__init__.py
+++ b/openviking/__init__.py
@@ -18,10 +18,11 @@ except ImportError:
try:
from openviking.pyagfs import AGFSClient
-except ImportError:
+except ImportError as exc:
raise ImportError(
- "pyagfs not found. Please install: pip install -e third_party/agfs/agfs-sdk/python"
- )
+ "Bundled OpenViking AGFS client is unavailable. "
+ "Reinstall openviking or run 'pip install -e .' from the project root."
+ ) from exc
def __getattr__(name: str):
diff --git a/openviking_cli/doctor.py b/openviking_cli/doctor.py
index 130fd262a..e31c944e3 100644
--- a/openviking_cli/doctor.py
+++ b/openviking_cli/doctor.py
@@ -9,6 +9,7 @@ native vector engine, AGFS, embedding provider, VLM provider, and disk space.
from __future__ import annotations
+import importlib
import json
import os
import platform
@@ -127,16 +128,16 @@ def check_native_engine() -> tuple[bool, str, Optional[str]]:
def check_agfs() -> tuple[bool, str, Optional[str]]:
- """Verify pyagfs module loads."""
+ """Verify the bundled OpenViking AGFS client loads."""
try:
- import pyagfs
+ pyagfs = importlib.import_module("openviking.pyagfs")
version = getattr(pyagfs, "__version__", "unknown")
- return True, f"pyagfs {version}", None
+ return True, f"AGFS SDK {version}", None
except ImportError:
return (
False,
- "pyagfs module not found",
+ "Bundled AGFS client not found",
"pip install openviking --upgrade --force-reinstall",
)
diff --git a/tests/cli/test_doctor.py b/tests/cli/test_doctor.py
index 8a580f17f..e8f56dffc 100644
--- a/tests/cli/test_doctor.py
+++ b/tests/cli/test_doctor.py
@@ -111,17 +111,30 @@ class TestCheckAgfs:
assert isinstance(ok, bool)
assert isinstance(detail, str)
+ def test_pass_when_only_vendored_openviking_pyagfs_is_available(self):
+ real_import = __import__
+
+ def import_side_effect(name, globals=None, locals=None, fromlist=(), level=0):
+ if name == "pyagfs":
+ raise ImportError("No module named 'pyagfs'")
+ return real_import(name, globals, locals, fromlist, level)
+
+ with patch("builtins.__import__", side_effect=import_side_effect):
+ ok, detail, fix = check_agfs()
+
+ assert ok
+ assert "AGFS" in detail
+ assert fix is None
+
def test_fail_when_missing(self):
- with patch.dict(sys.modules, {"pyagfs": None}):
- # Force ImportError by removing from sys.modules
- saved = sys.modules.pop("pyagfs", None)
- try:
- with patch("builtins.__import__", side_effect=_import_fail("pyagfs")):
- ok, detail, fix = check_agfs()
- assert not ok
- finally:
- if saved is not None:
- sys.modules["pyagfs"] = saved
+ with patch(
+ "openviking_cli.doctor.importlib.import_module",
+ side_effect=ImportError("No module named 'openviking.pyagfs'"),
+ ):
+ ok, detail, fix = check_agfs()
+ assert not ok
+ assert "Bundled AGFS client not found" in detail
+ assert fix is not None
class TestCheckEmbedding: