notebooks: code_families.py sections 5 and 7b crash in the notebooks container (llm package needs langchain; LLM_DB_PASSWORD not provided) #720
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom (notebooks container, marimo://code_families.py cell-14 and the 7b cell):
and section 5 falls back to its 'LLM_DB_PASSWORD not set' note because the notebooks service never receives the password.
Causes. (1)
llm/__init__.pyeagerly importsHostPool/PoolEmbeddings, so importingllm.configorllm.lineagedrags in langchain even though those modules never need it; the notebooks image installs the workspace without thellmextra. (2) The notebook cells importllm.*unguarded, so a missing module is a traceback, not a note — the Task 8 guard only covered the env var. (3)compose.ymlpasses noLLM_DB_PASSWORD/LLM_PG_HOSTtonotebooks, so section 5's chunk-per-collection counts can never run there.Fix. Make
llm/__init__lazy for the pool exports (module__getattr__), sollm.config,llm.lineage,llm.linksimport with the base deps (section 7b then works replica-only); guard both cells with try/except ImportError → an explanatory note; passLLM_DB_PASSWORDandLLM_PG_HOST=postgresto the notebooks service so section 5 counts chunks when pgvector is reachable (the container is on thedata/storagenetworks); add the notebooks-container run to the nightly notebook set's expectations. Done when both cells render inside thenotebookscontainer (headlessmarimo exportin-container) and tests cover the import guard.Fixed on main. (1) llm/init resolves HostPool/PoolEmbeddings lazily and llm.evidence imports sqlalchemy only when a pgvector query runs, so llm.config/llm.links/llm.lineage/llm.evidence import without langchain or sqlalchemy (test: tests/llm/test_init_lazy.py runs a subprocess that blocks those modules). (2) Both notebook cells guard their imports: 7b renders a note instead of a traceback when the llm package cannot be imported; section 5 distinguishes 'client not installed' from 'password not set'. (3) compose.yml passes LLM_DB_PASSWORD and LLM_PG_HOST=postgres to the notebooks service; the notebooks image adds sqlalchemy + psycopg[binary] so section 5 can count chunks. Verified inside the running notebooks container (bind-mounted src): lineage_evidence('history of 99490') builds 57 events with labels, headless export has no traceback. Section 5's chunk counts need the image rebuild + container recreate (docker compose build notebooks && docker compose up -d notebooks); until then it shows its note.
Verified after the image rebuild + recreate (fhirworx/notebooks:latest, 2026-09-11): inside the notebooks container sqlalchemy 2.0.52 and psycopg 3.3.5 are present, LLM_DB_PASSWORD/LLM_PG_HOST are set, and section 5's pgvector query returns the CCM chunk counts (comments 949, corpus 1,179, rules 428); section 7b builds the timeline (57 events for 99490). Headless export in-container has no traceback. Closing.