mirror of
https://github.com/macaodha/batdetect2.git
synced 2026-05-22 22:32:18 +02:00
fix: preserve CLI output defaults with outputs config
This commit is contained in:
parent
0b410d9f4f
commit
48922b5910
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user