Repository navigation
Python SDK: expose snapshot #4611
Copy link
Copy link
Open
Labels
good first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python code
Description
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 newsnapshotmethod 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-emptybytesagainst a real server.- An unknown compression or snapshot type, or an empty type list, raises
ValueErrorbefore any request is sent. - The method has a docstring in the style of its neighbours, and the
.pyistub is regenerated. uv run --no-sync pytest tests/test_snapshot.py -vpasses.
Steps
- Read
snapshotinforeign/cpp/src/client.rsfor the argument checks and theFromStrcalls. - Add
snapshot(compression: &str, snapshot_types: Vec<String>)toforeign/python/src/client.rs, usingfuture_into_pyandto_runtime_errorasget_statsdoes, and map bad input toPyValueError. - Return the snapshot as
bytes. - Regenerate the stub with
cargo run --bin stub_gen(see the Python README) and commit theapache_iggy.pyichange. - Add
test_snapshot.pymodelled ontest_stats.py: a happy path, an invalid compression, an empty type list, and"all"combined with another type (the C++ testSnapshotAllCombinedWithOtherTypeThrowsshows the expected behaviour).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python code
Activity
debangshu919 commentedon Oct 21, 2026
Hi @justinmclean I'd like to work on this issue. I'll be adding the
snapshotmethod to the Python client, handle input validation for the compression and snapshot types, update the stubs, and write the tests intest_snapshot.py. Could you please assign it to me?slbotbm commentedon Oct 21, 2026
@debangshu919 assigned