@@ -116,30 +116,32 @@ def __init__(self, config_file: Path, provider: str): # type: ignore
116116
117117 def _specific_search (self , ** kwargs ) -> Union [SearchResult , List ]:
118118 """
119- Conducts a search for products within a specified time range .
119+ Conducts a search for products using the specified OData arguments .
120120
121- This private method interfaces with the client's search functionality,
122- retrieving products that fall within the given time range. The 'between'
123- parameter is expected to be a TimeRange object, encompassing start and end
124- timestamps. The method returns a dictionary of products keyed by their
125- respective identifiers.
121+ This private method interfaces with the EODAG client's search functionality
122+ to retrieve products that match the given search parameters. It handles
123+ special cases such as `PublicationDate` and session ID lists while enforcing
124+ pagination constraints as per provider limitations.
126125
127126 Args:
128- date_time: An object representing search datetime, can be fixed or open/closed interval.
127+ **kwargs: Arbitrary keyword arguments specifying search parameters,
128+ including all queryables defined in the provider's configuration as OData arguments.
129129
130130 Returns:
131- SearchResult: A dictionary where keys are product identifiers and
132- values are EOProduct instances.
133-
134- Note:
135- The time format of the 'between' parameter should be verified or formatted
136- appropriately before invoking this method. The method also assumes that the
137- client's search function is correctly set up to handle the provided time
138- range format.
131+ Union[SearchResult, List]: A `SearchResult` object containing the matched products
132+ or an empty list if no matches are found.
139133
140134 Raises:
141- Exception: If the search encounters an error or fails, an exception is raised.
135+ HTTPException: If a validation error occurs in the search query.
136+ SearchProductFailed: If the search request fails due to request errors,
137+ misconfiguration, or authentication issues.
138+ ValueError: If authentication with EODAG fails.
139+
140+ Notes:
141+ - Ensures compliance with provider-specific constraints, such as pagination limits.
142+ - Logs encountered errors and provides detailed messages in case of failures.
142143 """
144+
143145 mapped_search_args : Dict [str , Union [str , None ]] = {}
144146 if session_id := kwargs .pop ("SessionId" , None ):
145147 # Map session_id to the appropriate eodag parameter
@@ -157,11 +159,6 @@ def _specific_search(self, **kwargs) -> Union[SearchResult, List]:
157159 value = ", " .join (f"'{ p } '" for p in platform ) if isinstance (platform , list ) else f"'{ platform } '"
158160 mapped_search_args [key ] = value
159161
160- # TODO: check if it is the right way of doing this, looks very cumbersome to do it for every field
161- # Tempfix, will be updated, to dirrectly, to verify kwargs and then forward to search.
162- if retransfer := kwargs .pop ("retransfer" , None ):
163- mapped_search_args ["Retransfer" ] = str (retransfer ).lower ()
164-
165162 if date_time := kwargs .pop ("PublicationDate" , False ):
166163 # Since now both for files and sessions, time interval is optional, map it if provided.
167164 fixed , start , end = [str (date ) if date else None for date in date_time ]
@@ -172,6 +169,14 @@ def _specific_search(self, **kwargs) -> Union[SearchResult, List]:
172169 "StopPublicationDate" : end ,
173170 },
174171 )
172+ max_items_allowed = int (self .client .providers_config [self .provider ].search .pagination ["max_items_per_page" ])
173+ if int (kwargs ["items_per_page" ]) > max_items_allowed :
174+ logger .warning (
175+ f"Requesting { kwargs ['items_per_page' ]} exceeds maximum of { max_items_allowed } "
176+ "allowed for this provider!" ,
177+ )
178+ logger .warning (f"Number of items per page was set to { max_items_allowed - 1 } ." )
179+ kwargs ["items_per_page" ] = max_items_allowed - 1
175180 try :
176181 logger .info (f"Searching from { self .provider } with parameters { mapped_search_args } " )
177182 # Start search -> user defined search params in mapped_search_args (id), pagination in kwargs (top, limit).
0 commit comments