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: Remove deprecated pyscopg v2 (pyscopg2) #532

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Nov 16, 2024

Summary by CodeRabbit

  • New Features

    • Updated PostgreSQL connection URL format to utilize the psycopg driver for enhanced database interactions.
  • Bug Fixes

    • Adjusted dependency management for improved compatibility and stability across libraries, including updates to various dependency version constraints.
  • Tests

    • Modified test connection URL format to align with the new PostgreSQL connection method.

Copy link

vercel bot commented Nov 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pyairbyte-api-docs ❌ Failed (Inspect) Nov 16, 2024 5:44am

@aaronsteers aaronsteers changed the title chore: remove deprecated pyscopg2 Chore: Remove deprecated pyscopg2 Nov 16, 2024
@aaronsteers aaronsteers changed the title Chore: Remove deprecated pyscopg2 Chore: Remove deprecated pyscopg v2 (pyscopg2) Nov 16, 2024
@aaronsteers aaronsteers marked this pull request as ready for review November 16, 2024 05:47
Copy link

coderabbitai bot commented Nov 16, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily involve updates to the PostgreSQL connection handling within the PostgresConfig class and related testing configurations. The SQLAlchemy URL scheme has been modified to use postgresql+psycopg, indicating a shift to the psycopg driver. Additionally, the pyproject.toml file has seen adjustments in dependency management, including the removal of psycopg2-binary and tightening version constraints for several libraries. The testing function for PostgreSQL connections has also been updated to reflect the new URL format.

Changes

File Change Summary
airbyte/_processors/sql/postgres.py Updated get_sql_alchemy_url method to return a URL using the postgresql+psycopg scheme.
pyproject.toml Removed psycopg2-binary, updated version constraints for numpy, sqlalchemy, and sqlalchemy-bigquery.
tests/conftest.py Modified test_pg_connection function to use the postgresql+psycopg scheme for the PostgreSQL connection URL.

Possibly related PRs

  • Chore: Bump to Sqlalchemy 2.0 #396: The changes in this PR involve modifications to SQLAlchemy types, which may relate to the overall handling of SQLAlchemy connections and types, similar to the changes made in the main PR regarding the SQLAlchemy URL format.
  • Chore(deps): Update psycopg to ^3.1.19 for macOS <14 compatibility #538: This PR updates the psycopg dependency, which is directly relevant to the main PR's change in the SQLAlchemy URL scheme to use psycopg, indicating a connection in the context of database interaction.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fe45f96 and a7e9d73.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • airbyte/_processors/sql/postgres.py (2 hunks)
  • tests/conftest.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/conftest.py
  • airbyte/_processors/sql/postgres.py

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 or @coderabbitai title 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.

Copy link

@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 (2)
airbyte/_processors/sql/postgres.py (1)

32-32: Consider adding migration notes

Since we're moving from psycopg2 to psycopg3, should we add a note in the docstring about this significant change? This could help users understand the migration path. wdyt? 🤔

Here's a suggestion for the docstring:

    def get_sql_alchemy_url(self) -> SecretString:
-        """Return the SQLAlchemy URL to use."""
+        """Return the SQLAlchemy URL to use.
+        
+        Note: As of version X.Y.Z, we use psycopg3 instead of psycopg2. 
+        For migration details, see: <link-to-docs>
+        """
tests/conftest.py (1)

140-142: LGTM! Quick suggestion about URL readability

The URL change from postgresql to postgresql+psycopg looks good and aligns with removing psycopg2! 🎉

What do you think about extracting the URL components into variables for better readability? Something like this:

-    pg_url = (
-        f"postgresql+psycopg://postgres:postgres@{host}:{PYTEST_POSTGRES_PORT}/postgres"
-    )
+    scheme = "postgresql+psycopg"
+    credentials = "postgres:postgres"
+    database = "postgres"
+    pg_url = f"{scheme}://{credentials}@{host}:{PYTEST_POSTGRES_PORT}/{database}"

This would make it easier to modify individual components in the future. WDYT?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 13f8dd6 and a8ea2a0.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • airbyte/_processors/sql/postgres.py (1 hunks)
  • pyproject.toml (0 hunks)
  • tests/conftest.py (1 hunks)
💤 Files with no reviewable changes (1)
  • pyproject.toml
🔇 Additional comments (1)
airbyte/_processors/sql/postgres.py (1)

32-32: Verify SQLAlchemy compatibility with psycopg3

The URL scheme change looks good! Just want to double-check SQLAlchemy compatibility with the new driver. Mind if we verify this? 🤔

✅ Verification successful

SQLAlchemy and psycopg3 compatibility looks great! 👍

The verification shows everything is properly configured:

  • SQLAlchemy version constraint (>=1.4.51,!=2.0.36,<3.0) is compatible with psycopg3
  • psycopg3 is correctly specified with required extras: psycopg = {extras = ["binary", "pool"], version = "^3.2.2"}
  • The URL scheme change is consistent across the codebase (both in main code and tests)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check SQLAlchemy and psycopg version constraints in project dependencies

# Check for SQLAlchemy version specification
rg -l "sqlalchemy" pyproject.toml requirements*.txt setup*.py

# Check for psycopg version specification
rg -l "psycopg[^2]" pyproject.toml requirements*.txt setup*.py

Length of output: 380


Script:

#!/bin/bash
# Let's check the actual content of pyproject.toml for version constraints
cat pyproject.toml

# Also search for any SQLAlchemy usage patterns in the codebase
ast-grep --pattern 'create_engine($_)'

# And check for any existing SQLAlchemy connection strings
rg "postgresql\+" -A 2 -B 2

Length of output: 11833

@aaronsteers
Copy link
Contributor Author

aaronsteers commented Nov 19, 2024

/poetry-lock

poetry lock job started... Check job output.

poetry lock applied successfully.

Resolving dependencies... changes
@aaronsteers aaronsteers enabled auto-merge (squash) November 19, 2024 05:36
@aaronsteers
Copy link
Contributor Author

aaronsteers commented Dec 2, 2024

/poetry-lock

poetry lock job started... Check job output.

poetry lock applied successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant