Repository navigation
feat(python): expose snapshot #4616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
debangshu919
wants to merge
9
commits into
apache:master
Choose a base branch
from
debangshu919:feat/python-snapshot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b3a9dc2
feat(python): add snapshot support
debangshu919 151bb6e
fix(python): deduplicate parsed snapshot types and update docs
debangshu919 b1ea98d
fix(python): trim snapshot types and document binary timeout
debangshu919 3047354
chore(python): sync snapshot docstring in stub file
debangshu919 419e149
chore(python): remove redundant capacity cap in snapshot
debangshu919 069da08
refactor(python): rename compression to snapshot_compression
debangshu919 96c5e4d
refactor(python): use enums for snapshot compression and snapshot types
debangshu919 04c71b6
test(python): ignore pyrefly bad-argument-type in snapshot negative t…
debangshu919 d63fccd
refactor(python): address maintainer feedback
debangshu919 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use iggy::prelude::{ | ||
| SnapshotCompression as RustSnapshotCompression, SystemSnapshotType as RustSystemSnapshotType, | ||
| }; | ||
| use pyo3::prelude::*; | ||
| use pyo3_stub_gen::derive::gen_stub_pyclass_enum; | ||
|
|
||
| /// Compression method for server snapshots. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| #[gen_stub_pyclass_enum] | ||
| #[pyclass(eq, from_py_object)] | ||
| pub enum SnapshotCompression { | ||
| /// Store the file as is without compression. | ||
| Stored, | ||
| /// Compress the file using Deflate. | ||
| Deflated, | ||
| /// Compress the file using BZIP2. | ||
| Bzip2, | ||
| /// Compress the file using ZStandard. | ||
| Zstd, | ||
| /// Compress the file using LZMA. | ||
| Lzma, | ||
| /// Compress the file using XZ. | ||
| Xz, | ||
| } | ||
|
|
||
| impl From<SnapshotCompression> for RustSnapshotCompression { | ||
| fn from(compression: SnapshotCompression) -> Self { | ||
| match compression { | ||
| SnapshotCompression::Stored => RustSnapshotCompression::Stored, | ||
| SnapshotCompression::Deflated => RustSnapshotCompression::Deflated, | ||
| SnapshotCompression::Bzip2 => RustSnapshotCompression::Bzip2, | ||
| SnapshotCompression::Zstd => RustSnapshotCompression::Zstd, | ||
| SnapshotCompression::Lzma => RustSnapshotCompression::Lzma, | ||
| SnapshotCompression::Xz => RustSnapshotCompression::Xz, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<RustSnapshotCompression> for SnapshotCompression { | ||
| fn from(compression: RustSnapshotCompression) -> Self { | ||
| match compression { | ||
| RustSnapshotCompression::Stored => SnapshotCompression::Stored, | ||
| RustSnapshotCompression::Deflated => SnapshotCompression::Deflated, | ||
| RustSnapshotCompression::Bzip2 => SnapshotCompression::Bzip2, | ||
| RustSnapshotCompression::Zstd => SnapshotCompression::Zstd, | ||
| RustSnapshotCompression::Lzma => SnapshotCompression::Lzma, | ||
| RustSnapshotCompression::Xz => SnapshotCompression::Xz, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Type of system data to include in a snapshot. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| #[gen_stub_pyclass_enum] | ||
| #[pyclass(eq, from_py_object)] | ||
| pub enum SystemSnapshotType { | ||
| /// Overview of the filesystem. | ||
| FilesystemOverview, | ||
| /// List of currently running processes. | ||
| ProcessList, | ||
| /// Resource usage statistics of the system. | ||
| ResourceUsage, | ||
| /// Test snapshot type for development purposes. | ||
| Test, | ||
| /// Server logs. | ||
| ServerLogs, | ||
| /// Server configuration. | ||
| ServerConfig, | ||
| /// Everything. | ||
| All, | ||
| } | ||
|
|
||
| impl From<SystemSnapshotType> for RustSystemSnapshotType { | ||
| fn from(snapshot_type: SystemSnapshotType) -> Self { | ||
| match snapshot_type { | ||
| SystemSnapshotType::FilesystemOverview => RustSystemSnapshotType::FilesystemOverview, | ||
| SystemSnapshotType::ProcessList => RustSystemSnapshotType::ProcessList, | ||
| SystemSnapshotType::ResourceUsage => RustSystemSnapshotType::ResourceUsage, | ||
| SystemSnapshotType::Test => RustSystemSnapshotType::Test, | ||
| SystemSnapshotType::ServerLogs => RustSystemSnapshotType::ServerLogs, | ||
| SystemSnapshotType::ServerConfig => RustSystemSnapshotType::ServerConfig, | ||
| SystemSnapshotType::All => RustSystemSnapshotType::All, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<RustSystemSnapshotType> for SystemSnapshotType { | ||
| fn from(snapshot_type: RustSystemSnapshotType) -> Self { | ||
| match snapshot_type { | ||
| RustSystemSnapshotType::FilesystemOverview => SystemSnapshotType::FilesystemOverview, | ||
| RustSystemSnapshotType::ProcessList => SystemSnapshotType::ProcessList, | ||
| RustSystemSnapshotType::ResourceUsage => SystemSnapshotType::ResourceUsage, | ||
| RustSystemSnapshotType::Test => SystemSnapshotType::Test, | ||
| RustSystemSnapshotType::ServerLogs => SystemSnapshotType::ServerLogs, | ||
| RustSystemSnapshotType::ServerConfig => SystemSnapshotType::ServerConfig, | ||
| RustSystemSnapshotType::All => SystemSnapshotType::All, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.