From 448016ef02861acfff3cb8f5c42266497bca0d11 Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 28 Aug 2024 11:08:49 +0100 Subject: [PATCH 1/5] resave main() returns nothing to indicate no error --- src/ome2024_ngff_challenge/resave.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ome2024_ngff_challenge/resave.py b/src/ome2024_ngff_challenge/resave.py index 586f2f1..022bf53 100755 --- a/src/ome2024_ngff_challenge/resave.py +++ b/src/ome2024_ngff_challenge/resave.py @@ -406,10 +406,9 @@ def write( config.zr_write_text(filename, text) -def main(ns: argparse.Namespace) -> int: +def main(ns: argparse.Namespace) -> None: """ - If no images are converted, raises - SystemExit. Otherwise, return the number of images. + If no images are converted, raises SystemExit. """ converted: int = 0 @@ -550,7 +549,6 @@ def main(ns: argparse.Namespace) -> int: if converted == 0: raise SystemExit(1) - return converted def cli(subparsers: argparse._SubParsersAction): From c3bdbfbc0875d0ce77303e613671fea4ce50c3a9 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 29 Aug 2024 10:21:01 +0100 Subject: [PATCH 2/5] Revert "resave main() returns nothing to indicate no error" This reverts commit 448016ef02861acfff3cb8f5c42266497bca0d11. --- src/ome2024_ngff_challenge/resave.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ome2024_ngff_challenge/resave.py b/src/ome2024_ngff_challenge/resave.py index 022bf53..586f2f1 100755 --- a/src/ome2024_ngff_challenge/resave.py +++ b/src/ome2024_ngff_challenge/resave.py @@ -406,9 +406,10 @@ def write( config.zr_write_text(filename, text) -def main(ns: argparse.Namespace) -> None: +def main(ns: argparse.Namespace) -> int: """ - If no images are converted, raises SystemExit. + If no images are converted, raises + SystemExit. Otherwise, return the number of images. """ converted: int = 0 @@ -549,6 +550,7 @@ def main(ns: argparse.Namespace) -> None: if converted == 0: raise SystemExit(1) + return converted def cli(subparsers: argparse._SubParsersAction): From 87135657ace0e647845743542dc0bdba74217f1a Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 29 Aug 2024 10:34:18 +0100 Subject: [PATCH 3/5] Add --silent option to return nothing --- src/ome2024_ngff_challenge/resave.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ome2024_ngff_challenge/resave.py b/src/ome2024_ngff_challenge/resave.py index 586f2f1..00aa3a4 100755 --- a/src/ome2024_ngff_challenge/resave.py +++ b/src/ome2024_ngff_challenge/resave.py @@ -406,10 +406,10 @@ def write( config.zr_write_text(filename, text) -def main(ns: argparse.Namespace) -> int: +def main(ns: argparse.Namespace) -> int | None: """ - If no images are converted, raises - SystemExit. Otherwise, return the number of images. + If no images are converted, raises SystemExit. + Otherwise, return the number of images, unless --silent. """ converted: int = 0 @@ -550,6 +550,11 @@ def main(ns: argparse.Namespace) -> int: if converted == 0: raise SystemExit(1) + + # Support for nextflow etc where response is interpreted as an error. + if ns.silent: + return None + return converted @@ -675,6 +680,7 @@ def cli(subparsers: argparse._SubParsersAction): default=16, help="number of simultaneous write threads", ) + parser.add_argument("--silent", action="store_true", help="Command returns nothing") # Very recommended metadata (SHOULD!) def license_action(group, arg: str, url: str, recommended: bool = True): From 59acc00911c940401def77d1705de6c738ac7f78 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Fri, 30 Aug 2024 13:54:01 +0200 Subject: [PATCH 4/5] Mention nextflow in help --- src/ome2024_ngff_challenge/resave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ome2024_ngff_challenge/resave.py b/src/ome2024_ngff_challenge/resave.py index 00aa3a4..3119477 100755 --- a/src/ome2024_ngff_challenge/resave.py +++ b/src/ome2024_ngff_challenge/resave.py @@ -680,7 +680,7 @@ def cli(subparsers: argparse._SubParsersAction): default=16, help="number of simultaneous write threads", ) - parser.add_argument("--silent", action="store_true", help="Command returns nothing") + parser.add_argument("--silent", action="store_true", help="Command returns nothing; required for nextflow") # Very recommended metadata (SHOULD!) def license_action(group, arg: str, url: str, recommended: bool = True): From 0f556a15dced186de98b6c8a68cd9e32d797f1cc Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Fri, 30 Aug 2024 13:57:07 +0200 Subject: [PATCH 5/5] Fix formatting --- src/ome2024_ngff_challenge/resave.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ome2024_ngff_challenge/resave.py b/src/ome2024_ngff_challenge/resave.py index 3119477..f915431 100755 --- a/src/ome2024_ngff_challenge/resave.py +++ b/src/ome2024_ngff_challenge/resave.py @@ -680,7 +680,11 @@ def cli(subparsers: argparse._SubParsersAction): default=16, help="number of simultaneous write threads", ) - parser.add_argument("--silent", action="store_true", help="Command returns nothing; required for nextflow") + parser.add_argument( + "--silent", + action="store_true", + help="Command returns nothing; required for nextflow", + ) # Very recommended metadata (SHOULD!) def license_action(group, arg: str, url: str, recommended: bool = True):