airbytehq / airbyte-python-cdk

The Python CDK empowers hundreds of Airbyte connectors, including low-code and no-code connectors.
https://airbytehq.github.io/airbyte-python-cdk/
MIT License
0 stars 0 forks source link

chore(refactor): refactor partition generator to take any stream slicer #39

Open maxi297 opened 2 days ago

maxi297 commented 2 days ago

What

Work as part of https://github.com/airbytehq/airbyte-internal-issues/issues/10552

In order to easily use any type of stream slicing that is done in the Declarative CDK as part of the Concurrent CDK, we need the StreamSlicer abstraction to be available in the Concurrent CDK.

How

Summary by CodeRabbit

Release Notes

maxi297 commented 1 day ago

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made, those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

🟦 Job completed successfully (no changes).

coderabbitai[bot] commented 13 minutes ago
📝 Walkthrough ## Walkthrough The pull request introduces significant modifications across several files within the Airbyte CDK framework, focusing on enhancing the handling of streams and partition management. Key changes include the addition of new classes and methods for partition generation, updates to existing classes for improved state management, and refinements in type hints for clarity. The `Cursor` class and its subclasses have been restructured to better align with the new `StreamSlice` representation. Additionally, test suites have been expanded and refined to ensure comprehensive coverage of the new functionalities and behaviors. ## Changes | File | Change Summary | |--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | `airbyte_cdk/sources/declarative/concurrent_declarative_source.py` | - Added method `_retriever_factory` and modified `_group_streams` to use `StreamSlicerPartitionGenerator`.
- Updated imports and type hints. | | `airbyte_cdk/sources/declarative/manifest_declarative_source.py` | - Updated return type of `message_repository` to always return `MessageRepository`.
- Changed type hint for `update_with_cache_parent_configs`. | | `airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py` | - Introduced `DeclarativePartitionFactory`, `DeclarativePartition`, and `StreamSlicerPartitionGenerator` classes with relevant methods for partition management. | | `airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py` | - Updated `StreamSlicer` class to inherit from `ConcurrentStreamSlicer` and removed the `stream_slices` method. | | `airbyte_cdk/sources/streams/concurrent/adapters.py` | - Removed `CursorPartitionGenerator` class and updated hashing logic in `StreamPartition`. | | `airbyte_cdk/sources/streams/concurrent/cursor.py` | - Updated `Cursor` class to inherit from `StreamSlicer` and renamed `generate_slices` to `stream_slices`. | | `airbyte_cdk/sources/streams/concurrent/partitions/stream_slicer.py` | - Added abstract class `StreamSlicer` with method `stream_slices`. | | `airbyte_cdk/sources/streams/concurrent/state_converters/abstract_stream_state_converter.py` | - Added abstract method `output_format` to `AbstractStreamStateConverter`. | | `airbyte_cdk/utils/slice_hasher.py` | - Introduced `SliceEncoder` and `SliceHasher` classes for custom serialization and hashing of slices. | | `unit_tests/sources/declarative/parsers/test_model_to_component_factory.py` | - Expanded test suite with new tests and modified existing ones for better coverage. | | `unit_tests/sources/declarative/stream_slicers/test_declarative_partition_generator.py` | - Introduced unit tests for `DeclarativePartitionFactory`. | | `unit_tests/sources/streams/concurrent/test_adapters.py` | - Removed tests related to `CursorPartitionGenerator`. | | `unit_tests/sources/streams/concurrent/test_cursor.py` | - Updated tests to reflect the renaming of `generate_slices` to `stream_slices`. | ## Possibly related PRs - **#32**: Involves the removal of the `partition.close()` method, relevant to partition management in `ConcurrentDeclarativeSource`. - **#52**: Modifies state management logic in `DateTimeStreamStateConverter`, related to stream state handling in `ConcurrentDeclarativeSource`. ## Suggested reviewers - aaronsteers - brianjlai Would you like to consider any additional reviewers or related PRs? Wdyt?

[!WARNING]

Rate limit exceeded

@maxi297 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.
📥 Commits Reviewing files that changed from the base of the PR and between ab7ab684c832bf7a697f6c2f3b739f33d739325b and eb00f8b5af6189d56d38ac0640c32bf42eda3565.

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): > ‼️ **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 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.