Skip to content

fix: chipstream-cli --recursive stopped at the first failed file - #17

Merged
paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:fix-cli-recursive-failures
Nov 23, 2026
Merged

paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:fix-cli-recursive-failures

Conversation

@paulmueller-agent

Copy link
Copy Markdown

Bug

In recursive mode (-r), the first file that fails aborts the whole batch:

  • process_dataset raises click.ClickException on errors instead of returning 1, so the exception leaves the loop, all later files are skipped, and the failed counter never counts anything.
  • An existing <name>_dcn.rtdc output makes dcnum raise FileExistsError, which aborts the batch, so an interrupted batch cannot be resumed by running the same command again.

Observed with a directory containing a_bad.rtdc (not an HDF5 file) and b_good.rtdc:

$ chipstream-cli -r in out
Processing .../in/a_bad.rtdc
Error: Not a valid input file '.../in/a_bad.rtdc'.

b_good.rtdc is never processed.

Fix

  • Each file is processed in a try block. click.ClickException and other exceptions are reported for that file, and the loop continues. At the end, the failed files are listed and the exit code is 1.
  • Files whose output file already exists are skipped with a message and counted separately (not as failures). dcnum only renames its temporary file to the output path after a successful run, so an existing output file means that file was processed.
  • click.UsageError (invalid command-line arguments) still aborts, since it applies to all files.
  • In dry-run mode, no files are skipped (nothing is written).
$ chipstream-cli -r in out
Processing .../in/a_bad.rtdc
Failed to process .../in/a_bad.rtdc: Not a valid input file '.../in/a_bad.rtdc'.

Processing .../in/b_good.rtdc
...
Could not process 1 file(s):
 - .../in/a_bad.rtdc
Encountered problems during processing

Running again on a directory where a_dcn.rtdc exists:

Skipping .../in/a.rtdc, because the output file '.../in/a_dcn.rtdc' exists
Processing .../in/b.rtdc
...
Skipped 1 file(s) with existing output

Tests

  • test_cli_recursive_continue_after_failure (with and without PATH_OUT): the valid file is processed after the invalid one, exit code 1, failure listed.

  • test_cli_recursive_skip_existing_output (with and without PATH_OUT): the existing output is not touched, the other file is processed, exit code 0.

  • test_cli_recursive_invalid_kwargs: an invalid -ks value still aborts the batch with a usage error (guards the click.UsageError re-raise; it also passes on main).

The first two fail on main and pass with the fix (run with --debug). flake8 is clean; ruff shows no new errors.

🤖 Generated with Claude Code

- catch errors per file, continue with the next file, and list the
  failed files at the end (the failure counter never counted anything,
  because `process_dataset` raises instead of returning 1)
- skip files whose `_dcn.rtdc` output file already exists instead of
  aborting the batch, so an interrupted batch can be resumed (dcnum
  only creates the output file after the pipeline completed)
- invalid command-line arguments (`click.UsageError`) still abort,
  since they apply to all files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.37%. Comparing base (a5069ff) to head (73e93ff).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
chipstream/cli/cli_main.py 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #17      +/-   ##
==========================================
+ Coverage   76.00%   77.37%   +1.37%     
==========================================
  Files          19       19              
  Lines        1350     1370      +20     
==========================================
+ Hits         1026     1060      +34     
+ Misses        324      310      -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmueller
paulmueller merged commit 13d9143 into DC-analysis:main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants