From 70217ba90934ee0489da5787ecaab8173e087877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Mon, 23 Nov 2026 12:33:15 +0100 Subject: [PATCH] fix: `chipstream-cli --recursive` silently did nothing when PATH_IN is a file In recursive mode, `path_in.rglob("*.rtdc")` yields nothing for a file, so the CLI processed nothing and exited with 0. Now it prints an error and exits with 1, like it does for a directory without `--recursive`. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG | 1 + chipstream/cli/cli_main.py | 7 ++++++- tests/test_cli.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c54ee33..d873c51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 0.11.2 - fix: `python -m chipstream.cli` failed with ModuleNotFoundError + - fix: `chipstream-cli --recursive` silently did nothing when PATH_IN is a file 0.11.1 - enh: don't show rounded 100% in CLI progress - setup: bump dcnum to 0.31.2 diff --git a/chipstream/cli/cli_main.py b/chipstream/cli/cli_main.py index 8d9058d..3500b7b 100644 --- a/chipstream/cli/cli_main.py +++ b/chipstream/cli/cli_main.py @@ -219,7 +219,12 @@ def chipstream_cli( debug=debug, ) - if recursive: + if recursive and not path_in.is_dir(): + click.secho(f"PATH_IN must be a directory in recursive mode, but " + f"'{path_in}' is a file. Omit the `--recursive` flag " + f"to process a single file.", fg="red") + exit_code = 1 + elif recursive: failed = 0 # keeps track of files that failed to process for pi in sorted(path_in.rglob("*.rtdc")): if pi.name.endswith("_dcn.rtdc"): diff --git a/tests/test_cli.py b/tests/test_cli.py index 8379d55..58e8a0b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -216,6 +216,17 @@ def test_cli_python_m(): assert chipstream.__version__ in result.stdout +def test_cli_recursive_with_file(cli_runner): + """Recursive mode requires a directory as input""" + path = retrieve_data( + "fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip") + result = cli_runner.invoke(cli_main.chipstream_cli, + [str(path), "--recursive"]) + assert result.exit_code == 1 + assert result.stdout.count("must be a directory in recursive mode") + assert not path.with_name(path.stem + "_dcn.rtdc").exists() + + def test_cli_set_pixel_size(cli_runner): path_temp = retrieve_data( "fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip")