Skip to content

fix: specifying a target version for a source does not actually install that version #651

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

Merged
merged 4 commits into from
Apr 4, 2025

Conversation

marcosmarxm
Copy link
Member

@marcosmarxm marcosmarxm commented Apr 3, 2025

Fixes #622

Example:

source = ab.get_source(
    name="source-faker",
    version="6.2.17",
    config={"count": SCALE / 2},
    install_if_missing=True,
)

PyAirbyte logs:

Installing 'source-faker' into virtual environment '/Users/m.marx/Code/playground/pyab/.venv-source-faker'.
Running 'pip install airbyte-source-faker==6.2.23'...

Collecting airbyte-source-faker==6.2.23
-----
AirbyteConnectorInstallationError: Connector's reported version does not match the target version.
    Connector Name: 'source-faker'
    Venv Name: '.venv-source-faker'
    Target Version: '6.2.17'
    Original Installed Version: None
    Version After Reinstall: '6.2.23'

With this change we make sure the pip_url uses the target version.
Also fix a possible bug in case users specify pip_url and version where it will install the static value of pip_url

source = ab.get_source(
    name="source-faker",
    pip_url="airbyte-source-faker",
    version="6.2.17",
    config={"count": SCALE / 2},
    install_if_missing=True,
)

Now it will throws an error alerting users to use pip_url OR version.

My initial idea was to change the following code:

self.pip_url = pip_url or (
metadata.pypi_package_name
if metadata and metadata.pypi_package_name
else f"airbyte-{self.name}"
)

But you'll always receive the pip_url and the executor doesn't have knowledge if it was the user or the (current code block) created the pip_url variable.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced validation for installation configuration to prevent conflicting inputs.
    • Updated the handling of package reference inputs so that version information is automatically integrated when provided.
    • Added error handling to prevent both version and pip_url from being specified simultaneously.
    • Updated function documentation to include a warning regarding cyclomatic complexity.

Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

This changeset updates the get_connector_executor function in airbyte/_executors/util.py. It introduces a conditional error check to raise a PyAirbyteInputError if both version and pip_url are provided. Additionally, the behavior for the InstallType.PYTHON case is modified to conditionally append the provided version to the pip_url. These modifications aim to prevent conflicting input parameters and ensure that the connector installation process uses the intended version.

Changes

File Change Summary
airbyte/_executors/util.py Added a conditional check to raise PyAirbyteInputError when both version and pip_url are provided; modified pip_url assignment to append version for InstallType.PYTHON.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Executor as get_connector_executor
    Note over Executor: Calculate install_method_count

    Caller->>Executor: Call get_connector_executor(version, pip_url, ...)
    alt Both version and pip_url provided
        Executor-->>Caller: Raise PyAirbyteInputError ("Both version and pip_url provided. Specify version in pip_url.")
    else Valid parameters provided
        Executor->>Executor: Process installation method
        alt InstallType.PYTHON and version provided
            Executor->>Executor: Append version to pip_url
        end
        Executor-->>Caller: Continue execution
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure the connector deploys with the specified target version (#622)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd541e4 and 4d7127b.

📒 Files selected for processing (1)
  • airbyte/_executors/util.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte/_executors/util.py
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (No Creds)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee5cb2d and 4182b65.

📒 Files selected for processing (1)
  • airbyte/_executors/util.py (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
airbyte/_executors/util.py (1)
airbyte/exceptions.py (1)
  • PyAirbyteInputError (201-210)
🪛 Ruff (0.8.2)
airbyte/_executors/util.py

154-154: Line too long (131 > 100)

(E501)


160-160: Blank line contains whitespace

Remove whitespace from blank line

(W293)

🪛 GitHub Actions: Run Linters
airbyte/_executors/util.py

[error] 1-1: Ruff formatting check failed. 1 file would be reformatted. Please run 'ruff format' to fix code style issues in this file.

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (No Creds)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
🔇 Additional comments (1)
airbyte/_executors/util.py (1)

211-211: Perfect fix for the version specification issue!

This line change is the heart of the fix - it ensures that when a user specifies a version, it's properly appended to the pip_url with the == syntax that pip requires for exact version installations. This directly addresses the issue where specifying a target version wasn't actually installing that version.

Before this change, the system would likely ignore the version parameter when constructing the pip command, which explains why it was installing a different version than requested.

@marcosmarxm marcosmarxm changed the title Fix when specifying a target version for a source does not actually install that version fix: specifying a target version for a source does not actually install that version Apr 3, 2025
Copy link
Contributor

@aaronsteers aaronsteers left a comment

Choose a reason for hiding this comment

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

Nice!!

@aaronsteers
Copy link
Contributor

aaronsteers commented Apr 3, 2025

/fix-pr

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.
(This job requires that the PR author has "Allow edits from maintainers" enabled.)

PR auto-fix job started... Check job output.

🟦 Job completed successfully (no changes).

@aaronsteers aaronsteers merged commit 1b339b2 into main Apr 4, 2025
19 checks passed
@aaronsteers aaronsteers deleted the marcos/fix-target-version branch April 4, 2025 16:11
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.

Specifying a target version for a source does not actually install that version
2 participants