Skip to content

Conversation

@b-long
Copy link
Owner

@b-long b-long commented Dec 14, 2025

No description provided.

BREAKING CHANGE: Upgrade from connect-python 0.4.2 to 0.6.0

The connect-python library underwent a major API change between versions
0.4.x and 0.6.0, requiring updates throughout the codebase.

Changes:
- Update dependencies: split connect-python[compiler] into separate packages
  - connect-python>=0.6.0,<0.7
  - protoc-gen-connect-python>=0.6.0,<0.7

- Fix binary name: protoc-gen-connect_python → protoc-gen-connect-python
  The new version uses hyphens instead of underscores in the binary name

- Regenerate proto files with new API
  - Deleted 15 old *_pb2_connect.py files
  - Generated 15 new *_connect.py files
  - Fixed imports to use relative paths

- Update SDK implementation (kas_connect_rpc_client.py)
  - Replace urllib3.PoolManager with httpx.Client
  - Use AccessServiceClientSync instead of AccessServiceClient
  - Update client instantiation: base_url and session parameters
  - Change extra_headers parameter to headers
  - Add proper context manager usage for HTTP clients

- Update test mocks (test_kas_client.py)
  - Patch httpx.Client instead of urllib3.PoolManager
  - Update mock setup for context managers
  - Fix import paths for new module structure

- Update proto module exports (kas/__init__.py)
  - Export AccessServiceClientSync instead of AsyncAccessServiceClient
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @b-long, 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 primarily updates the otdf-python-proto submodule to align with the latest connect-python library. This involves a significant refactoring of the generated RPC client code, moving to a new naming convention for service clients and updating related build scripts and dependencies. Additionally, the KAS client's underlying HTTP request mechanism has been modernized by switching from urllib3 to httpx, enhancing network communication capabilities and maintainability.

Highlights

  • Connect RPC Client Migration: The generated Connect RPC client files have been migrated from the older *_pb2_connect.py naming convention to the new *_connect.py format, reflecting updates in the connect-python library.
  • Dependency Updates: The connect-python dependency has been upgraded to 0.6.0 and protoc-gen-connect-python has been added to pyproject.toml to support the updated client generation.
  • HTTP Client Library Switch: The internal KAS client implementation now utilizes httpx instead of urllib3 for making HTTP requests, including changes to SSL verification handling, for a more modern and robust approach to network communication.
  • OTDF Python Proto Submodule Update: The otdf-python-proto submodule has been updated to its latest version, incorporating the aforementioned changes and ensuring compatibility with the latest protobuf and Connect RPC ecosystem.
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.

@b-long
Copy link
Owner Author

b-long commented Dec 14, 2025

/gemini review

Copy link
Contributor

@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 successfully updates the otdf-python-proto submodule, primarily focusing on upgrading the connect-python dependency and its related tooling. The changes are comprehensive, including updates to the protobuf generation scripts, regeneration of client code, and necessary adaptations in the KAS client and its tests. The migration from urllib3 to httpx is a positive change, improving the HTTP client handling. The code modifications are consistent with the dependency upgrade and appear to be correct. I have no further suggestions.

Copy link
Contributor

@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 updates the otdf-python-proto submodule, which involves upgrading connect-python and regenerating the protobuf client code. The changes correctly adapt the SDK to the new library version, including switching from urllib3 to httpx and updating client instantiation. The tests have also been updated accordingly. My main concern is that while the KAS service's __init__.py is updated to export the new client classes, other services' __init__.py files are not included in this PR. If they exist, they are likely broken by this change, preventing other services from being used. Additionally, there's an opportunity to improve performance by reusing httpx.Client instances across multiple requests.

@b-long
Copy link
Owner Author

b-long commented Dec 14, 2025

/gemini review

@b-long b-long requested a review from Copilot December 14, 2025 17:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the otdf-python-proto submodule to use the newer connect-python version 0.6.x, migrating from version 0.4.x. The update involves regenerating protobuf client code to use the new Connect RPC library API, which changes HTTP client handling from urllib3 to httpx, updates client class names, and modifies the parameter naming convention.

Key Changes:

  • Upgraded connect-python from 0.4.x to 0.6.x and added separate protoc-gen-connect-python dependency
  • Migrated HTTP client from urllib3.PoolManager to httpx.Client with lazy initialization and resource management
  • Updated Connect RPC client class names (e.g., AccessServiceClientAccessServiceClientSync)

Reviewed changes

Copilot reviewed 50 out of 52 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Updated connect-python dependency versions and added protoc-gen-connect-python
src/otdf_python/kas_connect_rpc_client.py Migrated from urllib3 to httpx, added context manager support and lazy client initialization
src/otdf_python/kas_client.py Added context manager methods for proper resource cleanup
tests/test_kas_client.py Updated test mocks to reflect new httpx and AccessServiceClientSync usage
otdf-python-proto files Regenerated protobuf connect files with new connect-python 0.6.x tooling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@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 updates the otdf-python-proto submodule, primarily to upgrade the connect-python dependency. The changes include regenerating the protobuf client files to align with the new version, which now uses httpx instead of urllib3. The client code in kas_client.py and kas_connect_rpc_client.py has been updated to support the new API, including adding context manager support for better resource management. The tests have also been updated accordingly. I've identified a potential resource leak issue in the backward-compatibility implementation and suggested a fix.

Comment on lines +65 to +74
def _get_http_client(self):
"""Get HTTP client, creating one if needed for backward compatibility.
Returns:
httpx.Client instance
"""
if self._http_client is None:
self._http_client = self._create_http_client()
return self._http_client
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This new _get_http_client method, intended for backward compatibility, introduces a potential resource leak. If the KASConnectRPCClient is used without a context manager and close() is not called manually, the httpx.Client instance created here will not be closed. This can lead to leaked connections and other resource issues.

The previous implementation created a new urllib3.PoolManager for each request, which, while less efficient, did not have this specific leak risk. The new approach of reusing a single httpx.Client is better for performance but requires diligent resource management.

To guide users toward the correct usage and prevent potential issues, I recommend adding a warning when the client is created outside of a context manager.

    def _get_http_client(self):
        """Get HTTP client, creating one if needed for backward compatibility.

        Returns:
            httpx.Client instance

        """
        if self._http_client is None:
            logging.warning(
                "KASConnectRPCClient is creating an HTTP client outside of a context manager. "
                "To ensure resources are properly managed, please use the client as a context manager "
                "or call .close() when finished."
            )
            self._http_client = self._create_http_client()
        return self._http_client

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