Skip to content

Add feature that when activated hides all progress bars #66

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ features = ["extension-module","abi3-py36"]

[features]
default = ["jemalloc"]
jemalloc = []
jemalloc = []
no-progress-bars = []
2 changes: 1 addition & 1 deletion auto_compressor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ postgres-openssl = "0.5.0"
jemallocator = "0.3.2"
rand = "0.8.0"
serial_test = "0.5.1"
synapse_compress_state = { path = "../" }
synapse_compress_state = { path = "../", features = ["no-progress-bars"] }
env_logger = { version = "0.9.0", git = "https://github.com/TilCreator/env_logger", branch = "fix_pipe" }
log = "0.4.14"
log-panics = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion compressor_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ openssl = "0.10.32"
postgres = "0.19.0"
postgres-openssl = "0.5.0"
rand = "0.8.0"
synapse_compress_state = { path = "../" }
synapse_compress_state = { path = "../", features = ["no-progress-bars"] }
auto_compressor = { path = "../auto_compressor/" }
env_logger = "0.9.0"
log = "0.4.14"
Expand Down
7 changes: 6 additions & 1 deletion src/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ impl<'a> Compressor<'a> {
panic!("Can only call `create_new_tree` once");
}

let pb = ProgressBar::new(self.original_state_map.len() as u64);
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
} else {
pb = ProgressBar::new(self.original_state_map.len() as u64);
}
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
Expand Down
14 changes: 12 additions & 2 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ fn get_initial_data_from_db(
// Copy the data from the database into a map
let mut state_group_map: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();

let pb = ProgressBar::new_spinner();
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
} else {
pb = ProgressBar::new_spinner();
}
pb.set_style(
ProgressStyle::default_spinner().template("{spinner} [{elapsed}] {pos} rows retrieved"),
);
Expand Down Expand Up @@ -533,7 +538,12 @@ pub fn send_changes_to_db(
println!("Writing changes...");

// setup the progress bar
let pb = ProgressBar::new(old_map.len() as u64);
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ fn output_sql(

println!("Writing changes...");

let pb = ProgressBar::new(old_map.len() as u64);
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
Expand Down Expand Up @@ -597,7 +602,12 @@ fn check_that_maps_match(
) {
println!("Checking that state maps match...");

let pb = ProgressBar::new(old_map.len() as u64);
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
Expand Down