fix: preserve CLI output defaults with outputs config

This commit is contained in:
mbsantiago 2026-05-07 09:15:55 +01:00
parent 0b410d9f4f
commit 48922b5910
2 changed files with 37 additions and 2 deletions

View File

@ -84,10 +84,10 @@ def common_predict_options(func):
"--format", "--format",
"format_name", "format_name",
type=str, type=str,
default="batdetect2",
help=( help=(
"Output format name used by the prediction writer. If omitted, " "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( @click.option(
@ -187,6 +187,9 @@ def _run_prediction(
if audio_dir is None: if audio_dir is None:
audio_dir = audio_files[0].parent if audio_files else 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( api.save_predictions(
predictions, predictions,
path=output_path, path=output_path,

View File

@ -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( def test_cli_process_file_list_runs_on_real_audio(
tmp_path: Path, tmp_path: Path,
tiny_checkpoint_path: Path, tiny_checkpoint_path: Path,