1616from requests import Response
1717
1818from openml .__version__ import __version__
19- from openml ._api . config import RetryPolicy
19+ from openml .enums import RetryPolicy
2020from openml .exceptions import (
2121 OpenMLNotAuthorizedError ,
2222 OpenMLServerError ,
@@ -116,15 +116,15 @@ def __init__( # noqa: PLR0913
116116 server : str ,
117117 base_url : str ,
118118 api_key : str ,
119- timeout : int ,
119+ timeout_seconds : int ,
120120 retries : int ,
121121 retry_policy : RetryPolicy ,
122122 cache : HTTPCache | None = None ,
123123 ) -> None :
124124 self .server = server
125125 self .base_url = base_url
126126 self .api_key = api_key
127- self .timeout = timeout
127+ self .timeout_seconds = timeout_seconds
128128 self .retries = retries
129129 self .retry_policy = retry_policy
130130 self .cache = cache
@@ -322,6 +322,7 @@ def request(
322322 path : str ,
323323 * ,
324324 use_cache : bool = False ,
325+ reset_cache : bool = False ,
325326 use_api_key : bool = False ,
326327 ** request_kwargs : Any ,
327328 ) -> Response :
@@ -342,10 +343,10 @@ def request(
342343 headers = request_kwargs .pop ("headers" , {}).copy ()
343344 headers .update (self .headers )
344345
345- timeout = request_kwargs .pop ("timeout" , self .timeout )
346+ timeout = request_kwargs .pop ("timeout" , self .timeout_seconds )
346347 files = request_kwargs .pop ("files" , None )
347348
348- if use_cache and self .cache is not None :
349+ if use_cache and not reset_cache and self .cache is not None :
349350 cache_key = self .cache .get_key (url , params )
350351 try :
351352 return self .cache .load (cache_key )
@@ -379,6 +380,7 @@ def request(
379380 assert response is not None
380381
381382 if use_cache and self .cache is not None :
383+ cache_key = self .cache .get_key (url , params )
382384 self .cache .save (cache_key , response )
383385
384386 return response
@@ -388,13 +390,15 @@ def get(
388390 path : str ,
389391 * ,
390392 use_cache : bool = False ,
393+ reset_cache : bool = False ,
391394 use_api_key : bool = False ,
392395 ** request_kwargs : Any ,
393396 ) -> Response :
394397 return self .request (
395398 method = "GET" ,
396399 path = path ,
397400 use_cache = use_cache ,
401+ reset_cache = reset_cache ,
398402 use_api_key = use_api_key ,
399403 ** request_kwargs ,
400404 )
0 commit comments