Skip to content

feat(python): expose snapshot - #4616

Open
debangshu919 wants to merge 8 commits into
apache:masterfrom
debangshu919:feat/python-snapshot
Open

debangshu919 wants to merge 8 commits into
apache:masterfrom
debangshu919:feat/python-snapshot

Conversation

@debangshu919

@debangshu919 debangshu919 commented Oct 21, 2026 •

Copy link
Copy Markdown

Which issue does this PR address?

Closes #4611

Rationale

The Python SDK lacked support for taking server diagnostic snapshots, a capability already available in the Rust and C++ SDKs.

What changed?

The Python client had no interface to request server diagnostic snapshots.

IggyClient.snapshot() now captures server snapshots and returns compressed ZIP archive bytes. The method accepts strongly typed SnapshotCompression and SystemSnapshotType enums instead of raw strings, providing compile-time/IDE autocompletion and early type validation. The changes include full PyO3 bindings, regenerated type stubs in apache_iggy.pyi, and comprehensive unit and integration tests.

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

  1. Which tools? (e.g., GitHub Copilot, Claude, ChatGPT)
  • OpenCode
  1. Scope of usage? (e.g., autocomplete, generated functions, entire implementation)
  • Used AI tools to understand the codebase and generate tests
  1. How did you verify the generated code works correctly?
  • Ran unit tests and integration tests against a live iggy server with pytest (test_snapshot.py), ran cargo clippy and verified with ruff.
  1. Can you explain every line of the code if asked?
  • Yes

@github-actions

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
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Oct 21, 2026
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.73134% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.75%. Comparing base (b1adfe5) to head (04c71b6).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
foreign/python/src/snapshot.rs 22.50% 31 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4616      +/-   ##
============================================
- Coverage     90.76%   90.75%   -0.01%     
  Complexity     2966     2966              
============================================
  Files          1459     1460       +1     
  Lines        347741   347824      +83     
  Branches     292547   292547              
============================================
+ Hits         315617   315669      +52     
- Misses        25507    25538      +31     
  Partials       6617     6617              
Components Coverage Δ
Rust Core 92.08% <ø> (ø)
Java SDK 77.73% <ø> (ø)
C# SDK 83.54% <ø> (ø)
Python SDK 85.25% <53.73%> (-0.39%) ⬇️
PHP SDK 90.59% <ø> (ø)
Node SDK 96.45% <ø> (ø)
Go SDK 69.87% <ø> (ø)
C++ SDK 85.45% <ø> (ø)
Files with missing lines Coverage Δ
foreign/python/src/client.rs 99.12% <100.00%> (+0.03%) ⬆️
foreign/python/src/lib.rs 100.00% <100.00%> (ø)
foreign/python/src/snapshot.rs 22.50% <22.50%> (ø)
🚀 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.

@slbotbm

slbotbm commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: The Python snapshot() binding mirrors the Rust SDK and its dedupe protects the wire encoder, but it inherits a fixed 30-second transport deadline that large log snapshots can exceed. The method also trims compression but not snapshot_types, and the new dedupe path has no test.

Counts: critical 0, warning 1, nit 2, simplification 0


This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread foreign/python/src/client.rs
Comment thread foreign/python/src/client.rs Outdated
Comment thread foreign/python/src/client.rs Outdated
@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 Oct 21, 2026
@debangshu919

Copy link
Copy Markdown
Author

/ready

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

@slbotbm slbotbm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add snapshot compression and snapshot types as enums instead of allowing the user to freely enter strings for them.

Comment thread foreign/python/src/client.rs Outdated
@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 Oct 24, 2026
@debangshu919

Copy link
Copy Markdown
Author

Hi @slbotbm thanks for the review!
I've replaced the string parameters with SnapshotCompression and SystemSnapshotType enums as you suggested, and also rebased the branch onto latest master to resolve the merge conflicts.

Please let me know if any further adjustments are needed.

@debangshu919

Copy link
Copy Markdown
Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Oct 24, 2026
@debangshu919
debangshu919 requested a review from slbotbm October 24, 2026 12:36

let mut parsed_types = Vec::with_capacity(snapshot_types.len());
for snapshot_type in snapshot_types {
let rust_type: SystemSnapshotType = snapshot_type.into();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's make this SystemSnapshotType::from(snapshot_type)

}

let inner = self.inner.clone();
let compression: SnapshotCompression = snapshot_compression.into();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SnapshotCompression::from(snapshot_compression)

Comment on lines +118 to +122
#[cfg(test)]
mod tests {
use super::*;

#[test]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these tests are not required

Comment on lines +90 to +95
@pytest.mark.unit
def test_snapshot_enums(self):
"""Snapshot compression and type enums expose expected variants."""
assert SnapshotCompression.Deflated == SnapshotCompression.Deflated
assert SnapshotCompression.Deflated != SnapshotCompression.Stored
assert SystemSnapshotType.All == SystemSnapshotType.All

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is not required

@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 Oct 28, 2026

This branch has not been deployed

No deployments
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 snapshot

2 participants