Skip to content

refactor: standardize by renaming PLUTO_API_TOKEN to PLUTO_API_KEY#58

Merged
asaiacai merged 1 commit intomainfrom
n-branch-2
Feb 26, 2026
Merged

refactor: standardize by renaming PLUTO_API_TOKEN to PLUTO_API_KEY#58
asaiacai merged 1 commit intomainfrom
n-branch-2

Conversation

@Nicoowr
Copy link
Collaborator

@Nicoowr Nicoowr commented Feb 25, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Nicoowr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request standardizes the environment variable used for API authentication within the Pluto ecosystem. By renaming PLUTO_API_TOKEN to PLUTO_API_KEY, the change aims to improve clarity and consistency in how API credentials are referenced and managed across the project's code, documentation, and testing infrastructure.

Highlights

  • Environment Variable Renaming: The primary authentication environment variable PLUTO_API_TOKEN has been consistently renamed to PLUTO_API_KEY across the codebase and documentation for standardization.
  • Documentation Updates: All relevant documentation files, including CLAUDE.md and docs/SYNC_PROCESS_V2_ARCHITECTURE.md, have been updated to reflect the new PLUTO_API_KEY variable.
  • Codebase Refactoring: Core Python files like pluto/query.py and pluto/sets.py have been modified to use PLUTO_API_KEY for API client initialization, token resolution, and authentication settings, while maintaining backward compatibility with MLOP_API_TOKEN where applicable.
  • Test Suite Adjustments: Kubernetes test scripts (tests/k8s/README.md, tests/k8s/multinode_worker.py, tests/k8s/run_multinode_test.sh) and unit tests (tests/test_query.py) have been updated to correctly reference and utilize the new PLUTO_API_KEY environment variable.
Changelog
  • CLAUDE.md
    • Updated references to the API token environment variable in authentication and testing notes.
  • docs/SYNC_PROCESS_V2_ARCHITECTURE.md
    • Modified the example environment variable for API authentication.
  • pluto/query.py
    • Updated comments to reflect the new API key environment variable.
    • Changed the default API token argument in the Client class to PLUTO_API_KEY.
    • Modified the error message for missing API tokens to reference PLUTO_API_KEY.
    • Updated the _resolve_api_token function to look for PLUTO_API_KEY first.
  • pluto/sets.py
    • Adjusted the environment variable lookup for authentication settings to use PLUTO_API_KEY.
  • tests/k8s/README.md
    • Updated the required environment variable in the running instructions.
  • tests/k8s/multinode_worker.py
    • Updated environment variable checks for the API token.
  • tests/k8s/run_multinode_test.sh
    • Modified the prerequisite check for the API token environment variable.
    • Updated the environment variable passed to the konduktor launch command.
  • tests/test_query.py
    • Updated the list of environment variables to clean for test isolation.
    • Modified monkeypatch.setenv calls to use PLUTO_API_KEY for mocking.
    • Adjusted assertions to verify PLUTO_API_KEY is correctly resolved and used.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/k8s-multinode-test.yml
    • .github/workflows/neptune-compat.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request standardizes the API authentication environment variable by renaming PLUTO_API_TOKEN to PLUTO_API_KEY. The changes are consistent across the codebase, including documentation, application code, and tests. However, the current implementation is a breaking change as it completely removes support for the old PLUTO_API_TOKEN variable. My main feedback is to introduce backward compatibility by continuing to support PLUTO_API_TOKEN with a deprecation warning, similar to how older MLOP_* variables are handled. This will ensure a smoother transition for existing users.

def _resolve_api_token() -> Optional[str]:
"""Resolve API token from environment or keyring."""
token = os.environ.get('PLUTO_API_TOKEN')
token = os.environ.get('PLUTO_API_KEY')

Choose a reason for hiding this comment

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

high

This change removes support for PLUTO_API_TOKEN entirely, which is a breaking change. To provide a smoother transition for users, consider maintaining backward compatibility by supporting PLUTO_API_TOKEN with a deprecation warning, similar to how MLOP_API_TOKEN is handled.

The recommended resolution order would be:

  1. PLUTO_API_KEY
  2. PLUTO_API_TOKEN (with deprecation warning)
  3. MLOP_API_TOKEN (with deprecation warning)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gemini-code-assist PLUTO_API_KEY was there before (in pluto/compat/neptune.py) so it shouldn't break anything

Choose a reason for hiding this comment

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

Thanks for the clarification, Nicoowr. I understand that PLUTO_API_KEY might have been present or used in other parts of the codebase, such as pluto/compat/neptune.py. However, the concern here is specifically about the _resolve_api_token function in pluto/query.py.

Before this change, _resolve_api_token explicitly looked for PLUTO_API_TOKEN as its primary environment variable. By changing line 640 from os.environ.get('PLUTO_API_TOKEN') to os.environ.get('PLUTO_API_KEY') and not adding PLUTO_API_TOKEN as a fallback, any user who has PLUTO_API_TOKEN set but not PLUTO_API_KEY will find that their API token is no longer resolved by this function. This constitutes a breaking change for those users.

To maintain backward compatibility and provide a smoother transition, I recommend modifying the _resolve_api_token function to check for PLUTO_API_TOKEN after PLUTO_API_KEY, but with a deprecation warning. This aligns with the approach already taken for MLOP_API_TOKEN.

The revised resolution order for _resolve_api_token should be:

  1. Check for PLUTO_API_KEY.
  2. If not found, check for PLUTO_API_TOKEN and issue a deprecation warning.
  3. If not found, check for MLOP_API_TOKEN and issue a deprecation warning.

Here's a conceptual example of how the _resolve_api_token function could be structured to achieve this:

def _resolve_api_token() -> Optional[str]:
    """Resolve API token from environment or keyring."""
    token = os.environ.get('PLUTO_API_KEY')
    if token:
        return token

    token = os.environ.get('PLUTO_API_TOKEN')
    if token:
        warnings.warn(
            'PLUTO_API_TOKEN is deprecated. Use PLUTO_API_KEY instead.',
            DeprecationWarning,
            stacklevel=3,
        )
        return token

    token = os.environ.get('MLOP_API_TOKEN')
    if token:
        warnings.warn(
            'MLOP_API_TOKEN is deprecated. Use PLUTO_API_KEY instead.',
            DeprecationWarning,
            stacklevel=3,
        )
        return token

    # ... (keyring lookup logic)
    return None

# Read PLUTO_API_KEY environment variable (with MLOP_API_TOKEN fallback)
# Only apply if not already set via function parameters
env_api_token = _get_env_with_deprecation('PLUTO_API_TOKEN', 'MLOP_API_TOKEN')
env_api_token = _get_env_with_deprecation('PLUTO_API_KEY', 'MLOP_API_TOKEN')

Choose a reason for hiding this comment

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

high

Similar to my comment in pluto/query.py, this logic removes support for PLUTO_API_TOKEN, which is a breaking change. For backward compatibility, please consider supporting PLUTO_API_TOKEN with a deprecation warning.

The recommended resolution order is PLUTO_API_KEY, then PLUTO_API_TOKEN, then MLOP_API_TOKEN.

Comment on lines 71 to 74
def test_pluto_takes_precedence(self, monkeypatch):
monkeypatch.setenv('PLUTO_API_TOKEN', 'new_token')
monkeypatch.setenv('PLUTO_API_KEY', 'new_token')
monkeypatch.setenv('MLOP_API_TOKEN', 'old_token')
assert _resolve_api_token() == 'new_token'

Choose a reason for hiding this comment

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

medium

If you implement my suggestion to add backward compatibility for PLUTO_API_TOKEN, please update the tests to cover the new logic. Specifically, this test should be expanded to ensure PLUTO_API_KEY has precedence over both PLUTO_API_TOKEN and MLOP_API_TOKEN. Additionally, new tests should be added to verify:

  1. A deprecation warning is issued when PLUTO_API_TOKEN is used.
  2. PLUTO_API_TOKEN has precedence over MLOP_API_TOKEN.

@asaiacai
Copy link

thank you @Nicoowr ! merging

@asaiacai asaiacai merged commit 2b4bebf into main Feb 26, 2026
11 of 19 checks passed
@asaiacai asaiacai deleted the n-branch-2 branch February 26, 2026 00:29
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.

2 participants