@@ -22,7 +22,7 @@ def setup_method(self):
2222 """Set up test fixtures."""
2323 self .test_config = {
2424 'grobid_server' : 'http://localhost:8070' ,
25- 'batch_size ' : 1000 ,
25+ 'queue_size ' : 1000 ,
2626 'coordinates' : ["persName" , "figure" , "ref" ],
2727 'sleep_time' : 5 ,
2828 'timeout' : 60 ,
@@ -43,7 +43,7 @@ def test_init_default_values(self, mock_configure_logging, mock_test_server):
4343 client = GrobidClient (check_server = False )
4444
4545 assert client .config ['grobid_server' ] == 'http://localhost:8070'
46- assert client .config ['batch_size ' ] == 10
46+ assert client .config ['queue_size ' ] == 10
4747 assert client .config ['sleep_time' ] == 5
4848 assert client .config ['timeout' ] == 180
4949 assert 'persName' in client .config ['coordinates' ]
@@ -58,15 +58,15 @@ def test_init_custom_values(self, mock_configure_logging, mock_test_server):
5858 custom_coords = ["figure" , "ref" ]
5959 client = GrobidClient (
6060 grobid_server = 'http://custom:9090' ,
61- batch_size = 500 ,
61+ queue_size = 500 ,
6262 coordinates = custom_coords ,
6363 sleep_time = 10 ,
6464 timeout = 120 ,
6565 check_server = False
6666 )
6767
6868 assert client .config ['grobid_server' ] == 'http://custom:9090'
69- assert client .config ['batch_size ' ] == 500
69+ assert client .config ['queue_size ' ] == 500
7070 assert client .config ['coordinates' ] == custom_coords
7171 assert client .config ['sleep_time' ] == 10
7272 assert client .config ['timeout' ] == 120
@@ -114,6 +114,19 @@ def test_load_config_success(self, mock_configure_logging, mock_test_server, moc
114114 mock_file .assert_called_once_with ('/path/to/config.json' , 'r' )
115115 assert client .config ['grobid_server' ] == 'http://test:8080'
116116
117+ @patch ('builtins.open' , new_callable = mock_open , read_data = '{"batch_size": 250}' )
118+ @patch ('grobid_client.grobid_client.GrobidClient._test_server_connection' )
119+ @patch ('grobid_client.grobid_client.GrobidClient._configure_logging' )
120+ def test_load_config_legacy_batch_size (self , mock_configure_logging , mock_test_server , mock_file ):
121+ """Test that the deprecated batch_size config key is mapped to queue_size."""
122+ mock_test_server .return_value = (True , 200 )
123+
124+ client = GrobidClient (check_server = False )
125+ client ._load_config ('/path/to/config.json' )
126+
127+ assert client .config ['queue_size' ] == 250
128+ assert 'batch_size' not in client .config
129+
117130 @patch ('grobid_client.grobid_client.GrobidClient._test_server_connection' )
118131 @patch ('grobid_client.grobid_client.GrobidClient._configure_logging' )
119132 def test_load_config_file_not_found (self , mock_configure_logging , mock_test_server ):
@@ -680,12 +693,12 @@ def test_get_server_url_edge_cases(self, mock_configure_logging, mock_test_serve
680693class TestArchiveInput :
681694 """Tests for streaming zip/tar archives as input (process_archive)."""
682695
683- def _client (self , batch_size = 2 ):
696+ def _client (self , queue_size = 2 ):
684697 with patch ('grobid_client.grobid_client.GrobidClient._test_server_connection' ):
685698 with patch ('grobid_client.grobid_client.GrobidClient._configure_logging' ):
686699 client = GrobidClient (check_server = False )
687700 client .logger = Mock ()
688- client .config ['batch_size ' ] = batch_size
701+ client .config ['queue_size ' ] = queue_size
689702 return client
690703
691704 @staticmethod
@@ -757,7 +770,7 @@ def test_safe_member_path_blocks_traversal(self):
757770 assert client ._safe_member_path (dest , '.' ) is None
758771
759772 def test_process_zip_streams_all_pdfs (self ):
760- client = self ._client (batch_size = 2 )
773+ client = self ._client (queue_size = 2 )
761774 with tempfile .TemporaryDirectory () as d :
762775 zip_path = os .path .join (d , 'docs.zip' )
763776 self ._make_zip (zip_path , {
@@ -779,7 +792,7 @@ def test_process_zip_streams_all_pdfs(self):
779792 ]
780793
781794 def test_process_targz (self ):
782- client = self ._client (batch_size = 10 )
795+ client = self ._client (queue_size = 10 )
783796 with tempfile .TemporaryDirectory () as d :
784797 tar_path = os .path .join (d , 'docs.tar.gz' )
785798 self ._make_targz (tar_path , {'x.pdf' : b'%PDF-x' , 'nested/y.pdf' : b'%PDF-y' }, d )
@@ -802,7 +815,7 @@ def test_process_routes_archive_to_core(self):
802815 assert mock_core .call_args .args [1 ] == zip_path
803816
804817 def test_process_zip_default_output_named_after_archive (self ):
805- client = self ._client (batch_size = 10 )
818+ client = self ._client (queue_size = 10 )
806819 with tempfile .TemporaryDirectory () as d :
807820 zip_path = os .path .join (d , 'mydocs.zip' )
808821 self ._make_zip (zip_path , {'a.pdf' : b'%PDF' })
@@ -811,7 +824,7 @@ def test_process_zip_default_output_named_after_archive(self):
811824
812825 def test_archive_entries_never_touch_disk (self ):
813826 """PDFs go from the archive straight to GROBID, without a temp dir."""
814- client = self ._client (batch_size = 2 )
827+ client = self ._client (queue_size = 2 )
815828 with tempfile .TemporaryDirectory () as d :
816829 zip_path = os .path .join (d , 'docs.zip' )
817830 self ._make_zip (zip_path , {'a.pdf' : b'%PDF-a' , 'sub/b.pdf' : b'%PDF-b' })
@@ -831,7 +844,7 @@ def fake_post(url, files=None, data=None, headers=None, timeout=None):
831844
832845 def test_citation_lists_are_still_extracted_to_disk (self ):
833846 """process_txt reads from a path, so citation lists keep the temp-dir route."""
834- client = self ._client (batch_size = 10 )
847+ client = self ._client (queue_size = 10 )
835848 with tempfile .TemporaryDirectory () as d :
836849 zip_path = os .path .join (d , 'refs.zip' )
837850 self ._make_zip (zip_path , {'refs.txt' : b'one reference per line' })
@@ -954,7 +967,7 @@ def fake_post(url=None, files=None, data=None, headers=None, timeout=None):
954967 def test_archive_processing_runs_the_preflight (self ):
955968 import zipfile
956969 client = self ._client ()
957- client .config ['batch_size ' ] = 10
970+ client .config ['queue_size ' ] = 10
958971 with tempfile .TemporaryDirectory () as d :
959972 zip_path = os .path .join (d , 'docs.zip' )
960973 with zipfile .ZipFile (zip_path , 'w' ) as z :
@@ -974,7 +987,7 @@ def fake_post(url, files=None, data=None, headers=None, timeout=None):
974987 def test_local_files_skip_the_preflight (self ):
975988 """Plain file processing does not gain a new health call."""
976989 client = self ._client ()
977- client .config ['batch_size ' ] = 10
990+ client .config ['queue_size ' ] = 10
978991 with tempfile .TemporaryDirectory () as d :
979992 with open (os .path .join (d , 'a.pdf' ), 'wb' ) as f :
980993 f .write (b'%PDF' )
@@ -994,12 +1007,12 @@ def fake_post(url, files=None, data=None, headers=None, timeout=None):
9941007class TestGlobInput :
9951008 """Tests for glob-pattern input resolution (--input as a glob)."""
9961009
997- def _client (self , batch_size = 50 ):
1010+ def _client (self , queue_size = 50 ):
9981011 with patch ('grobid_client.grobid_client.GrobidClient._test_server_connection' ):
9991012 with patch ('grobid_client.grobid_client.GrobidClient._configure_logging' ):
10001013 client = GrobidClient (check_server = False )
10011014 client .logger = Mock ()
1002- client .config ['batch_size ' ] = batch_size
1015+ client .config ['queue_size ' ] = queue_size
10031016 return client
10041017
10051018 @staticmethod
@@ -1213,7 +1226,7 @@ def _client(self):
12131226 with patch ('grobid_client.grobid_client.GrobidClient._configure_logging' ):
12141227 client = GrobidClient (check_server = False )
12151228 client .logger = Mock ()
1216- client .config ['batch_size ' ] = 50
1229+ client .config ['queue_size ' ] = 50
12171230 return client
12181231
12191232 @staticmethod
0 commit comments