Skip to content

Commit 3ecd4a6

Browse files
recursive guard
1 parent 90f9456 commit 3ecd4a6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

mp_api/client/core/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ def _submit_requests(
814814
num_chunks: int | None = None,
815815
timeout: float | None = None,
816816
max_batch_size: int = 100,
817+
norecur: bool = False,
817818
) -> dict:
818819
"""Handle submitting requests sequentially with pagination.
819820
@@ -827,7 +828,9 @@ def _submit_requests(
827828
num_chunks (int or None): Maximum number of chunks of data to yield. None will yield all possible.
828829
chunk_size (int): Number of data entries per chunk.
829830
timeout (float): Time in seconds to wait until a request timeout error is thrown
830-
max_batch_size (int) : Maximum size of a batch for when retrieving batches in parallel
831+
max_batch_size (int) : Maximum size of a batch when retrieving batches in parallel
832+
norecur (bool) : Whether to forbid recursive splitting of a query field
833+
when a direct query fails
831834
832835
Returns:
833836
Dictionary containing data and metadata
@@ -897,8 +900,8 @@ def _submit_requests(
897900
# Continue with pagination if needed (handled below)
898901

899902
except MPRestError as e:
900-
# If we get 422 or 414 error, or 0 results for comma-separated params, split into batches
901-
if any(
903+
# If we get 422 or 414 error, split into batches
904+
if not norecur and any(
902905
trace in str(e)
903906
for trace in (
904907
"422",
@@ -940,6 +943,7 @@ def _submit_requests(
940943
chunk_size=chunk_size,
941944
num_chunks=num_chunks,
942945
timeout=timeout,
946+
norecur=len(batch) <= max_batch_size,
943947
)
944948

945949
data_chunks.append(result["data"])

0 commit comments

Comments
 (0)