@@ -659,7 +659,7 @@ def _query_resource(
659659 use_document_model: if None, will defer to the self.use_document_model attribute
660660 num_chunks: Maximum number of chunks of data to yield. None will yield all possible.
661661 chunk_size: Number of data entries per chunk.
662- timeout : Time in seconds to wait until a request timeout error is thrown
662+ timeout (float or None) : Time in seconds to wait until a request timeout error is thrown
663663
664664 Returns:
665665 A Resource, a dict with two keys, "data" containing a list of documents, and
@@ -810,9 +810,9 @@ def _submit_requests(
810810 url : str ,
811811 criteria : dict [str , Any ],
812812 use_document_model : bool ,
813- chunk_size : int ,
813+ chunk_size : int | None ,
814814 num_chunks : int | None = None ,
815- timeout : float | None = None ,
815+ timeout : int | None = None ,
816816 max_batch_size : int = 100 ,
817817 norecur : bool = False ,
818818 ) -> dict :
@@ -826,8 +826,8 @@ def _submit_requests(
826826 criteria (dict of str): dictionary of criteria to filter down
827827 use_document_model (bool): whether to use the document model
828828 num_chunks (int or None): Maximum number of chunks of data to yield. None will yield all possible.
829- chunk_size (int): Number of data entries per chunk.
830- timeout (float ): Time in seconds to wait until a request timeout error is thrown
829+ chunk_size (int or None ): Number of data entries per chunk.
830+ timeout (int or None ): Time in seconds to wait until a request timeout error is thrown
831831 max_batch_size (int) : Maximum size of a batch when retrieving batches in parallel
832832 norecur (bool) : Whether to forbid recursive splitting of a query field
833833 when a direct query fails
@@ -985,6 +985,12 @@ def _submit_requests(
985985 if "meta" in data :
986986 total_data ["meta" ] = data ["meta" ]
987987
988+ # otherwise, paginate sequentially
989+ if chunk_size is None or chunk_size < 1 :
990+ raise ValueError (
991+ "A positive chunk size must be provided to enable pagination"
992+ )
993+
988994 # Get max number of response pages
989995 max_pages = (
990996 num_chunks if num_chunks is not None else ceil (total_num_docs / chunk_size )
@@ -1024,10 +1030,6 @@ def _submit_requests(
10241030 pbar .close ()
10251031 return new_total_data
10261032
1027- # otherwise, paginate sequentially
1028- if chunk_size is None :
1029- raise ValueError ("A chunk size must be provided to enable pagination" )
1030-
10311033 # Warning to select specific fields only for many results
10321034 if criteria .get ("_all_fields" , False ) and (total_num_docs / chunk_size > 10 ):
10331035 warnings .warn (
0 commit comments