Skip to content

feat(python): expose get_me, get_client, get_clients - #4020

Open
yummyPancake2607 wants to merge 20 commits into
apache:masterfrom
yummyPancake2607:feat/python-sdk-get-me-client-clients
Open

feat(python): expose get_me, get_client, get_clients#4020
yummyPancake2607 wants to merge 20 commits into
apache:masterfrom
yummyPancake2607:feat/python-sdk-get-me-client-clients

Conversation

@yummyPancake2607

@yummyPancake2607 yummyPancake2607 commented Sep 1, 2026

Copy link
Copy Markdown

closes: #4015

Add system client methods to the Python SDK for parity with Rust SDK:

  • Add client_info.rs wrapping ClientInfo, ClientInfoDetails, ConsumerGroupInfo types with pyclass getters
  • Add get_me() -> ClientInfoDetails for current client info
  • Add get_client(client_id) -> ClientInfoDetails | None
  • Add get_clients() -> list[ClientInfo] for all connected clients
  • Register new types in lib.rs pymodule
  • Add iggy_common dependency for ClientInfo/ConsumerGroupInfo
  • Add integration tests for all three methods

Which issue does this PR address?

Relates to #4015

Rationale

The Rust SDK exposes get_me, get_client, and get_clients via SystemClient, but the Python SDK had none of them. Every other SDK (Java, .NET, Go, etc.) already exposes connection state — this closes the parity gap.

What changed?

The Python SDK had no way to inspect the currently connected client or enumerate all connected clients, while every other SDK could. This adds three methods (get_me, get_client, get_clients) and their associated wrapper types (ClientInfo, ClientInfoDetails, ConsumerGroupInfo) to the Python SDK, following the same pattern used for user types in user.rs.

Local Execution

  • Passed: cargo check, cargo clippy --all-features --all-targets -- -D warnings, cargo fmt --all -- --check
  • Pre-commit hooks ran / not ran

AI Usage

None

Add system client methods to the Python SDK for parity with Rust SDK:

- Add client_info.rs wrapping ClientInfo, ClientInfoDetails,
  ConsumerGroupInfo types with pyclass getters
- Add get_me() -> ClientInfoDetails for current client info
- Add get_client(client_id) -> ClientInfoDetails | None
- Add get_clients() -> list[ClientInfo] for all connected clients
- Register new types in lib.rs pymodule
- Add iggy_common dependency for ClientInfo/ConsumerGroupInfo
- Add integration tests for all three methods
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Sep 1, 2026
@yummyPancake2607 yummyPancake2607 changed the title feat(python-sdk): expose get_me, get_client, get_clients feat(python): expose get_me, get_client, get_clients Sep 1, 2026
@slbotbm

slbotbm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@yummyPancake2607 the ci is failing. could you please check?

@hubcio

hubcio commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

why didn't you run precommit hooks? please read CONTRIBUTING.md

- Regenerate apache_iggy.pyi with ClientInfo, ClientInfoDetails,
  ConsumerGroupInfo classes and get_me/get_client/get_clients methods
- Fix ruff lint/format issues in test_client_info.py
@yummyPancake2607

Copy link
Copy Markdown
Author

@hubcio, my bad. I will run it all. Sorry for the earlier work. I will fix it.

@yummyPancake2607

Copy link
Copy Markdown
Author

i have updated the PR accordingly please check. @slbotbm

@slbotbm

slbotbm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@yummyPancake2607 the CI is still failing

yummyPancake2607 and others added 7 commits September 1, 2026 19:04
…info.py

pyrefly flags details.client_id when details may be None.
Add assert details is not None before attribute access.
Reorder classes to alphabetical order as produced by stub_gen:
- Move ClientInfo and ClientInfoDetails after AutoLogin
- Move ConsumerGroupMember after ConsumerGroupInfo
- Remove @typing.final from ConsumerGroupMember
- Fix docstring line wrapping
@justinmclean

Copy link
Copy Markdown
Member

It looks like apache_iggy.pyi is out of date. Run 'cargo run --bin stub_gen' from foreign/python, let Ruff format it, and then commit the result.

@justinmclean

Copy link
Copy Markdown
Member

The three methods and the wrapper types look right and the tests are well shaped. One regression in the stub, plus two small points.

ConsumerGroupMember lost its @typing.final (foreign/python/apache_iggy.pyi:464)

The new ConsumerGroupInfo block was inserted between the existing @typing.final line and class ConsumerGroupMember:, so the decorator now applies to ConsumerGroupInfo and ConsumerGroupMember is left undecorated:

@typing.final
class ConsumerGroupInfo:
    ...
        The unique identifier (numeric) of the consumer group.
        """

class ConsumerGroupMember:      # <- was @typing.final on the base commit

Nothing in this PR touches ConsumerGroupMember, so this is an edit the generator would not produce. .github/actions/python-maturin/pre-merge/action.yml:108 runs the generator and compares the result to the tracked file, so please run exactly that from foreign/python and commit whatever it writes, rather than editing the stub by hand:

cd foreign/python
cargo run --bin stub_gen
uv run --no-sync ruff format apache_iggy.pyi
uv run --no-sync ruff check --fix apache_iggy.pyi
git diff --exit-code -- apache_iggy.pyi

The rest of the stub, including the placement of get_me / get_client / get_clients in source order, already matches what the generator emits.

New direct iggy_common dependency (foreign/python/Cargo.toml:41, foreign/python/src/client_info.rs:18)

This is the first direct iggy_common dependency in the Python binding; every other module reaches its Rust types through iggy::prelude. The module splits its imports across both, because core/sdk/src/prelude.rs:50 re-exports ClientInfoDetails but not ClientInfo or ConsumerGroupInfo.

It works. Worth a maintainer's call whether the better fix is adding those two types to the core/sdk prelude, which would keep the binding on one dependency.

Smaller observations

  • foreign/python/src/client_info.rs:30 - the From<RustConsumerGroupInfo> for ConsumerGroupInfo impl is never called. The consumer_groups getter at line 153 cannot use it: it holds &self, and iggy_common::ConsumerGroupInfo derives only Debug, Serialize, Deserialize (core/common/src/types/client/client_info.rs:70), so there is nothing to move or clone from. Changing the impl to From<&RustConsumerGroupInfo> would make it usable and let the getter read .map(ConsumerGroupInfo::from). Dropping the impl works too.

This review was drafted by an AI-assisted tool (Apache Magpie) so may contain mistakes. If you think one of them is misapplied, please reply on the PR, and a maintainer will weigh in.

Run cargo run --bin stub_gen from foreign/python, let Ruff format it

- Add @typing.final to ConsumerGroupMember (generator output)
- Reformat docstrings and reorder classes to alphabetical order
- No other changes needed - rest matches generator output
@yummyPancake2607

Copy link
Copy Markdown
Author

@justinmclean please approve these so the tests can begin.

@slbotbm

slbotbm commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@yummyPancake2607 done

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (3cfc7df) to head (78bcee2).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
foreign/python/src/client_info.rs 67.18% 21 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4020      +/-   ##
============================================
- Coverage     85.24%   85.24%   -0.01%     
  Complexity     1402     1402              
============================================
  Files          1236     1237       +1     
  Lines        182594   182694     +100     
  Branches     148900   148900              
============================================
+ Hits         155661   155740      +79     
- Misses        22889    22910      +21     
  Partials       4044     4044              
Components Coverage Δ
Rust Core 86.13% <ø> (ø)
Java SDK 67.29% <ø> (ø)
C# SDK 76.42% <ø> (ø)
Python SDK 89.60% <79.00%> (-0.47%) ⬇️
PHP SDK 85.65% <ø> (ø)
Node SDK 96.22% <ø> (ø)
Go SDK 69.31% <ø> (ø)
Files with missing lines Coverage Δ
foreign/python/src/client.rs 99.86% <100.00%> (+<0.01%) ⬆️
foreign/python/src/lib.rs 100.00% <100.00%> (ø)
foreign/python/src/client_info.rs 67.18% <67.18%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yummyPancake2607

Copy link
Copy Markdown
Author

@slbotbm it is being able to pass in all the test just againit require approval to finish the tests

Comment thread foreign/python/Cargo.toml
Comment thread foreign/python/tests/test_client_info.py
Comment thread foreign/python/tests/test_client_info.py
Comment thread foreign/python/tests/test_client_info.py
Comment thread foreign/python/src/client.rs
Comment thread foreign/python/src/client_info.rs
Comment thread foreign/python/src/client_info.rs
Comment thread foreign/python/src/client_info.rs
Comment thread foreign/python/src/client.rs
Comment thread foreign/python/tests/test_client_info.py
@slbotbm

slbotbm commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

/author

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Sep 3, 2026
@hubcio

hubcio commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

you resolved all 17 threads without changing any code.
please reopen them and either fix the code or reply saying why you disagree. resolving is for after the change lands.

also, stop rebasing PR if it rebases without conflicts. maintainers will take care about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author PR is waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python SDK: expose get_me, get_client and get_clients

4 participants