udpate chromadb import to be lazy #27
@ -91,7 +91,19 @@ class BlogFlow(Flow[BlogFlowState]):
|
||||
|
||||
@staticmethod
|
||||
def _get_chroma_client() -> "chromadb.HttpClient":
|
||||
import chromadb
|
||||
# Lazily import chromadb here rather than at module level.
|
||||
# chromadb unconditionally loads hnswlib (a native C++ library
|
||||
# compiled with AVX instructions) even when using HttpClient
|
||||
# to talk to an external ChromaDB server. Deferring the import
|
||||
# avoids "Illegal instruction" (SIGILL) crashes in environments
|
||||
# that lack AVX support (e.g. act, older CI runners).
|
||||
try:
|
||||
import chromadb
|
||||
except ImportError as exc:
|
||||
raise RuntimeError(
|
||||
"chromadb is required for the editor phase but could not be "
|
||||
f"imported: {exc}"
|
||||
) from exc
|
||||
|
||||
chroma_port = int(os.environ["CHROMA_PORT"])
|
||||
return chromadb.HttpClient(host=os.environ["CHROMA_HOST"], port=chroma_port)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user