Skip to content

Commit 8389ea6

Browse files
authored
Print progress bar in dry_load_files (#928)
1 parent 739ad30 commit 8389ea6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

strax/io.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515

1616
export, __all__ = strax.exporter()
1717

18+
# use tqdm as loaded in utils (from tqdm.notebook when in a jupyter env)
19+
tqdm = strax.utils.tqdm
20+
1821
blosc.set_releasegil(True)
1922
blosc.set_nthreads(1)
2023

21-
2224
# zstd's default compression level is 3:
2325
# https://github.com/sergey-dryabzhinsky/python-zstd/blob/eba9e633e0bc0e9c9762c985d0433e08405fd097/src/python-zstd.h#L53
2426
# we also need to constraint the number of worker threads to 1
@@ -109,7 +111,7 @@ def _compress_blosc(data):
109111

110112

111113
@export
112-
def dry_load_files(dirname, chunk_numbers=None, **kwargs):
114+
def dry_load_files(dirname, chunk_numbers=None, disable=False, **kwargs):
113115
prefix = strax.storage.files.dirname_to_prefix(dirname)
114116
metadata_json = RUN_METADATA_PATTERN % prefix
115117
md_path = os.path.join(dirname, metadata_json)
@@ -148,7 +150,7 @@ def load_chunk(chunk_info):
148150
raise ValueError(f"Chunk {max(chunk_numbers):06d} does not exist in {dirname}.")
149151

150152
results = []
151-
for c in chunk_numbers:
153+
for c in tqdm(chunk_numbers, disable=disable):
152154
chunk_info = metadata["chunks"][c]
153155
x = load_chunk(chunk_info)
154156
x = strax.apply_selection(x, **kwargs)

0 commit comments

Comments
 (0)