11import warnings
22from datetime import date
3- from typing import Any , List , Optional , Tuple , Union
3+ from typing import List , Optional , Tuple , Union
44
55import pandas as pd
66from databento .common .bento import Bento
77from databento .common .enums import Compression , Dataset , Encoding , Schema , SType
8- from databento .common .logging import log_debug
98from databento .common .validation import validate_enum
109from databento .historical .api import API_VERSION
1110from databento .historical .http import BentoHttpAPI
12- from requests import Response
13-
14-
15- _5GB = 1024 ** 3 * 5
1611
1712
1813class TimeSeriesHttpAPI (BentoHttpAPI ):
@@ -107,7 +102,6 @@ def stream(
107102 start = start ,
108103 end = end ,
109104 limit = limit ,
110- params = params ,
111105 )
112106
113107 bento : Bento = self ._create_bento (path = path )
@@ -204,7 +198,6 @@ async def stream_async(
204198 start = start ,
205199 end = end ,
206200 limit = limit ,
207- params = params ,
208201 )
209202
210203 bento : Bento = self ._create_bento (path = path )
@@ -225,44 +218,26 @@ def _pre_check_data_size(
225218 start : Optional [Union [pd .Timestamp , date , str , int ]],
226219 end : Optional [Union [pd .Timestamp , date , str , int ]],
227220 limit : Optional [int ],
228- params : List [Tuple [str , Any ]],
229221 ):
230222 if limit and limit < 10 ** 7 :
231223 return
232224
225+ # Use heuristics to check ballpark data size
233226 if (
234227 _is_large_data_size_schema (schema )
235228 or _is_greater_than_one_day (start , end )
236229 or _is_large_number_of_symbols (symbols )
237230 ):
238- params = params [:] # copy
239- params .append (("mode" , "historical-streaming" ))
240- params .append (("instruments" , str (len (symbols ))))
241- log_debug (
242- "Checking estimated data size for potentially large streaming "
243- "request..." ,
244- )
245- response : Response = self ._get (
246- url = self ._gateway + f"/v{ API_VERSION } /metadata.get_size_estimation" ,
247- params = params ,
248- basic_auth = True ,
249- )
250-
251- size : int = response .json ()["size" ]
252- log_debug (
253- f"Requesting data stream for { size :,} bytes (binary uncompressed)..." ,
231+ warnings .warn (
232+ "\n The size of the current streaming request is estimated "
233+ "to be 5 GB or greater. We recommend smaller "
234+ "individual streaming request sizes, or alternatively "
235+ "submit a batch data request."
236+ "\n You can check the uncompressed binary size of a request "
237+ "through the metadata API (from the client library, or over "
238+ "HTTP).\n This warning can be suppressed "
239+ "https://docs.python.org/3/library/warnings.html" ,
254240 )
255- if size > _5GB :
256- warnings .warn (
257- f"\n The size of the current streaming request is estimated "
258- f"to exceed 5GB ({ _5GB :,} bytes). We recommend smaller "
259- f"individual streaming request sizes, or alternatively "
260- f"submit a batch data request."
261- f"\n You can check the uncompressed binary size of a request "
262- f"through the metadata API (from the client library, or over "
263- f"HTTP).\n This warning can be suppressed "
264- f"https://docs.python.org/3/library/warnings.html" ,
265- )
266241
267242
268243def _is_large_number_of_symbols (symbols : Optional [Union [List [str ], str ]]):
0 commit comments