From e7deb6068d7dde22d2bbd4cd446fee86c5dcf53c Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Thu, 22 Jan 2026 11:11:54 -0500 Subject: [PATCH 1/6] feat: add folder ouput to the pipeline option --- batbot/__init__.py | 5 ++++- batbot/batbot.py | 21 +++++---------------- batbot/spectrogram/__init__.py | 5 +++++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/batbot/__init__.py b/batbot/__init__.py index 111778f..22641ea 100644 --- a/batbot/__init__.py +++ b/batbot/__init__.py @@ -63,6 +63,7 @@ def pipeline( config=None, # classifier_thresh=classifier.CONFIGS[None]['thresh'], clean=True, + output_folder=None, ): """ Run the ML pipeline on a given WAV filepath and return the classification results @@ -93,7 +94,9 @@ def pipeline( tuple ( float, list ( dict ) ): classifier score, list of time windows """ # Generate spectrogram - output_paths, metadata_path, metadata = spectrogram.compute(filepath) + output_paths, metadata_path, metadata = spectrogram.compute( + filepath, output_folder=output_folder + ) return output_paths, metadata_path diff --git a/batbot/batbot.py b/batbot/batbot.py index b47eb61..2263e4d 100755 --- a/batbot/batbot.py +++ b/batbot/batbot.py @@ -47,7 +47,8 @@ def fetch(config): ) @click.option( '--output', - help='Path to output JSON (if unspecified, results are printed to screen)', + 'output_path', + help='Path to output folder for the results', default=None, type=str, ) @@ -60,7 +61,7 @@ def fetch(config): def pipeline( filepath, config, - output, + output_path, # classifier_thresh, ): """ @@ -79,25 +80,13 @@ def pipeline( config = config.strip().lower() # classifier_thresh /= 100.0 - score = batbot.pipeline( + batbot.pipeline( filepath, config=config, # classifier_thresh=classifier_thresh, + output_folder=output_path, ) - data = { - filepath: { - 'classifier': score, - } - } - - log.debug('Outputting results...') - if output: - with open(output, 'w') as outfile: - json.dump(data, outfile) - else: - print(data) - @click.command('batch') @click.argument( diff --git a/batbot/spectrogram/__init__.py b/batbot/spectrogram/__init__.py index b9814a0..35781ef 100644 --- a/batbot/spectrogram/__init__.py +++ b/batbot/spectrogram/__init__.py @@ -1329,6 +1329,11 @@ def compute_wrapper( chunksize = int(50e3) + # create output folder if it doesn't exist + if not exists(output_folder): + os.makedirs(output_folder) + assert exists(output_folder) + debug_path = get_debug_path(output_folder, wav_filepath, enabled=debug) # Load the spectrogram from a WAV file on disk From 8bc1beea78fd4c918c7715e4ac4e5de7294a997a Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Thu, 22 Jan 2026 11:45:39 -0500 Subject: [PATCH 2/6] fix: resolve tests by defaulting to '.' for the output folder --- batbot/__init__.py | 2 +- batbot/spectrogram/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/batbot/__init__.py b/batbot/__init__.py index 22641ea..5fe4622 100644 --- a/batbot/__init__.py +++ b/batbot/__init__.py @@ -63,7 +63,7 @@ def pipeline( config=None, # classifier_thresh=classifier.CONFIGS[None]['thresh'], clean=True, - output_folder=None, + output_folder=".", ): """ Run the ML pipeline on a given WAV filepath and return the classification results diff --git a/batbot/spectrogram/__init__.py b/batbot/spectrogram/__init__.py index 35781ef..f1fa0f4 100644 --- a/batbot/spectrogram/__init__.py +++ b/batbot/spectrogram/__init__.py @@ -1330,7 +1330,7 @@ def compute_wrapper( chunksize = int(50e3) # create output folder if it doesn't exist - if not exists(output_folder): + if not os.path.exists(output_folder): os.makedirs(output_folder) assert exists(output_folder) From 7e6a7c0fbbe49bf9c19c042872ce81ede0aabaaf Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Thu, 22 Jan 2026 11:49:03 -0500 Subject: [PATCH 3/6] fix: pre-commit linting --- batbot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batbot/__init__.py b/batbot/__init__.py index 5fe4622..03cbc27 100644 --- a/batbot/__init__.py +++ b/batbot/__init__.py @@ -63,7 +63,7 @@ def pipeline( config=None, # classifier_thresh=classifier.CONFIGS[None]['thresh'], clean=True, - output_folder=".", + output_folder='.', ): """ Run the ML pipeline on a given WAV filepath and return the classification results From b36d6929ab5cc032a78bdff347f6e45ce1ceb40d Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Thu, 22 Jan 2026 12:29:16 -0500 Subject: [PATCH 4/6] fix: default output option --- batbot/batbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batbot/batbot.py b/batbot/batbot.py index 2263e4d..6ccebcb 100755 --- a/batbot/batbot.py +++ b/batbot/batbot.py @@ -49,7 +49,7 @@ def fetch(config): '--output', 'output_path', help='Path to output folder for the results', - default=None, + default=".", type=str, ) # @click.option( From 740efb7f8454270bee4fbb919048ee8f224c6488 Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Thu, 22 Jan 2026 12:31:39 -0500 Subject: [PATCH 5/6] fix: linting --- batbot/batbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batbot/batbot.py b/batbot/batbot.py index 6ccebcb..fa137e0 100755 --- a/batbot/batbot.py +++ b/batbot/batbot.py @@ -49,7 +49,7 @@ def fetch(config): '--output', 'output_path', help='Path to output folder for the results', - default=".", + default='.', type=str, ) # @click.option( From b93f23e96ce418f9066ed159a13f411995fa603e Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Mon, 26 Jan 2026 12:16:01 -0500 Subject: [PATCH 6/6] fix: codecov for example test --- batbot/__init__.py | 4 ++-- tests/test_spectrogram.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/batbot/__init__.py b/batbot/__init__.py index 03cbc27..c415831 100644 --- a/batbot/__init__.py +++ b/batbot/__init__.py @@ -164,7 +164,7 @@ def example(): assert exists(wav_filepath) log.debug(f'Running pipeline on WAV: {wav_filepath}') - - results = pipeline(wav_filepath) + output = './output' + results = pipeline(wav_filepath, output_folder=output) log.debug(results) diff --git a/tests/test_spectrogram.py b/tests/test_spectrogram.py index dcf03d5..47fc1dc 100644 --- a/tests/test_spectrogram.py +++ b/tests/test_spectrogram.py @@ -5,4 +5,5 @@ def test_spectrogram_compute(): from batbot.spectrogram import compute wav_filepath = abspath(join('examples', 'example2.wav')) - output_paths, metadata_path, metadata = compute(wav_filepath) + output_folder = './output' + output_paths, metadata_path, metadata = compute(wav_filepath, output_folder=output_folder)