Skip to content

Conversation

girarda
Copy link
Contributor

@girarda girarda commented Mar 7, 2025

Update the StreamPartition so it properly handles AirbyteRecords.

On master, we send all AirbyteMessages on the repository, which is wrong if the message is an AirbyteRecord. We should instead create a record from it and yield it.

Summary by CodeRabbit

  • New Features
    • Enhanced message processing to reliably extract records from AirbyteMessage objects.
  • Tests
    • Introduced a test to validate the behavior of the StreamPartition class when reading AirbyteMessage records.

@girarda girarda changed the title handle airbyte records fix(concurrent-cdk): StreamPartition handles AIrbyteRecords Mar 7, 2025
@girarda girarda marked this pull request as ready for review March 7, 2025 02:13
@girarda girarda requested a review from maxi297 March 7, 2025 02:13
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

📝 Walkthrough

Walkthrough

The changes enhance the read method of the StreamPartition class by updating its functionality to handle AirbyteMessage objects that contain records. A new conditional branch has been added to yield records from these messages. Additionally, a unit test has been introduced to validate this new behavior, while the existing functionality for handling Mapping types remains unchanged.

Changes

File Change Summary
airbyte_cdk/sources/streams/concurrent/adapters.py Updated read method in StreamPartition to add a branch that handles AirbyteMessage objects with a valid record, yielding a Record using record_data.record.data (defaulting to an empty dict if missing).
unit_tests/sources/streams/concurrent/test_adapters.py Added test_stream_partition_read_airbyte_message to validate the new logic with AirbyteMessage records. Also updated import statements to include AirbyteRecordMessage and verified proper processing of records and logging of messages.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant StreamPartition
    Caller->>StreamPartition: Call read(record_data)
    alt record_data is AirbyteMessage with non-null record
        StreamPartition->>Caller: Yield Record(record_data.record.data or {} if data is None)
    else record_data is Mapping type
        StreamPartition->>Caller: Yield processed record (existing logic)
    end
Loading

Suggested reviewers

  • brianjlai
  • maxi297

Would these suggestions work for you? wdyt?


📜 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 12f5cc7 and 65d3c4f.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/streams/concurrent/adapters.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/streams/concurrent/adapters.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: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)
  • 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.

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)
unit_tests/sources/streams/concurrent/test_adapters.py (1)

142-195: Great test implementation for the new functionality!

This test properly validates the behavior of the StreamPartition.read method when processing AirbyteMessage records. It ensures that the data from the AirbyteRecordMessage is correctly extracted and yielded as a Record.

The test setup is comprehensive with appropriate mock objects and assertions. Would you consider adding another parameter case for a different transformer configuration like you have in other tests? Just a thought since you only have the NoTransform case currently, 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 fe2f9a5 and f168624.

📒 Files selected for processing (2)
  • airbyte_cdk/sources/streams/concurrent/adapters.py (1 hunks)
  • unit_tests/sources/streams/concurrent/test_adapters.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Check: 'source-shopify' (skip=false)
🔇 Additional comments (2)
airbyte_cdk/sources/streams/concurrent/adapters.py (1)

305-310: Nice fix to handle AirbyteMessage containing AirbyteRecord!

The change correctly handles the case when record_data is an AirbyteMessage with a non-null record attribute. It extracts the data from the record and yields it as a Record object, ensuring proper handling of these messages.

I like the null-safety with record_data.record.data or {} that provides an empty dict fallback. This aligns with the PR objective to fix how AirbyteRecord instances are handled.

unit_tests/sources/streams/concurrent/test_adapters.py (1)

10-17: Good addition of AirbyteRecordMessage to the imports!

Adding the AirbyteRecordMessage import supports the new test case and makes the dependencies clear.

Copy link
Contributor

@natikgadzhi natikgadzhi left a comment

Choose a reason for hiding this comment

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

Nit: can you update the docstring of read_records too? It seems outdated.

@github-actions github-actions bot added the bug Something isn't working label Mar 7, 2025
@girarda girarda changed the title fix(concurrent-cdk): StreamPartition handles AIrbyteRecords fix(concurrent-cdk): StreamPartition handles AirbyteRecords Mar 7, 2025
@girarda girarda enabled auto-merge (squash) March 7, 2025 18:17
@girarda girarda merged commit edafc40 into main Mar 7, 2025
25 checks passed
@girarda girarda deleted the alex/handle_airbyte_records branch March 7, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants