@@ -189,6 +189,8 @@ class SupersetConfig(
189
189
provider : str = Field (default = "db" , description = "Superset provider." )
190
190
options : Dict = Field (default = {}, description = "" )
191
191
192
+ timeout : int = Field (default = 10 , description = "Timeout of single API call to superset." )
193
+
192
194
# TODO: Check and remove this if no longer needed.
193
195
# Config database_alias is removed from sql sources.
194
196
database_alias : Dict [str , str ] = Field (
@@ -293,13 +295,14 @@ def login(self) -> requests.Session:
293
295
}
294
296
)
295
297
296
- # Test the connection
297
298
test_response = requests_session .get (
298
- f"{ self .config .connect_uri } /api/v1/dashboard/"
299
+ f"{ self .config .connect_uri } /api/v1/dashboard/" ,
300
+ timeout = self .config .timeout ,
299
301
)
300
302
if test_response .status_code == 200 :
301
- pass
302
- # TODO(Gabe): how should we message about this error?
303
+ # throw an error and terminate ingestion,
304
+ # cannot proceed without access token
305
+ logger .error (f"Failed to log in to Superset with status: { test_response .status_code } " )
303
306
return requests_session
304
307
305
308
def paginate_entity_api_results (self , entity_type , page_size = 100 ):
@@ -310,6 +313,7 @@ def paginate_entity_api_results(self, entity_type, page_size=100):
310
313
response = self .session .get (
311
314
f"{ self .config .connect_uri } /api/v1/{ entity_type } " ,
312
315
params = {"q" : f"(page:{ current_page } ,page_size:{ page_size } )" },
316
+ timeout = self .config .timeout ,
313
317
)
314
318
315
319
if response .status_code != 200 :
@@ -347,6 +351,7 @@ def build_owner_urn(self, data: Dict[str, Any]) -> List[str]:
347
351
def get_dataset_info (self , dataset_id : int ) -> dict :
348
352
dataset_response = self .session .get (
349
353
f"{ self .config .connect_uri } /api/v1/dataset/{ dataset_id } " ,
354
+ timeout = self .config .timeout ,
350
355
)
351
356
if dataset_response .status_code != 200 :
352
357
logger .warning (f"Failed to get dataset info: { dataset_response .text } " )
0 commit comments