Skip to content
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

fix: fix sorting & __init__ imports #189

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

artem1205
Copy link
Contributor

@artem1205 artem1205 commented Dec 24, 2024

What

Resolve #12

  • fixed circular imports

Summary by CodeRabbit

  • New Features
    • Added DeclarativeOauth2Authenticator to the public API.
    • Reintroduced multiple classes and serializers to the models module.
    • Included ResumableFullRefreshCheckpointReader and ResumableFullRefreshCursor in the streams checkpoint module.
  • Bug Fixes
    • Corrected import paths for several classes to ensure proper module organization.
  • Documentation
    • Enhanced readability of import statements and public API declarations across multiple modules.
  • Chores
    • Removed exclusion for __init__.py from linting checks in the project configuration.

Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
@artem1205 artem1205 self-assigned this Dec 24, 2024
@github-actions github-actions bot added bug Something isn't working security labels Dec 24, 2024
@artem1205 artem1205 marked this pull request as ready for review December 24, 2024 11:59
@artem1205 artem1205 requested a review from bazarnov December 24, 2024 12:00
Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

📝 Walkthrough

Walkthrough

This pull request focuses on reorganizing and improving the import statements and __all__ declarations across multiple files in the Airbyte CDK. The changes primarily involve reformatting imports to use multi-line parentheses, reordering import statements, and ensuring consistent export of classes and functions. These modifications aim to enhance code readability and maintainability without altering the underlying functionality of the codebase.

Changes

File Path Change Summary
airbyte_cdk/__init__.py Rearranged and consolidated import statements
airbyte_cdk/models/__init__.py Re-added AirbyteStateStats, AirbyteStreamStatusTraceMessage, and serializer imports
airbyte_cdk/sources/declarative/async_job/job_orchestrator.py Updated StreamSlice import path
Multiple __init__.py files Reformatted imports to multi-line style, updated __all__ declarations
pyproject.toml Removed exclusion for __init__.py in Ruff linting

Assessment against linked issues

Objective Addressed Explanation
Resolve unstable root __init__.py imports Partial improvements made, but full resolution requires further investigation

Possibly related PRs

Suggested labels

chore

Suggested reviewers

  • maxi297

Hey there! 👋 I noticed you've made some nice improvements to the import statements across the Airbyte CDK. A few thoughts:

  1. The multi-line import formatting looks clean and consistent. Wdyt about potentially creating a style guide to document this approach?
  2. The removal of the __init__.py exclusion in Ruff linting is interesting. Are you planning to address any potential linting issues that might now surface?

The changes look solid overall - they'll definitely help improve code readability. Cheers! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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
🪧 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. (Beta)
  • @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 (4)
airbyte_cdk/sources/streams/checkpoint/__init__.py (2)

11-11: Nicely included ResumableFullRefreshCheckpointReader. Would you consider adding a brief docstring or comment describing its main purpose, so it’s easier for new contributors to discover and use? wdyt?


25-25: Great that ResumableFullRefreshCursor is now exposed. This helps clarify the module’s public interface. A brief mention in the docs might help teams properly configure or override it. wdyt?

airbyte_cdk/__init__.py (2)

51-54: Nice organization around config_observation imports. Would you like to add a one-line docstring in create_connector_config_control_message and emit_configuration_as_airbyte_control_message so folks quickly understand their usage? wdyt?


84-84: Exposing DeclarativeAuthenticator and NoAuth can be useful for advanced custom builds. Do you think it might be beneficial to group or annotate these authenticator classes in the docs for clarity? 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 cf93e3a and 0731c36.

📒 Files selected for processing (34)
  • airbyte_cdk/__init__.py (2 hunks)
  • airbyte_cdk/cli/source_declarative_manifest/__init__.py (0 hunks)
  • airbyte_cdk/models/__init__.py (2 hunks)
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py (1 hunks)
  • airbyte_cdk/sources/declarative/auth/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/decoders/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/extractors/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/incremental/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/partition_routers/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/paginators/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/paginators/strategies/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/requesters/request_options/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/resolvers/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/retrievers/__init__.py (1 hunks)
  • airbyte_cdk/sources/declarative/retrievers/async_retriever.py (1 hunks)
  • airbyte_cdk/sources/declarative/schema/__init__.py (1 hunks)
  • airbyte_cdk/sources/file_based/availability_strategy/__init__.py (1 hunks)
  • airbyte_cdk/sources/file_based/discovery_policy/__init__.py (1 hunks)
  • airbyte_cdk/sources/file_based/file_types/__init__.py (2 hunks)
  • airbyte_cdk/sources/file_based/schema_validation_policies/__init__.py (1 hunks)
  • airbyte_cdk/sources/file_based/stream/concurrent/cursor/__init__.py (1 hunks)
  • airbyte_cdk/sources/message/__init__.py (1 hunks)
  • airbyte_cdk/sources/streams/__init__.py (1 hunks)
  • airbyte_cdk/sources/streams/checkpoint/__init__.py (2 hunks)
  • airbyte_cdk/sources/streams/http/__init__.py (1 hunks)
  • airbyte_cdk/sources/streams/http/error_handlers/__init__.py (2 hunks)
  • airbyte_cdk/test/mock_http/__init__.py (1 hunks)
  • airbyte_cdk/test/mock_http/mocker.py (1 hunks)
  • airbyte_cdk/test/mock_http/response_builder.py (1 hunks)
  • airbyte_cdk/utils/__init__.py (1 hunks)
  • pyproject.toml (0 hunks)
  • unit_tests/sources/mock_server_tests/test_helpers/__init__.py (1 hunks)
💤 Files with no reviewable changes (2)
  • airbyte_cdk/cli/source_declarative_manifest/init.py
  • pyproject.toml
✅ Files skipped from review due to trivial changes (28)
  • airbyte_cdk/sources/declarative/incremental/init.py
  • airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/init.py
  • unit_tests/sources/mock_server_tests/test_helpers/init.py
  • airbyte_cdk/sources/file_based/schema_validation_policies/init.py
  • airbyte_cdk/sources/declarative/retrievers/init.py
  • airbyte_cdk/test/mock_http/response_builder.py
  • airbyte_cdk/sources/declarative/requesters/paginators/strategies/init.py
  • airbyte_cdk/sources/file_based/discovery_policy/init.py
  • airbyte_cdk/sources/streams/http/init.py
  • airbyte_cdk/sources/declarative/partition_routers/init.py
  • airbyte_cdk/utils/init.py
  • airbyte_cdk/sources/declarative/requesters/paginators/init.py
  • airbyte_cdk/sources/declarative/requesters/error_handlers/init.py
  • airbyte_cdk/sources/declarative/resolvers/init.py
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py
  • airbyte_cdk/sources/declarative/retrievers/async_retriever.py
  • airbyte_cdk/sources/streams/init.py
  • airbyte_cdk/sources/message/init.py
  • airbyte_cdk/sources/file_based/file_types/init.py
  • airbyte_cdk/test/mock_http/init.py
  • airbyte_cdk/sources/file_based/availability_strategy/init.py
  • airbyte_cdk/sources/declarative/requesters/request_options/init.py
  • airbyte_cdk/sources/declarative/decoders/init.py
  • airbyte_cdk/sources/streams/http/error_handlers/init.py
  • airbyte_cdk/test/mock_http/mocker.py
  • airbyte_cdk/sources/file_based/stream/concurrent/cursor/init.py
  • airbyte_cdk/sources/declarative/extractors/init.py
  • airbyte_cdk/sources/declarative/schema/init.py
🔇 Additional comments (4)
airbyte_cdk/sources/declarative/auth/__init__.py (2)

6-6: Great addition for clarity, ensuring DeclarativeOauth2Authenticator is directly imported. Would you consider verifying there are no new circular imports if other modules import this authenticator? wdyt?


8-8: Neat job updating the __all__ list, which makes the intended public interface more explicit. Would you consider double-checking that all references to JwtAuthenticator and DeclarativeOauth2Authenticator within the codebase match this final naming? wdyt?

airbyte_cdk/models/__init__.py (2)

24-31: Reintroducing AirbyteStateStats and AirbyteStreamStatusTraceMessage ensures backward compatibility. Should we confirm that internal usage has been restored consistently, or do we need a note in changelogs about re-adding these classes? wdyt?


51-58: Likewise, adding these serializers helps unify all serialization logic in the models package. Would you consider verifying that no other modules still rely on older, removed references? wdyt?
[approve]

Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
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 (2)
unit_tests/sources/declarative/resolvers/test_http_components_resolver.py (2)

444-444: Consider a more concise set comprehension.
"You might simplify it by writing {stream.name for stream in actual_catalog.streams} instead of set([stream.name for stream in actual_catalog.streams]). This avoids creating an unnecessary list, wdyt?"


446-446: Keep it consistent with the previous set comprehension suggestion.
"You can also simplify this by doing {record.stream for record in records} instead of set([record.stream for record in records]). Consistency across these assertions can help keep the code clean, 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 0731c36 and dc0cca2.

📒 Files selected for processing (1)
  • unit_tests/sources/declarative/resolvers/test_http_components_resolver.py (2 hunks)
🔇 Additional comments (1)
unit_tests/sources/declarative/resolvers/test_http_components_resolver.py (1)

403-403: Great job switching from a list to a set!
"By using a set for expected_stream_names, you ensure the test won't fail due to unexpected ordering of streams. This makes the test more robust, wdyt?"

@artem1205 artem1205 merged commit 2671c24 into main Dec 24, 2024
20 checks passed
@artem1205 artem1205 deleted the artem1205/fix-ruff-init-formatting branch December 24, 2024 12:35
rpopov added a commit to rpopov/airbyte-python-cdk that referenced this pull request Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Root __init__.py import and unstable and cannot be sorted due to circular references
2 participants