Skip to content

feat(AsyncRetriever): slice information during the polling request, Support creation_response interpolation in body #541

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aldogonzalez8
Copy link
Contributor

@aldogonzalez8 aldogonzalez8 commented May 10, 2025

  • AsyncRetriever:
    • Having access to slice information during the polling request
    • Support creation_response interpolation in body

Resolves: https://github.com/airbytehq/airbyte-internal-issues/issues/12875

Summary by CodeRabbit

  • Refactor

    • Improved internal logic for building request contexts and stream slices, resulting in more consistent handling of job parameters and interpolation contexts.
  • Tests

    • Refactored test setup for better maintainability.
    • Added a new test to verify correct handling of stream slice information during job status updates.

@aldogonzalez8 aldogonzalez8 self-assigned this May 10, 2025
@aldogonzalez8 aldogonzalez8 requested a review from maxi297 May 10, 2025 00:38
@github-actions github-actions bot added the enhancement New feature or request label May 10, 2025
@aldogonzalez8 aldogonzalez8 requested a review from brianjlai May 10, 2025 00:38
Copy link
Contributor

coderabbitai bot commented May 10, 2025

📝 Walkthrough

Walkthrough

This update refactors internal logic for constructing interpolation contexts and stream slices in the Airbyte CDK's declarative HTTP job repository and request input providers. It introduces a helper for creating job repositories in tests, adds a new test case for stream slice access, and consolidates error handler usage.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Refactored _get_create_job_stream_slice to return a StreamSlice using job parameters' partition and cursor_slice, and merged extra_fields with the job's extra_fields and a new creation_response key.
airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py,
airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py
Replaced manual dictionary construction for interpolation context with the get_interpolation_context utility in both input provider modules.
unit_tests/sources/declarative/requesters/test_http_job_repository.py Refactored test setup by introducing _create_async_job_repository helper, added _ERROR_HANDLER constant, and implemented a new test to verify stream slice information in polling requests. No changes to existing test assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Case
    participant Repo as AsyncHttpJobRepository
    participant Requester as HttpRequester
    participant Server as Mocked HTTP Server

    Test->>Repo: Create repository via _create_async_job_repository()
    Test->>Repo: Trigger job status update
    Repo->>Requester: Prepare polling request with stream_slice['path']
    Requester->>Server: Send HTTP request (with interpolated path)
    Server-->>Requester: Return job status response
    Requester-->>Repo: Provide response
    Repo-->>Test: Job status updated (assertion)
Loading

Suggested labels

enhancement

Suggested reviewers

  • maxi297

Would you consider extracting the new test's polling requester logic into a reusable fixture for clarity and reuse in future tests, wdyt?

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 d7ebfd9 and 9c7e66f.

📒 Files selected for processing (4)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py (2 hunks)
  • airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py (2 hunks)
  • unit_tests/sources/declarative/requesters/test_http_job_repository.py (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
airbyte_cdk/sources/declarative/requesters/http_job_repository.py (2)
airbyte_cdk/sources/types.py (4)
  • StreamSlice (75-169)
  • partition (99-104)
  • cursor_slice (107-112)
  • extra_fields (115-117)
airbyte_cdk/sources/declarative/async_job/job.py (1)
  • job_parameters (46-47)
unit_tests/sources/declarative/requesters/test_http_job_repository.py (6)
airbyte_cdk/sources/message/repository.py (1)
  • MessageRepository (45-60)
airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py (1)
  • DefaultErrorHandler (26-147)
airbyte_cdk/sources/types.py (4)
  • StreamSlice (75-169)
  • partition (99-104)
  • cursor_slice (107-112)
  • get (146-147)
airbyte_cdk/sources/declarative/requesters/http_requester.py (1)
  • HttpRequester (37-478)
airbyte_cdk/sources/declarative/requesters/requester.py (1)
  • HttpMethod (18-26)
airbyte_cdk/sources/declarative/requesters/http_job_repository.py (3)
  • start (151-166)
  • update_jobs_status (168-202)
  • AsyncHttpJobRepository (34-350)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
🔇 Additional comments (11)
airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py (2)

11-11: Good addition of the utility import.

The import of get_interpolation_context is a nice improvement that will help standardize interpolation context creation across the codebase.


55-58: Nice refactoring to use the utility function.

Good job replacing the manual dictionary construction with a call to get_interpolation_context. This improves code consistency and maintainability. It aligns with the PR objective to enable access to more context during the request process.

airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py (2)

14-14: Good addition of the utility import.

The import of get_interpolation_context is a nice improvement that will help standardize interpolation context creation across the codebase.


56-59: Nice refactoring to use the utility function.

Good job replacing the manual dictionary construction with a call to get_interpolation_context. This improves code consistency and maintainability. The pattern is consistent with the changes in other input providers.

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

323-330: Great enhancement to incorporate all stream slice components.

This is a key improvement that fulfills both PR objectives:

  1. It enables access to slice information during polling by preserving the original partition and cursor_slice
  2. It adds support for creation_response interpolation by including it in the extra_fields

By properly utilizing the StreamSlice class with all its components (partition, cursor_slice, extra_fields), you've created a more robust solution that maintains backward compatibility while adding new functionality.

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

5-5: Good addition of the Optional import.

Adding this import is necessary for the type annotation in the new helper method.


32-33: Good import updates.

These imports are needed for the refactored setup code and new test.


51-51: Nice refactoring to define the error handler as a constant.

Creating a constant for the error handler that's used in multiple places improves code maintainability.


56-56: Good refactoring to use the helper method.

Replacing the verbose setup code with a call to the helper method makes the test more maintainable.


85-112: Excellent new test for stream slice access during polling.

This test directly validates the first PR objective - accessing slice information during the polling request. It confirms that:

  1. Stream slice keys like 'path' can be accessed via string interpolation
  2. This information is correctly passed to the polling requester
  3. The integration with the creation_response works properly

The test is well-structured, testing the exact scenario needed for the feature.


214-318: Great refactoring to extract repository creation logic.

The helper method improves code organization and reusability by:

  1. Centralizing the creation of all components (requesters, extractors, etc.)
  2. Allowing customization through parameters (like the custom polling requester)
  3. Reducing duplication across tests

This makes the tests more maintainable and easier to extend, which is particularly valuable for complex components like AsyncHttpJobRepository.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

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

🚢

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

Successfully merging this pull request may close these issues.

2 participants