diff --git a/src/servicex_did_finder_lib/accumulator.py b/src/servicex_did_finder_lib/accumulator.py index 8238f3e..53e328b 100644 --- a/src/servicex_did_finder_lib/accumulator.py +++ b/src/servicex_did_finder_lib/accumulator.py @@ -63,7 +63,11 @@ def send_on(self, count): # Sort the list to insure reproducibility files = sorted(self.file_cache, key=lambda x: x["paths"]) - self.send_bulk(files[:count]) + if count == -1: + self.send_bulk(files) + else: + self.send_bulk(files[:count]) + self.file_cache.clear() def send_bulk(self, file_list: List[Dict[str, Any]]): diff --git a/tests/servicex_did_finder_lib_tests/test_accumulator.py b/tests/servicex_did_finder_lib_tests/test_accumulator.py index 465de85..3262c66 100644 --- a/tests/servicex_did_finder_lib_tests/test_accumulator.py +++ b/tests/servicex_did_finder_lib_tests/test_accumulator.py @@ -56,7 +56,7 @@ def test_add_list_of_files(servicex, did_summary_obj, single_file_info): def test_send_on(servicex, did_summary_obj, single_file_info): acc = Accumulator(sx=servicex, sum=did_summary_obj) - acc.add([single_file_info, single_file_info, single_file_info]) + acc.add([single_file_info, single_file_info, single_file_info, single_file_info]) acc.send_on(3) servicex.put_file_add_bulk.assert_called_with( [single_file_info, single_file_info, single_file_info] @@ -65,6 +65,17 @@ def test_send_on(servicex, did_summary_obj, single_file_info): assert acc.summary.file_count == 3 +def test_send_on_all_files(servicex, did_summary_obj, single_file_info): + acc = Accumulator(sx=servicex, sum=did_summary_obj) + acc.add([single_file_info, single_file_info, single_file_info]) + acc.send_on(-1) + servicex.put_file_add_bulk.assert_called_with( + [single_file_info, single_file_info, single_file_info] + ) + assert acc.cache_len == 0 + assert acc.summary.file_count == 3 + + def test_invalid_constructor_arg(servicex, did_summary_obj): with pytest.raises(ValueError): acc = Accumulator(sx=servicex, sum=did_summary_obj)