Optional dependencies are not actually optional
Closed this issue · 2 comments
saevarb commented
In pyproject.toml, a good deal of dependencies are marked optional, and for good reason. However, these are not actually optional. They are all imported unconditionally which will cause a runtime crash whenever an "optional" dependency is not present.
jamescalam commented
We should be capturing these like with the pinecone imports in pinecone.py like:
def _initialize_client(self, api_key: Optional[str] = None):
try:
from pinecone import Pinecone, ServerlessSpec
self.ServerlessSpec = ServerlessSpec
except ImportError:
raise ImportError(
"Please install pinecone-client to use PineconeIndex. "
"You can install it with: "
"`pip install 'semantic-router[pinecone]'`"
)
Where are you seeing this not happen?
jamescalam commented
We fixed the issue (there were several cases of this issue) in #190 — hope this helps!