Skip to content

Python SDK: expose snapshot #4611

Open

Description

@justinmclean

The Python SDK has no way to take a server snapshot. The Rust client and the C++ SDK both have one.

Where

  • foreign/python/src/client.rs: a new snapshot method on the client.
  • foreign/python/apache_iggy.pyi: the regenerated stub.
  • foreign/python/tests/test_snapshot.py: a new test file.

Context

The Rust trait is SystemClient::snapshot(compression: SnapshotCompression, snapshot_types: Vec<SystemSnapshotType>) -> Result<Snapshot, IggyError> in core/common/src/traits/system_client.rs. Snapshot wraps a Vec<u8> (core/common/src/types/snapshot/mod.rs), so the Python method can return bytes with no new result class.

Both enums implement FromStr in that file, so the arguments can be plain strings, the way describe_options takes a scope string:

  • compression: stored, deflated, bzip2, zstd, lzma, xz
  • snapshot types: filesystem_overview, process_list, resource_usage, test, server_logs, server_config, all

The C++ SDK already does this in snapshot in foreign/cpp/src/client.rs, including rejecting an empty type list and an empty or unknown compression. Use it as the worked example.

Done looks like

  • data = await client.snapshot("deflated", ["all"]) returns non-empty bytes against a real server.
  • An unknown compression or snapshot type, or an empty type list, raises ValueError before any request is sent.
  • The method has a docstring in the style of its neighbours, and the .pyi stub is regenerated.
  • uv run --no-sync pytest tests/test_snapshot.py -v passes.

Steps

  • Read snapshot in foreign/cpp/src/client.rs for the argument checks and the FromStr calls.
  • Add snapshot(compression: &str, snapshot_types: Vec<String>) to foreign/python/src/client.rs, using future_into_py and to_runtime_error as get_stats does, and map bad input to PyValueError.
  • Return the snapshot as bytes.
  • Regenerate the stub with cargo run --bin stub_gen (see the Python README) and commit the apache_iggy.pyi change.
  • Add test_snapshot.py modelled on test_stats.py: a happy path, an invalid compression, an empty type list, and "all" combined with another type (the C++ test SnapshotAllCombinedWithOtherTypeThrows shows the expected behaviour).

Activity

  1. debangshu919 commented on Oct 21, 2026

    @debangshu919

    Hi @justinmclean I'd like to work on this issue. I'll be adding the snapshot method to the Python client, handle input validation for the compression and snapshot types, update the stubs, and write the tests in test_snapshot.py. Could you please assign it to me?

  2. slbotbm commented on Oct 21, 2026

    @slbotbm
    Contributor

    @debangshu919 assigned

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

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerspythonPull requests that update Python code

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions