diff --git a/cohere/compass/clients/parser.py b/cohere/compass/clients/parser.py index 2f6bcfa..adb7967 100644 --- a/cohere/compass/clients/parser.py +++ b/cohere/compass/clients/parser.py @@ -6,24 +6,25 @@ from concurrent.futures import ThreadPoolExecutor from typing import Any, Callable, Optional, Union +# 3rd party imports +import requests from requests.exceptions import InvalidSchema from tenacity import ( - RetryError, retry, retry_if_not_exception_type, stop_after_attempt, wait_fixed, ) -# 3rd party imports -import requests - # Local imports from cohere.compass import ( ProcessFileParameters, ) -from cohere.compass.constants import DEFAULT_MAX_ACCEPTED_FILE_SIZE_BYTES, DEFAULT_SLEEP_RETRY_SECONDS, \ - DEFAULT_MAX_RETRIES +from cohere.compass.constants import ( + DEFAULT_MAX_ACCEPTED_FILE_SIZE_BYTES, + DEFAULT_MAX_RETRIES, + DEFAULT_SLEEP_RETRY_SECONDS, +) from cohere.compass.models import ( CompassDocument, MetadataConfig, @@ -208,11 +209,7 @@ def _get_metadata( @retry( stop=stop_after_attempt(DEFAULT_MAX_RETRIES), wait=wait_fixed(DEFAULT_SLEEP_RETRY_SECONDS), - retry=retry_if_not_exception_type( - ( - InvalidSchema, - ) - ), + retry=retry_if_not_exception_type((InvalidSchema,)), ) def process_file( self, diff --git a/cohere/compass/utils.py b/cohere/compass/utils.py index a209fff..eee597e 100644 --- a/cohere/compass/utils.py +++ b/cohere/compass/utils.py @@ -32,7 +32,7 @@ def imap_queued( ) -> Iterator[U]: """ Similar to Python's `map`, but uses an executor to parallelize the calls. - @@ -34,20 +41,43 @@ def imap_queued( + :param f: the function to call. :param it: the iterable to map over. :param max_queued: the maximum number of futures to keep in flight.