Some checks failed
CI / lint (push) Successful in 33s
CI / notebooks-smoke (push) Successful in 1m45s
Deploy / notebooks (push) Successful in 6m3s
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Infra CI / notebooks (push) Successful in 1m2s
Infra CI / zotero (push) Successful in 14s
Infra CI / docs (push) Successful in 27s
Infra CI / api (push) Successful in 1m7s
Infra CI / llm (push) Successful in 48s
Infra CI / mc (push) Successful in 13s
Deploy / report (push) Successful in 15s
CI / test (push) Failing after 21m36s
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""#720: the notebooks container installs the workspace without the
|
|
``llm`` extra (no langchain, no sqlalchemy). ``llm.config``,
|
|
``llm.links`` and ``llm.lineage`` must import there anyway — the pool
|
|
exports are resolved lazily, and ``llm.evidence`` only touches
|
|
sqlalchemy when a pgvector query actually runs."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
_PROBE = """
|
|
import sys, builtins
|
|
_real = builtins.__import__
|
|
def _fake(name, *a, **k):
|
|
if name.split('.')[0] in {'langchain_core', 'langchain_postgres', 'langchain_ollama', 'sqlalchemy'}:
|
|
raise ModuleNotFoundError(name)
|
|
return _real(name, *a, **k)
|
|
builtins.__import__ = _fake
|
|
import llm.config, llm.links, llm.lineage, llm.evidence # must not need langchain/sqlalchemy
|
|
import llm
|
|
print('ok', llm.LlmConfig.__name__)
|
|
"""
|
|
|
|
|
|
def test_config_links_lineage_evidence_import_without_langchain_or_sqlalchemy():
|
|
r = subprocess.run(
|
|
[sys.executable, "-c", _PROBE], capture_output=True, text=True, check=False
|
|
)
|
|
assert r.returncode == 0, r.stderr[-800:]
|
|
assert "ok LlmConfig" in r.stdout
|
|
|
|
|
|
def test_pool_exports_resolve_lazily():
|
|
llm = importlib.import_module("llm")
|
|
assert llm.HostPool.__name__ == "HostPool"
|
|
assert llm.PoolEmbeddings.__name__ == "PoolEmbeddings"
|
|
with pytest.raises(AttributeError):
|
|
_ = llm.NoSuchName
|