Skip to content

Conversation

@bazarnov
Copy link
Contributor

@bazarnov bazarnov commented Mar 18, 2025

What

Original Slack thread:

Additional side-fix for the:

How

  • make the TIMEOUT Job status to be Terminal

  • make the TIMEOUT Job status non-retriable

  • add more interpolation context required by certain sources, like source-amazon-ads, relying on creation_response['headrs']['My-Header-Value']. Also valid for the polling_response case.

User Impact

No impact is expected, this is not a Breaking Change.

Summary by CodeRabbit

  • New Features

    • Improved job management now distinguishes between failed and timed-out jobs, ensuring more precise job reallocation and clearer error notifications when timeouts occur.
    • Centralized handling of job responses streamlines the processing of creation and polling data.
  • Tests

    • Updated testing ensures that timeout errors provide accurate and informative feedback.

@bazarnov bazarnov self-assigned this Mar 18, 2025
@github-actions github-actions bot added bug Something isn't working security labels Mar 18, 2025
@bazarnov bazarnov marked this pull request as ready for review March 18, 2025 12:30
Copilot AI review requested due to automatic review settings March 18, 2025 12:30
@bazarnov bazarnov requested review from lmossman, maxi297 and pnilan March 18, 2025 12:30
Copy link
Contributor

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 pull request fixes an issue where TIMEOUT jobs were being retried despite the polling job timeout setting, while also adding enhanced context interpolation for HTTP job responses.

  • In job_orchestrator.py, TIMEOUT jobs are now treated as terminal with improved error messaging and allocation freeing.
  • New helper methods have been added in http_job_repository.py to generate interpolation contexts for creation and polling responses.
  • The related test has been updated to assert the new timeout error message.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
airbyte_cdk/sources/declarative/async_job/job_orchestrator.py Updated logic to avoid re-queuing TIMEOUT jobs and improved error handling and cleanup, along with new helper methods for partition job management.
airbyte_cdk/sources/declarative/requesters/http_job_repository.py Added methods for generating interpolation contexts for job responses, maintaining consistency in extra_fields.
unit_tests/sources/declarative/async_job/test_job_orchestrator.py Modified test to capture and assert the updated timeout error message.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

📝 Walkthrough

Walkthrough

This pull request updates the asynchronous job orchestration and HTTP job repository logic. In the orchestrator, job status handling is refined to distinguish between FAILED and TIMED_OUT states. New methods remove completed or timed-out jobs and reallocate partitions for failed jobs, while error reporting for timeouts is enhanced. The HTTP job repository now centralizes response context creation with dedicated methods for job creation and polling, streamlining the data extraction process. The unit test has been adjusted to focus on validating the proper error message when a job times out.

Changes

File(s) Change Summary
airbyte_cdk/.../job_orchestrator.py Modified job status handling in AsyncJobOrchestrator: updated _replace_failed_jobs to only target FAILED jobs; removed logic handling restarted jobs in _process_running_partitions_and_yield_completed_ones; added _remove_completed_or_timed_out_jobs and _reallocate_partition methods; enhanced _stop_timed_out_jobs to free allocation and raise a detailed exception.
airbyte_cdk/.../http_job_repository.py Introduced _get_creation_response_interpolation_context and _get_polling_response_interpolation_context methods to generate response contexts. Updated _get_create_job_stream_slice and _get_download_targets to use these new methods for a more modular approach.
unit_tests/.../test_job_orchestrator.py Revised the timeout exception test to capture the exception and assert that the error message includes "Job an api job id has timed out," removing previous assertions related to job tracker intent and call parameters.

Sequence Diagram(s)

Async Job Orchestration Flow

sequenceDiagram
    participant O as AsyncJobOrchestrator
    participant P as Partition
    participant J as Job

    O->>O: Evaluate job status (FAILED vs TIMED_OUT)
    alt Job status is FAILED
        O->>P: Invoke _replace_failed_jobs
        O->>P: Call _reallocate_partition to start a new job
    else Job status is TIMED_OUT/COMPLETED
        O->>P: Call _remove_completed_or_timed_out_jobs
        O->>O: Free allocation and raise AirbyteTracedException
    end
Loading

HTTP Job Repository Context Flow

sequenceDiagram
    participant Repo as AsyncHttpJobRepository
    participant Job as AsyncJob

    Job->>Repo: Request creation context
    Repo->>Repo: Execute _get_creation_response_interpolation_context
    Repo-->>Job: Return creation response data

    Job->>Repo: Request polling context
    Repo->>Repo: Execute _get_polling_response_interpolation_context
    Repo-->>Job: Return polling response data
Loading

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.

📜 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 17d77e8 and 073a71e.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/requesters/http_job_repository.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • 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: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Analyze (python)

🪧 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.

@bazarnov bazarnov requested a review from maxi297 March 18, 2025 12:40
Copy link
Contributor

@pnilan pnilan left a comment

Choose a reason for hiding this comment

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

Thanks for quickly updating this!

I have one comment regarding the use of .json() in the AsyncHttpJobRepository, other than that LGTM.

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.

4 participants