airbytehq / PyAirbyte

PyAirbyte brings the power of Airbyte to every Python developer.
https://docs.airbyte.com/pyairbyte
Other
234 stars 41 forks source link

Feat: Adds config_change_callback to Destinations and Sources #440

Closed tcboles closed 2 weeks ago

tcboles commented 3 weeks ago

Summary by CodeRabbit

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pyairbyte-api-docs ❌ Failed (Inspect) Nov 5, 2024 5:56pm
coderabbitai[bot] commented 3 weeks ago

[!WARNING]

Rate limit exceeded

@tcboles has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 58 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://coderabbit.ai/docs/faq) for further information.
📥 Commits Reviewing files that changed from the base of the PR and between 957f7eb41598ba8dca6c8f95dc1729a30d907e13 and 5567cd2208f59ebf73200301565ee54a82faabed.
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes introduce a new optional parameter, `config_change_callback`, to the `__init__` methods of the `ConnectorBase`, `Destination`, and `Source` classes in the Airbyte codebase. This callback allows for dynamic handling of configuration changes by invoking a specified callable when configuration change messages are received. The modifications include adjustments to the `_peek_airbyte_message` method to process these messages, while existing error handling remains unchanged. Overall, the control flow is enhanced to accommodate the new callback mechanism. ## Changes | File | Change Summary | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | airbyte/_connector_base.py | Added `config_change_callback` parameter to `ConnectorBase.__init__`. Modified `_peek_airbyte_message` to invoke the callback on configuration change messages. | | airbyte/destinations/base.py | Added `config_change_callback` parameter to `Destination.__init__`, passing it to the superclass constructor. | | airbyte/sources/base.py | Added `config_change_callback` parameter to `Source.__init__`, also passing it to the superclass constructor. | | airbyte/destinations/util.py | Added `config_change_callback` parameter to `get_destination`, passed to `Destination` constructor. | | airbyte/sources/util.py | Added `config_change_callback` to `get_source`, deprecated `get_connector`, which now redirects to `get_source`. |

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` or `@coderabbitai title` 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://coderabbit.ai/docs) 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.
aaronsteers commented 3 weeks ago

/fix-pr

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. (This job requires that the PR author has "Allow edits from maintainers" enabled.)

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

✅ Changes applied successfully.

aaronsteers commented 3 weeks ago

@tcboles - This looks great! I like the approach you took here - it seems nicely extensible and also simple enough to easily understand and explain to new developers.

I'm running a quick auto-fix here in CI for any simple linting or formatting issues. The slash command will only work for maintainers but you can run something similar using Ruff or Poe commands locally.

For both "get_source()" and "get_destination()", the linter will require adding a docstring entry for the new arg. These descriptions will then feed into our auto-generated API documentation.

I'll try to provide more detailed feedback inline but for now just wanted to drop in and say "thanks!" while giving my first observations/thoughts on this implementation. Feel free to ping me here if you have other questions/blockers.

tcboles commented 2 weeks ago

@tcboles - This looks great! I like the approach you took here - it seems nicely extensible and also simple enough to easily understand and explain to new developers.

I'm running a quick auto-fix here in CI for any simple linting or formatting issues. The slash command will only work for maintainers but you can run something similar using Ruff or Poe commands locally.

For both "get_source()" and "get_destination()", the linter will require adding a docstring entry for the new arg. These descriptions will then feed into our auto-generated API documentation.

I'll try to provide more detailed feedback inline but for now just wanted to drop in and say "thanks!" while giving my first observations/thoughts on this implementation. Feel free to ping me here if you have other questions/blockers.

Thanks @aaronsteers. I went ahead and removed the emitted time time from the callback. I also added basic tests. Let me know if you need anything updated.

aaronsteers commented 2 weeks ago

@tcboles - Looking good! Can you remind me which source you are wanting to use this feature with, and have you had any luck testing manually with that source?

tcboles commented 2 weeks ago

@tcboles - Looking good! Can you remind me which source you are wanting to use this feature with, and have you had any luck testing manually with that source?

I am going to be testing it with Quickbooks. I haven't had time to complete the testing yet. I will let you know when that is finished. It will hopefully be today or tomorrow.

tcboles commented 2 weeks ago

@aaronsteers Update on the testing. Everything is working for my use case with quickbooks.

aaronsteers commented 2 weeks ago

@tcboles - That's great! I'll do a final review and then merge if nothing else outstanding.

aaronsteers commented 2 weeks ago

@tcboles - Actually one more question so I can put this in the docs:

What is the shape of the config dict you received in the control message from QuickBooks? Can you tell me the keys/structure, obviously with anything sensitive removed?

tcboles commented 2 weeks ago

@tcboles - Actually one more question so I can put this in the docs:

What is the shape of the config dict you received in the control message from QuickBooks? Can you tell me the keys/structure, obviously with anything sensitive removed?

Here is the full control message that was sent from source-quickbooks. The callback receives everything inside control.connectorConfig.config.

{
  "type": "CONTROL",
  "control": {
    "type": "CONNECTOR_CONFIG",
    "emitted_at": 1731090040516.7517,
    "connectorConfig": {
      "config": {
        "auth_type": "oauth2",
        "sandbox": false,
        "start_date": "2000-01-01T00:00:00Z",
        "credentials": {
          "client_id": "************",
          "client_secret": "************",
          "refresh_token": "************",
          "access_token": "************",
          "realm_id": "************",
          "token_expiry_date": "2024-11-08T19:20:40.516582+00:00"
        }
      }
    }
  }
}