File tree 6 files changed +50
-14
lines changed
6 files changed +50
-14
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,14 @@ locations by modifying the respective environment variables:
223
223
* `` FINAGG_DATABASE_URL `` points to the ** finagg** data storage. Defaults to
224
224
`` ./findata/finagg.sqlite `` .
225
225
226
+ ## Other
227
+
228
+ You can change some ** finagg** behavior with other environment variables:
229
+
230
+ * `` FINAGG_DISABLE_HTTP_CACHE `` : Set this to `` "1" `` or `` "True" `` to disable the
231
+ HTTP requests cache. Instead of a cachable session, a default, uncached user
232
+ session will be used for all requests.
233
+
226
234
# Dependencies
227
235
228
236
* [ pandas] [ 11 ] for fast, flexible, and expressive representations of relational data.
Original file line number Diff line number Diff line change @@ -40,5 +40,14 @@ locations by modifying the respective environment variables:
40
40
* ``FINAGG_DATABASE_URL `` points to the **finagg ** data storage. Defaults to
41
41
``./findata/finagg.sqlite ``.
42
42
43
+ Other
44
+ -----
45
+
46
+ You can change some **finagg ** behavior with other environment variables:
47
+
48
+ * ``FINAGG_DISABLE_HTTP_CACHE ``: Set this to ``"1" `` or ``"True" `` to disable the
49
+ HTTP requests cache. Instead of a cachable session, a default, uncached user
50
+ session will be used for all requests.
51
+
43
52
.. _`BEA API site` : https://apps.bea.gov/API/#/
44
53
.. _`FRED API site` : https://fredaccount.stlouisfed.org/#/secure/
Original file line number Diff line number Diff line change 26
26
:meta hide-value:
27
27
"""
28
28
29
+ disable_http_cache = os .environ .get ("FINAGG_DISABLE_HTTP_CACHE" , "false" ).lower () in {
30
+ "1" ,
31
+ "true" ,
32
+ }
33
+ """Whether the disable the HTTP requests cache. Instead of a cachable session,
34
+ a default, uncached user session will be used for all requests.
35
+
36
+ :meta hide-value:
37
+ """
38
+
29
39
http_cache_path = pathlib .Path (
30
40
os .environ .get ("FINAGG_HTTP_CACHE_PATH" , root_path / "findata" / "http_cache" )
31
41
)
Original file line number Diff line number Diff line change 51
51
)
52
52
logger = logging .getLogger (__name__ )
53
53
54
- session = requests_cache .CachedSession (
55
- str (backend .http_cache_path ),
56
- ignored_parameters = ["ResultFormat" ],
57
- expire_after = timedelta (days = 1 ),
58
- )
54
+ if backend .disable_http_cache :
55
+ session = requests .Session ()
56
+ else :
57
+ session = requests_cache .CachedSession (
58
+ str (backend .http_cache_path ),
59
+ ignored_parameters = ["ResultFormat" ],
60
+ expire_after = timedelta (days = 1 ),
61
+ )
59
62
60
63
_YEAR = int | str
61
64
Original file line number Diff line number Diff line change 12
12
13
13
from ... import backend , ratelimit
14
14
15
- session = requests_cache .CachedSession (
16
- str (backend .http_cache_path ),
17
- ignored_parameters = ["api_key" , "file_type" ],
18
- expire_after = timedelta (weeks = 1 ),
19
- )
15
+ if backend .disable_http_cache :
16
+ session = requests .Session ()
17
+ else :
18
+ session = requests_cache .CachedSession (
19
+ str (backend .http_cache_path ),
20
+ ignored_parameters = ["api_key" , "file_type" ],
21
+ expire_after = timedelta (weeks = 1 ),
22
+ )
20
23
21
24
22
25
class API (ABC ):
Original file line number Diff line number Diff line change 44
44
)
45
45
logger = logging .getLogger (__name__ )
46
46
47
- session = requests_cache .CachedSession (
48
- str (backend .http_cache_path ),
49
- expire_after = timedelta (weeks = 1 ),
50
- )
47
+ if backend .disable_http_cache :
48
+ session = requests .Session ()
49
+ else :
50
+ session = requests_cache .CachedSession (
51
+ str (backend .http_cache_path ),
52
+ expire_after = timedelta (weeks = 1 ),
53
+ )
51
54
52
55
53
56
class Concept (TypedDict ):
You can’t perform that action at this time.
0 commit comments