diff --git a/CHANGELOG.md b/CHANGELOG.md index 236a860..61ab459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,11 @@ All notable changes, updates, and fixes to pod5 will be documented here The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [0.1.21] 2023-04-27 ### Fixed -- Repacker reads_completed value while copying a selection of reads. +- Repacker `reads_completed` value while copying a selection of reads. - Fixed crash when trying to load files with a bad footer. ## [0.1.20] 2023-04-20 diff --git a/python/pod5/pyproject.toml b/python/pod5/pyproject.toml index 00cb82f..f8fab1a 100644 --- a/python/pod5/pyproject.toml +++ b/python/pod5/pyproject.toml @@ -30,7 +30,7 @@ classifiers=[ dependencies = [ "iso8601", "jsonschema", - "lib_pod5 ~= 0.1.20dev0", + "lib_pod5 ~= 0.1.21dev0", "more_itertools", "numpy >= 1.20.0", "pyarrow ~= 11.0.0", diff --git a/python/pod5/src/pod5/repack.py b/python/pod5/src/pod5/repack.py index 602bd0a..48a5e4a 100644 --- a/python/pod5/src/pod5/repack.py +++ b/python/pod5/src/pod5/repack.py @@ -8,7 +8,8 @@ import lib_pod5 as p5b import pod5 as p5 -from tqdm import tqdm +from pod5.tools.utils import PBAR_DEFAULTS +from tqdm.auto import tqdm # The default interval in seconds to check for completion DEFAULT_INTERVAL = 0.5 @@ -161,10 +162,10 @@ def wait( disable_pbar = not bool(int(os.environ.get("POD5_PBAR", 1))) or not show_pbar pbar = tqdm( total=self.reads_requested, - ascii=True, disable=disable_pbar, leave=leave_pbar, unit="Reads", + **PBAR_DEFAULTS, ) last_time, last_bytes, last_reads = time.time(), 0, 0 @@ -187,7 +188,6 @@ def wait( pbar.total = self.reads_requested pbar.update(self.reads_completed - last_reads) last_reads = self.reads_completed - # tqdm.write(f"{self.reads_completed} , {self.reads_requested}") if finish: self.finish() diff --git a/python/pod5/src/pod5/tools/pod5_convert_from_fast5.py b/python/pod5/src/pod5/tools/pod5_convert_from_fast5.py index a87b1b4..8b303e2 100644 --- a/python/pod5/src/pod5/tools/pod5_convert_from_fast5.py +++ b/python/pod5/src/pod5/tools/pod5_convert_from_fast5.py @@ -26,7 +26,7 @@ import pod5 as p5 from pod5.signal_tools import DEFAULT_SIGNAL_CHUNK_SIZE, vbz_compress_signal_chunked from pod5.tools.parsers import pod5_convert_from_fast5_argparser, run_tool -from pod5.tools.utils import is_pod5_debug, iterate_inputs +from pod5.tools.utils import PBAR_DEFAULTS, is_pod5_debug, iterate_inputs READ_CHUNK_SIZE = 400 TIMEOUT_SECONDS = 600 @@ -371,12 +371,11 @@ def __init__(self, paths: List[Path]): disable_pbar = not bool(int(os.environ.get("POD5_PBAR", 1))) self.pbar = tqdm( total=self.total_reads, - ascii=True, disable=disable_pbar, desc=f"Converting {len(self.path_reads)} Fast5s", unit="Reads", leave=True, - dynamic_ncols=True, + **PBAR_DEFAULTS, ) @property diff --git a/python/pod5/src/pod5/tools/pod5_merge.py b/python/pod5/src/pod5/tools/pod5_merge.py index 8b089e0..0faae80 100644 --- a/python/pod5/src/pod5/tools/pod5_merge.py +++ b/python/pod5/src/pod5/tools/pod5_merge.py @@ -10,6 +10,7 @@ import pod5 as p5 import pod5.repack as p5_repack from pod5.tools.parsers import prepare_pod5_merge_argparser, run_tool +from pod5.tools.utils import PBAR_DEFAULTS from tqdm import tqdm # Default number of files to merge at a time @@ -75,9 +76,9 @@ def merge_pod5( disable_pbar = not bool(int(os.environ.get("POD5_PBAR", 1))) pbar = tqdm( total=len(inputs), - ascii=True, disable=disable_pbar or len(chunks) == 1, unit="Files", + **PBAR_DEFAULTS, ) for chunk in chunks: diff --git a/python/pod5/src/pod5/tools/pod5_repack.py b/python/pod5/src/pod5/tools/pod5_repack.py index 13219d3..1254ed0 100644 --- a/python/pod5/src/pod5/tools/pod5_repack.py +++ b/python/pod5/src/pod5/tools/pod5_repack.py @@ -6,7 +6,8 @@ import sys import typing from pathlib import Path -from tqdm import tqdm +from pod5.tools.utils import PBAR_DEFAULTS +from tqdm.auto import tqdm import pod5 as p5 import pod5.repack @@ -51,7 +52,9 @@ def repack_pod5( futures = {} with ProcessPoolExecutor(max_workers=threads) as executor: - pbar = tqdm(total=len(inputs), ascii=True, disable=disable_pbar, unit="Files") + pbar = tqdm( + total=len(inputs), disable=disable_pbar, unit="Files", **PBAR_DEFAULTS + ) for src in inputs: dest = output / src.name diff --git a/python/pod5/src/pod5/tools/pod5_subset.py b/python/pod5/src/pod5/tools/pod5_subset.py index c19b3b1..37bb0aa 100644 --- a/python/pod5/src/pod5/tools/pod5_subset.py +++ b/python/pod5/src/pod5/tools/pod5_subset.py @@ -12,7 +12,8 @@ import jsonschema import pandas as pd -from tqdm import tqdm +from pod5.tools.utils import PBAR_DEFAULTS +from tqdm.auto import tqdm import pod5 as p5 import pod5.repack as p5_repack @@ -353,9 +354,9 @@ def subset_pod5s_with_mapping( with ProcessPoolExecutor(max_workers=n_workers) as executor: pbar = tqdm( total=len(transfers), - ascii=True, disable=(disable_pbar or single_transfer), unit="Files", + **PBAR_DEFAULTS, ) # Launch the subsetting jobs diff --git a/python/pod5/src/pod5/tools/utils.py b/python/pod5/src/pod5/tools/utils.py index 0cc6a10..cc3c3f1 100644 --- a/python/pod5/src/pod5/tools/utils.py +++ b/python/pod5/src/pod5/tools/utils.py @@ -7,6 +7,9 @@ from pathlib import Path +PBAR_DEFAULTS = dict(ascii=True, smoothing=0.0, dynamic_ncols=True) + + def iterate_inputs( input_items: typing.Iterable[Path], recursive: bool, file_pattern: str ) -> typing.Generator[Path, None, None]: