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

fix: Async Retriever change url path for download retriever #192

Merged
merged 8 commits into from
Jan 14, 2025

Conversation

artem1205
Copy link
Contributor

@artem1205 artem1205 commented Dec 30, 2024

What

  • pass url as extra_field to ignore it in state manager
  • add transformations to download retriever

Caution

changing url path in stream_slice for download retriever is technically a breaking change, but I don't want to bump major version since AsyncRetriever is an ExperimentalClass

Reason

see #192 (comment)

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced StreamSlice class with boolean evaluation support
    • Improved record selector with customizable transformations
  • Improvements

    • Updated async HTTP job repository to provide more flexible stream slice construction
    • Refined URL retrieval mechanism in job processing tests

The changes introduce more dynamic and flexible data processing capabilities within the Airbyte CDK, allowing for more nuanced record transformations and stream handling.

@artem1205 artem1205 self-assigned this Dec 30, 2024
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
@artem1205 artem1205 changed the title ref: Async Retriever ref: Async Retriever change url path for download retriever Dec 30, 2024
@artem1205 artem1205 requested a review from brianjlai December 30, 2024 11:46
Signed-off-by: Artem Inzhyyants <[email protected]>
@artem1205 artem1205 marked this pull request as ready for review January 3, 2025 11:36
@artem1205 artem1205 changed the title ref: Async Retriever change url path for download retriever fix: Async Retriever change url path for download retriever Jan 3, 2025
@artem1205 artem1205 requested a review from brianjlai January 3, 2025 11:42
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

📝 Walkthrough

Walkthrough

This pull request introduces modifications across multiple files in the Airbyte CDK, focusing on enhancing record processing and stream slice handling. The changes primarily involve updating the create_async_retriever method to support transformations, modifying how stream slices are constructed in the AsyncHttpJobRepository, adding a boolean conversion method to StreamSlice, and adjusting a test case to reflect these changes.

Changes

File Change Summary
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Updated create_async_retriever to pass transformations to RecordSelector
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Modified fetch_records to construct stream_slice using job parameters
airbyte_cdk/sources/types.py Added __bool__ method to StreamSlice for boolean context evaluation
unit_tests/sources/declarative/requesters/test_http_job_repository.py Updated URL path access in test setup from stream_slice['url'] to stream_slice.extra_fields['url']

Sequence Diagram

sequenceDiagram
    participant Factory as ModelToComponentFactory
    participant Retriever as AsyncRetriever
    participant Selector as RecordSelector
    
    Factory->>Retriever: create_async_retriever()
    Retriever->>Selector: Initialize with transformations
    Selector-->>Retriever: Configured selector
Loading

Possibly related PRs

Suggested labels

bug, enhancement

Suggested reviewers

  • maxi297
  • darynaishchenko

Hey there! 👋 I noticed these changes look quite interesting. Would you like me to elaborate on any specific aspect of the modifications? Wdyt about the sequence of changes? 🤔


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (2)
airbyte_cdk/sources/types.py (1)

156-157: Should we consider extending the docstring for clarity?
Currently, the method is straightforward, but it might help future readers if we explained that a StreamSlice is considered truthy whenever its main or extra fields are non-empty. wdyt?

unit_tests/sources/declarative/requesters/test_http_job_repository.py (1)

87-87: Could we safeguard against missing 'url' in extra_fields?
When referencing {{stream_slice.extra_fields['url']}}, a KeyError could occur if 'url' is absent. Would it make sense to provide a default or fail gracefully? wdyt?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f8cb659 and 9d33042.

📒 Files selected for processing (4)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1 hunks)
  • airbyte_cdk/sources/types.py (1 hunks)
  • unit_tests/sources/declarative/requesters/test_http_job_repository.py (1 hunks)
🔇 Additional comments (2)
airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1)

192-197: Any concerns about overwriting an existing 'url' in extra_fields?
When merging extra_fields with {"url": url}, the new key unconditionally overrides. If the extra_fields dictionary already contained a url entry, it would be lost. Is this desired, or should we handle it differently? wdyt?

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1)

2257-2257: Are transformations intended for all download operations?
We are passing transformations=transformations into the RecordSelector for the download retriever. Should we allow users to configure a distinct transformations list exclusively for downloads? wdyt?

Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

📝 Walkthrough

Walkthrough

This pull request introduces modifications across multiple files in the Airbyte CDK, focusing on enhancing record processing and stream slice handling. The changes primarily affect the ModelToComponentFactory, AsyncHttpJobRepository, and StreamSlice classes, with updates to how transformations are applied, job parameters are processed, and stream slices are evaluated in boolean contexts.

Changes

File Change Summary
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Modified create_async_retriever to pass transformations to RecordSelector instead of an empty list
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Updated fetch_records method to construct stream_slice using job parameters and additional context
airbyte_cdk/sources/types.py Added __bool__ method to StreamSlice for boolean context evaluation
unit_tests/sources/declarative/requesters/test_http_job_repository.py Updated URL retrieval in test to use stream_slice.extra_fields['url']

Sequence Diagram

sequenceDiagram
    participant Factory as ModelToComponentFactory
    participant Selector as RecordSelector
    participant Job as AsyncHttpJobRepository
    participant Slice as StreamSlice

    Factory->>Selector: Create with transformations
    Job->>Slice: Construct with job parameters
    Slice-->>Job: Provide context for record fetching
Loading

Possibly related PRs

Suggested labels

bug, enhancement

Suggested reviewers

  • maxi297
  • aldogonzalez8

Hey there! 👋 I noticed these changes look quite interesting. Would you like me to elaborate on any specific aspect of the modifications? The transformation handling and stream slice updates seem particularly intriguing. Wdyt? 🤔


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (3)
airbyte_cdk/sources/types.py (1)

155-157: Would you consider expanding the docstring to explain the new boolean evaluation?

Currently, __bool__ returns true if either the main slice or extra_fields is non-empty. It might be helpful to clarify this in the docstring or comment, so future maintainers understand why it’s deemed “truthy” if either portion is present. wdyt?

airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1)

192-197: Would you consider verifying whether the “url” key already exists in job_slice.extra_fields?

Merging "url" into extra_fields might accidentally overwrite a name collision. Checking this in advance or documenting the assumption could prevent unexpected behavior. wdyt?

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1)

2257-2257: Any interest in logging or clarifying transformations usage here?

We’re now passing transformations to the SimpleRetriever’s RecordSelector. It might be good to describe in code comments how these transformations are applied when reading job results. wdyt?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f8cb659 and 9d33042.

📒 Files selected for processing (4)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1 hunks)
  • airbyte_cdk/sources/types.py (1 hunks)
  • unit_tests/sources/declarative/requesters/test_http_job_repository.py (1 hunks)
🔇 Additional comments (1)
unit_tests/sources/declarative/requesters/test_http_job_repository.py (1)

87-87: Could we handle missing “url” more gracefully?

In path="{{stream_slice.extra_fields['url']}}", a KeyError could arise if 'url' is absent from extra_fields. Perhaps we could add a default or an assertion? wdyt?

@artem1205 artem1205 requested a review from maxi297 January 7, 2025 12:11
@artem1205 artem1205 merged commit e3f904a into main Jan 14, 2025
23 of 24 checks passed
@artem1205 artem1205 deleted the artem1205/ref-asyncretriever-behaviour branch January 14, 2025 16:48
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.

3 participants