Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional dependencies are not actually optional #187

Closed
saevarb opened this issue Mar 6, 2024 · 2 comments
Closed

Optional dependencies are not actually optional #187

saevarb opened this issue Mar 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@saevarb
Copy link

saevarb commented Mar 6, 2024

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 jamescalam added the bug Something isn't working label Mar 8, 2024
@jamescalam
Copy link
Member

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
Copy link
Member

We fixed the issue (there were several cases of this issue) in #190 — hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants