diff --git a/src/batdetect2/cli/inference.py b/src/batdetect2/cli/inference.py index baa7b41..c5e189b 100644 --- a/src/batdetect2/cli/inference.py +++ b/src/batdetect2/cli/inference.py @@ -84,10 +84,10 @@ def common_predict_options(func): "--format", "format_name", type=str, - default="batdetect2", help=( "Output format name used by the prediction writer. If omitted, " - "the config default is used." + "the loaded outputs config is used, or batdetect2 when no " + "outputs config is provided." ), ) @click.option( @@ -187,6 +187,9 @@ def _run_prediction( if audio_dir is None: audio_dir = audio_files[0].parent if audio_files else None + if format_name is None and outputs_conf is None: + format_name = "batdetect2" + api.save_predictions( predictions, path=output_path, diff --git a/tests/test_cli/test_predict.py b/tests/test_cli/test_predict.py index 5b10bb8..1f72a71 100644 --- a/tests/test_cli/test_predict.py +++ b/tests/test_cli/test_predict.py @@ -209,6 +209,38 @@ def test_cli_process_directory_batdetect2_writes_cnn_features_csv_when_enabled( ] +def test_cli_process_directory_defaults_to_batdetect2_without_output_options( + tmp_path: Path, + tiny_checkpoint_path: Path, + single_audio_dir: Path, +) -> None: + """User story: default process output stays batdetect2 for CLI users.""" + + output_path = tmp_path / "predictions" + + result = CliRunner().invoke( + cli, + [ + "process", + "directory", + "--model", + str(tiny_checkpoint_path), + str(single_audio_dir), + str(output_path), + "--batch-size", + "1", + "--workers", + "0", + ], + ) + + assert result.exit_code == 0 + assert output_path.exists() + assert len(list(output_path.glob("*.json"))) == 1 + assert len(list(output_path.glob("*.csv"))) == 1 + assert len(list(output_path.glob("*.nc"))) == 0 + + def test_cli_process_file_list_runs_on_real_audio( tmp_path: Path, tiny_checkpoint_path: Path,