repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | """Regression tests for base installs without optional embedding dependencies.""" |
| #2 | |
| #3 | import os |
| #4 | import subprocess |
| #5 | import sys |
| #6 | import textwrap |
| #7 | |
| #8 | |
| #9 | _BLOCK_OPTIONAL_DEPS = r""" |
| #10 | import importlib.abc |
| #11 | import sys |
| #12 | |
| #13 | class BlockOptionalEmbeddingDeps(importlib.abc.MetaPathFinder): |
| #14 | def find_spec(self, fullname, path=None, target=None): |
| #15 | if fullname == "numpy" or fullname.startswith("numpy."): |
| #16 | raise ModuleNotFoundError("No module named 'numpy'") |
| #17 | if fullname == "fastembed" or fullname.startswith("fastembed."): |
| #18 | raise ModuleNotFoundError("No module named 'fastembed'") |
| #19 | return None |
| #20 | |
| #21 | sys.meta_path.insert(0, BlockOptionalEmbeddingDeps()) |
| #22 | """ |
| #23 | |
| #24 | |
| #25 | def _run_with_optional_embedding_deps_blocked(code: str, tmp_path): |
| #26 | env = os.environ.copy() |
| #27 | env["MNEMOSYNE_DATA_DIR"] = str(tmp_path / "mnemosyne-data") |
| #28 | env["HOME"] = str(tmp_path / "home") |
| #29 | return subprocess.run( |
| #30 | [sys.executable, "-c", _BLOCK_OPTIONAL_DEPS + "\n" + code], |
| #31 | text=True, |
| #32 | capture_output=True, |
| #33 | env=env, |
| #34 | check=False, |
| #35 | ) |
| #36 | |
| #37 | |
| #38 | def test_embeddings_module_imports_without_numpy_or_fastembed(tmp_path): |
| #39 | result = _run_with_optional_embedding_deps_blocked( |
| #40 | textwrap.dedent( |
| #41 | """ |
| #42 | from mnemosyne.core import embeddings |
| #43 | |
| #44 | assert embeddings.available() is False |
| #45 | assert embeddings.embed_query("hello") is None |
| #46 | assert embeddings.embed(["hello"]) is None |
| #47 | """ |
| #48 | ), |
| #49 | tmp_path, |
| #50 | ) |
| #51 | |
| #52 | assert result.returncode == 0, result.stderr |
| #53 | |
| #54 | |
| #55 | def test_cli_stats_works_without_optional_embedding_dependencies(tmp_path): |
| #56 | result = _run_with_optional_embedding_deps_blocked( |
| #57 | textwrap.dedent( |
| #58 | """ |
| #59 | import sys |
| #60 | from mnemosyne.cli import run_cli |
| #61 | |
| #62 | sys.argv = ["mnemosyne", "stats"] |
| #63 | run_cli() |
| #64 | """ |
| #65 | ), |
| #66 | tmp_path, |
| #67 | ) |
| #68 | |
| #69 | assert result.returncode == 0, result.stderr |
| #70 | assert "Mnemosyne Stats" in result.stdout |
| #71 | assert "Traceback" not in result.stderr |
| #72 |