Skip to content

chore: update sample script to accept positional argument for connector name #658

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

Merged
merged 3 commits into from
Apr 16, 2025

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Apr 16, 2025

Modify the sample script to accept a connector name as a positional argument, allowing for more flexible usage. Update the script's usage instructions accordingly.

Summary by CodeRabbit

  • New Features

    • Added support for specifying the connector name as a command-line argument, with a default value of "source-klaviyo".
    • Improved filename handling for secret files, allowing dynamic naming based on secret metadata.
  • Bug Fixes

    • Ensured required directories are created if missing, preventing errors due to non-existent paths.
  • Documentation

    • Updated usage instructions to reflect changes in script name and argument handling.

Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

📝 Walkthrough

Walkthrough

The script run_gsm_connector_secret_fetch.py was updated to allow dynamic specification of the connector name via command-line arguments, defaulting to "source-klaviyo" if not provided. The script now checks for the existence of required directories, creating them if necessary, and raises an error if the Airbyte repository root is missing. Additionally, the filename for each secret is determined from secret metadata or defaults to "config". Usage instructions were also updated to reflect these changes.

Changes

File(s) Change Summary
examples/run_gsm_connector_secret_fetch.py Updated to accept an optional connector name argument, defaulting to "source-klaviyo". Now checks and creates the secrets directory if missing, verifies Airbyte repo root existence, and determines secret filenames from metadata or defaults. Usage instructions updated.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script
    participant FileSystem
    participant GSM

    User->>Script: Run script with optional connector name argument
    Script->>FileSystem: Check Airbyte repo root exists
    alt Root missing
        Script->>User: Raise FileNotFoundError
    else Root exists
        Script->>FileSystem: Ensure secrets directory exists (create if missing)
        Script->>GSM: Fetch connector secrets (using connector name)
        loop For each secret
            Script->>FileSystem: Determine filename (from metadata or "config")
            Script->>FileSystem: Write secret to JSON file in secrets directory
        end
    end
Loading

Would you like me to whip up a comparison diagram showing the old vs. new script flow for extra clarity, wdyt?

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 2fe7765 and f075119.

📒 Files selected for processing (1)
  • examples/run_gsm_connector_secret_fetch.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/run_gsm_connector_secret_fetch.py
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (No Creds)
  • GitHub Check: Pytest (Fast)

🪧 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 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 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 (2)
examples/run_gsm_connector_secret_fetch.py (2)

39-42: Good directory validation and creation

I like the safeguards you've added to check for directory existence. Creating the connector secrets directory if it doesn't exist (line 42) is a nice quality-of-life improvement that reduces the steps users need to take.

Since this is in the examples directory and per our guidelines we prefer brevity for demo scripts, would you consider simplifying the error message or combining these checks? Just a thought - the current implementation is perfectly fine too.


51-58: Well implemented secret fetching loop with flexible filename handling

The improved loop now nicely handles dynamic connector names and provides sensible filename defaults. The addition of a default filename in line 54 is a good defensive programming practice.

One minor suggestion - would you consider adding a print statement to show which connector is being processed? Might be helpful for users to see what's happening, especially when running with default values. Something like:

def main() -> None:
    secret_mgr = GoogleGSMSecretManager(
        project=AIRBYTE_INTERNAL_GCP_PROJECT,
        credentials_json=ab.get_secret("GCP_GSM_CREDENTIALS"),
    )
+   print(f"Fetching secrets for connector: {CONNECTOR_NAME}")

    secret: SecretHandle

What do you think?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b339b2 and 2fe7765.

📒 Files selected for processing (1)
  • examples/run_gsm_connector_secret_fetch.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`examples/*`: These scripts are intended for demonstration purposes only. They are not meant to represent production code. For these scripts, you should prefer brevity over robust ...

examples/*: These scripts are intended for demonstration purposes only. They are not meant to represent production code. For these scripts, you should prefer brevity over robust error handling and handling of edge cases. These are demos - which should be as simple as possible to handle the 'blessed' use cases.

  • examples/run_gsm_connector_secret_fetch.py
🧬 Code Graph Analysis (1)
examples/run_gsm_connector_secret_fetch.py (2)
airbyte/secrets/google_gsm.py (3)
  • GoogleGSMSecretManager (75-298)
  • fetch_connector_secrets (243-262)
  • labels (70-72)
airbyte/secrets/base.py (2)
  • SecretHandle (207-263)
  • write_to_file (240-263)
🪛 GitHub Actions: Run Linters
examples/run_gsm_connector_secret_fetch.py

[error] 1-1: Ruff formatting check failed. File would be reformatted. Run 'ruff format' to fix code style issues.

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (No Creds)
  • GitHub Check: Pytest (Fast)
🔇 Additional comments (4)
examples/run_gsm_connector_secret_fetch.py (4)

13-15: The updated usage instructions look great!

Nice job updating the usage instructions to show the new flexibility. By providing several examples with different connector names, you've made it clear how users can take advantage of the new positional argument.


20-20: Clean import addition for command-line argument handling

The sys import is necessary for accessing command line arguments. Good addition!


27-27: Effective implementation of the dynamic connector name

This is a nice concise way to set the connector name from command line arguments with a sensible default. I notice you've changed the default from "source-s3" to "source-klaviyo" - was this intentional? Just checking in case it might affect existing usage, wdyt?


1-63: Please fix formatting issues reported by linters

The pipeline is reporting that this file needs formatting with Ruff:

[error] 1-1: Ruff formatting check failed. File would be reformatted. Run 'ruff format' to fix code style issues.

Could you run ruff format on this file to resolve the formatting issues?

🧰 Tools
🪛 GitHub Actions: Run Linters

[error] 1-1: Ruff formatting check failed. File would be reformatted. Run 'ruff format' to fix code style issues.

@aaronsteers
Copy link
Contributor Author

aaronsteers commented Apr 16, 2025

/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 aaronsteers marked this pull request as ready for review April 16, 2025 06:08
@aaronsteers aaronsteers enabled auto-merge (squash) April 16, 2025 06:08
@aaronsteers aaronsteers disabled auto-merge April 16, 2025 06:38
@aaronsteers aaronsteers merged commit 47aa6d1 into main Apr 16, 2025
19 of 22 checks passed
@aaronsteers aaronsteers deleted the chore/update-secret-script branch April 16, 2025 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant