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

chore: Add optional dependencies #241

Merged
merged 10 commits into from
Dec 2, 2024
Merged

Conversation

dexters1
Copy link
Collaborator

@dexters1 dexters1 commented Dec 2, 2024

Change intended optional dependencies to really be optional

List of optional dependencies added in PR:
qdrant,
neo4j,
weaviate,
falkordb,
langchain,
jupyter notebook,
posthog,
groq,
langfuse

Chore COG-595

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced installation instructions in the README for various database and vector store support options.
    • Updated dependency installation processes for Neo4j, Qdrant, and Weaviate to include optional extra dependencies.
  • Bug Fixes

    • Improved conditional checks in the database creation process for vector databases.
  • Chores

    • Updated dependency management in pyproject.toml to allow for optional dependencies, enhancing flexibility.

Change intended optional dependencies to really be optional

Chore COG-595
@dexters1 dexters1 self-assigned this Dec 2, 2024
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Warning

Rate limit exceeded

@dexters1 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 19c83a5 and ec65354.

Walkthrough

The pull request introduces changes to several workflow files for testing Neo4j, Qdrant, and Weaviate, updating dependency installation commands to include specific extras for each database. Additionally, the README.md file has been enhanced with detailed installation instructions for various database support options. Significant modifications are made to the PGVectorAdapter class and related database handling functions to support vector embeddings. The pyproject.toml file has been updated to manage optional dependencies more flexibly.

Changes

File Path Change Summary
.github/workflows/test_neo4j.yml Updated dependency installation command to include Neo4j extras.
.github/workflows/test_qdrant.yml Updated dependency installation command to include Qdrant extras.
.github/workflows/test_weaviate.yml Updated dependency installation command to include Weaviate extras.
README.md Enhanced installation instructions for Cognee framework, detailing commands for various databases.
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py Modified PGVectorAdapter to include vector column for embeddings and updated methods for vector handling.
cognee/infrastructure/databases/vector/pgvector/create_db_and_tables.py Added logic to conditionally create a database extension based on vector_db_provider.
pyproject.toml Updated dependencies to be optional and added new extras for better dependency management.

Possibly related PRs

Suggested reviewers

  • Vasilije1990
  • borisarzentar

🐰 In the garden where bunnies play,
New dependencies bloom today!
With Neo4j, Qdrant, and Weaviate,
Our setup's now first-rate!
Installation's clear, the path is bright,
Hop along, all feels just right! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Resolve issue with forced import of optional pgvector package.

Fix COG-595
Add install of optional databases packages for database gh actions

Fix COG-595
Switched falkordb and posthog to be optional dependencies

Chore COG-595
Update README.md with database optional dependencies

Chore COG-595
Added langchain as optional dependency

Chore COG-595
Update readme to be a bit more descriptive about installation

Chore COG-595
@dexters1 dexters1 marked this pull request as ready for review December 2, 2024 18:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)

Line range hint 70-85: Avoid duplicating the PGVectorDataPoint class definition

The PGVectorDataPoint class is defined within both the create_collection and create_data_points methods. This leads to code duplication and may cause maintenance challenges. Consider defining the class once, possibly at the class level or in a separate module, and reuse it across methods.

Apply this diff to refactor the class definition:

+from pgvector.sqlalchemy import Vector

+class PGVectorDataPoint(Base):
+    __tablename__ = None  # Will be set dynamically
+    __table_args__ = {"extend_existing": True}
+    # PGVector requires one column to be the primary key
+    primary_key: Mapped[int] = mapped_column(
+        primary_key=True, autoincrement=True
+    )
+    id: Mapped[Any]
+    payload = Column(JSON)
+    vector = Column(Vector(None))

+    def __init__(self, id, payload, vector):
+        self.id = id
+        self.payload = payload
+        self.vector = vector

Then, within your methods, set the appropriate attributes before using the class:

def create_collection(self, collection_name: str, payload_schema=None):
    PGVectorDataPoint.__tablename__ = collection_name
    vector_size = self.embedding_engine.get_vector_size()
    PGVectorDataPoint.vector.type.dim = vector_size
    # proceed with the rest of the method

def create_data_points(self, collection_name: str, data_points: List[DataPoint]):
    PGVectorDataPoint.__tablename__ = collection_name
    vector_size = self.embedding_engine.get_vector_size()
    PGVectorDataPoint.vector.type.dim = vector_size
    # proceed with the rest of the method
pyproject.toml (1)

92-92: Clarify the inclusion of notebook in both dev dependencies and extras

The notebook package is marked as optional in the [tool.poetry.group.dev.dependencies] section and is also included in the [tool.poetry.extras] section. This might lead to confusion about its intended usage. Consider:

  • If notebook is only for development purposes, keep it in dev.dependencies.
  • If it's meant to be an optional feature for users, include it in extras.
  • If both, ensure documentation clarifies its dual role.
README.md (1)

Line range hint 386-392: Enhance database compatibility information

Consider adding the following improvements to the implementation state table:

  1. Include minimum supported versions for each database
  2. Add known limitations or requirements for stable implementations
  3. Remove the HTML <style> tag as it's not standard markdown and may not work on all platforms

Here's a suggested format:

- <style>
-   table {
-     width: 100%;
-   }
- </style>
-
- | Name             | Type               | Current state     | Known Issues                          |
+ | Name             | Type               | Current state     | Supported Version | Known Issues      |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b0eb9af and 19c83a5.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .github/workflows/test_neo4j.yml (1 hunks)
  • .github/workflows/test_qdrant.yml (1 hunks)
  • .github/workflows/test_weaviate.yml (1 hunks)
  • README.md (3 hunks)
  • cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (2 hunks)
  • cognee/infrastructure/databases/vector/pgvector/create_db_and_tables.py (0 hunks)
  • pyproject.toml (3 hunks)
💤 Files with no reviewable changes (1)
  • cognee/infrastructure/databases/vector/pgvector/create_db_and_tables.py
🔇 Additional comments (6)
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)

Line range hint 109-125: Avoid duplicating the PGVectorDataPoint class definition

This is a duplicate of the earlier comment regarding the PGVectorDataPoint class being defined within methods. Refactoring as suggested will improve code maintainability.

.github/workflows/test_qdrant.yml (1)

50-50: Include qdrant extra in dependency installation

Adding the -E qdrant option ensures that the optional Qdrant dependencies are installed, which is necessary for the integration tests to run properly.

.github/workflows/test_weaviate.yml (1)

50-50: Include weaviate extra in dependency installation

Including the -E weaviate option in the installation command ensures that the Weaviate-specific dependencies are installed, enabling the integration tests to execute correctly.

.github/workflows/test_neo4j.yml (1)

49-49: Include neo4j extra in dependency installation

Adding -E neo4j to the poetry install command ensures that the Neo4j optional dependencies are included, which is necessary for the Neo4j integration tests.

pyproject.toml (1)

33-33: Optional dependencies correctly marked and extras defined

The dependencies like falkordb, qdrant-client, weaviate-client, neo4j, langchain_text_splitters, langsmith, posthog, asyncpg, and pgvector have been marked as optional, and corresponding extras have been defined. This allows users to install only the necessary dependencies based on their needs.

Also applies to: 46-46, 49-49, 52-52, 56-57, 59-59, 69-70, 80-81, 83-84

README.md (1)

Line range hint 23-85: Consider reordering database installation sections based on stability status

The installation sections show PostgreSQL first, but according to the implementation state table, it's marked as unstable. Consider reordering the sections to show stable implementations (Qdrant, Weaviate, Neo4j) first, followed by unstable ones (PostgreSQL) to better guide users toward recommended options.

Let's verify the stability status of each database integration:

@Vasilije1990 Vasilije1990 self-requested a review December 2, 2024 18:20
Added groq and langfuse as optional dependencies

Chore COG-595
@Vasilije1990 Vasilije1990 merged commit 1c47870 into main Dec 2, 2024
36 checks passed
@Vasilije1990 Vasilije1990 deleted the COG-595-optional-dependencies branch December 2, 2024 19:53
@coderabbitai coderabbitai bot mentioned this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants