Skip to content

fix: (CDK) (AsyncRetriever) - Add polling_timeout optional field #428

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 2 commits into from
Mar 17, 2025

Conversation

bazarnov
Copy link
Contributor

@bazarnov bazarnov commented Mar 17, 2025

What

Resolving:

How

Summary of Changes

  • declarative_component_schema.yaml:

    • Updated Description:
      • Removed the experimental notice from the AsyncRetriever description.
      • Corrected a typo in the AddFields class description.
    • Added polling_timeout property to AsyncRetriever with a description and support for integer and string types.
  • model_to_component_factory.py:

    • Removed unused ConnectionDefinition import.
    • Added _get_job_timeout method to determine job timeout.
  • http_job_repository.py:

    • Added Property: Added job_timeout property to the AsyncHttpJobRepository class.
  • async_retriever.py:

    • Removed Deprecated Warning: Removed deprecated decorator and ExperimentalClassWarning from the AsyncRetriever class.

User Impact

No impact is expected. This is not a breaking change.

Summary by CodeRabbit

  • New Features
    • Added a configurable timeout option for asynchronous operations, allowing users to specify a maximum wait period.
    • Enhanced timeout handling with dynamic logging during job initiation for improved clarity.
    • Stabilized the asynchronous record retrieval component by removing its experimental warning.
  • Documentation
    • Refined component descriptions for better clarity on asynchronous settings and timeout behavior.

@bazarnov bazarnov self-assigned this Mar 17, 2025
@github-actions github-actions bot added bug Something isn't working security labels Mar 17, 2025
@bazarnov bazarnov marked this pull request as ready for review March 17, 2025 16:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors and extends the AsyncRetriever component by adding an optional polling_timeout field and making related adjustments across the CDK. Key changes include:

  • Updating the Pydantic model and YAML schema for AsyncRetriever with a new polling_timeout property.
  • Removing deprecated warnings from the AsyncRetriever class.
  • Adjusting the HTTPJobRepository and model-to-component factory to incorporate job_timeout based on polling_timeout.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Updated AddFields description and added polling_timeout to AsyncRetriever.
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Revised AsyncRetriever description and introduced polling_timeout property.
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Updated job_timeout comment and enhanced the create job message to include job_timeout.
airbyte_cdk/sources/declarative/retrievers/async_retriever.py Removed deprecated decorator and ExperimentalClassWarning.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Added _get_job_timeout helper and passed job_timeout to AsyncHttpJobRepository.
Comments suppressed due to low confidence (1)

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:2942

  • [nitpick] Consider renaming variables like 'test_read_timeout' and 'default_sync_timeout' to names that more clearly indicate their purpose in distinguishing connector builder behavior from default sync timeouts.
def _get_job_timeout() -> datetime.timedelta:

Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

📝 Walkthrough

Walkthrough

This pull request refines the AsyncRetriever component by updating its documentation, adding a new polling_job_timeout configuration, and revising the timeout handling logic. Changes include modifications in the YAML schema and Python model to remove the experimental warning, introduce the polling_job_timeout property, and adjust descriptions. Additionally, it incorporates a new function for computing job timeouts and propagates these settings to the HTTP job repository. The deprecation warning on the AsyncRetriever class has also been removed.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml
airbyte_cdk/sources/declarative/models/declarative_component_schema.py
Updated AsyncRetriever documentation by removing the experimental warning and adding a new polling_job_timeout property; corrected AddFields description by removing an extraneous comma.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Introduced a _get_job_timeout() function that calculates the job timeout from the polling_timeout setting with default values; removed the unused ConnectionDefinition import.
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Added an optional job_timeout attribute to the AsyncHttpJobRepository and updated the log message to include timeout information during job creation.
airbyte_cdk/sources/declarative/retrievers/async_retriever.py Removed the @deprecated decorator from the AsyncRetriever class, eliminating its experimental warning.

Sequence Diagram(s)

sequenceDiagram
  participant U as User Config
  participant M as ModelToComponentFactory
  participant J as AsyncHttpJobRepository
  
  U->>M: Provide polling_timeout configuration
  M->>M: Call _get_job_timeout() to calculate timeout
  M->>J: Instantiate AsyncHttpJobRepository with calculated job_timeout
  J->>J: Log job creation with timeout information
Loading

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • maxi297, wdyt?
  • lmossman, wdyt?

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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 (1)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

3384-3391: Nice addition of the polling_timeout property!

This new field provides a clear way to handle timeouts for async jobs, which is an important feature for reliability. The support for both integer and string types with interpolation context offers good flexibility for configuration-based values.

Have you considered adding an example value? Something like:

examples:
  - 30
  - "{{ config['timeout_minutes'] }}"

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 d4fdd4f and 97cc9c4.

📒 Files selected for processing (5)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (4 hunks)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (2 hunks)
  • airbyte_cdk/sources/declarative/retrievers/async_retriever.py (0 hunks)
💤 Files with no reviewable changes (1)
  • airbyte_cdk/sources/declarative/retrievers/async_retriever.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
🔇 Additional comments (9)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

3336-3336: Description update looks good!

The removal of the experimental notice suggests this component is now considered stable. This aligns well with removing the deprecated warnings mentioned in the PR description. Good cleanup!

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

48-49: Good addition of the job_timeout property

The attribute and its documentation clearly explain that it's derived from the polling_timeout parameter. The typing as Optional[timedelta] is appropriate since this might not always be specified.


136-136: Nice dynamic description!

Including the timeout value in the job creation log message will make debugging timeout issues much easier. This change provides important context for both users and developers.


166-166: Using the timeout parameter successfully

I see that you're correctly passing the job_timeout to the AsyncJob constructor. This ensures the timeout is properly propagated to the job instance.

Just curious - is there any additional handling of the timeout in the AsyncJob class to make the timeout effective? If so, that might be worth mentioning in the PR description for completeness.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2)

1470-1477: Nice typo fix in the description!

You cleaned up the extraneous comma at the end of the sentence. Small details like this improve documentation quality.


2357-2360: The new polling_timeout field looks good!

This addition will allow users to specify a custom timeout for asynchronous jobs, which aligns with the PR objectives to fix issues #11209 and #11923. The field supports both integer and string types for flexibility, with a clear description.

Just to confirm - are there any default timeout values that would be good to document in the description? It might help users understand the expected behavior when None is provided, wdyt?

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

510-510: Import cleanup looks good!

Removing the unused import of ConnectionDefinition helps keep the codebase clean.


2942-2962: New timeout handling function looks good!

This function handles both string and numeric timeout values elegantly, with sensible defaults for different contexts (15 min for test reads, 60 min for production syncs).

I like how you're using the InterpolatedString for evaluation - this allows for flexible configuration via string expressions.


3067-3067: Good integration of the timeout parameter!

The job_timeout parameter is now properly passed to AsyncHttpJobRepository, completing the implementation of the configurable timeout feature.

Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

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

Just one concern regarding the naming but I'm good with this change

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 (1)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1)

2942-2962: Nice implementation of timeout handling with defaults!

The new _get_job_timeout() method provides a clear way to determine job timeouts with sensible defaults. I like how it handles both user-defined timeouts and fallback values differently for test reads vs normal sync operations.

One thought - have you considered adding a docstring to explain the method's purpose and parameter handling? It might help future developers understand the logic more quickly, 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 97cc9c4 and 16aa37c.

📒 Files selected for processing (4)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (4 hunks)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
🔇 Additional comments (2)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (2)

510-510: Clean up: Import simplified to Config only

The removal of the unused ConnectionDefinition import helps keep the imports clean and focused. Good improvement!


3067-3067: Well integrated job_timeout parameter

Good job passing the timeout from the newly created method to the AsyncHttpJobRepository. This nicely completes the implementation of the polling timeout feature.

@bazarnov bazarnov merged commit 923acc2 into main Mar 17, 2025
26 checks passed
@bazarnov bazarnov deleted the baz/cdk/add-timeout-async-retriever-builder branch March 17, 2025 18:08
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