Skip to content

Commit b4281db

Browse files
authored
Merge pull request #73 from rok4/develop
Release 2.0.1
2 parents 9b6505e + 72ab76f commit b4281db

6 files changed

Lines changed: 54 additions & 12 deletions

File tree

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 2
22
updates:
33
- package-ecosystem: pip
44
directory: "/"
5+
target-branch: develop
56
schedule:
67
interval: monthly
78
time: "17:00"
@@ -11,6 +12,7 @@ updates:
1112

1213
- package-ecosystem: "github-actions"
1314
directory: "/"
15+
target-branch: develop
1416
schedule:
1517
interval: monthly
1618
time: "22:00"

.github/workflows/build-and-release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
job_status: ${{ job.status }}
1717
steps:
1818
- name: Checkout project
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Create Release
2222
id: create_release
@@ -49,7 +49,7 @@ jobs:
4949

5050
steps:
5151
- name: Checkout project
52-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
5353

5454
- name: Setup python
5555
uses: actions/setup-python@v4
@@ -164,7 +164,7 @@ jobs:
164164
steps:
165165

166166
- name: Checkout project on gh-pages
167-
uses: actions/checkout@v3
167+
uses: actions/checkout@v4
168168
with:
169169
ref: 'gh-pages'
170170
token: ${{ secrets.GITHUB_TOKEN }}
@@ -213,7 +213,7 @@ jobs:
213213

214214
steps:
215215
- name: Remove release and tag
216-
uses: dev-drprasad/delete-tag-and-release@v0.2.0
216+
uses: dev-drprasad/delete-tag-and-release@v1.0.1
217217
with:
218218
tag_name: ${{ github.ref_name }}
219219
delete_release: true

.github/workflows/build-docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout project
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
with:
1818
ref: 'gh-pages'
1919
token: ${{ secrets.GITHUB_TOKEN }}
@@ -64,4 +64,4 @@ jobs:
6464
steps:
6565
- name: Deploy to GitHub Pages
6666
id: deployment
67-
uses: actions/deploy-pages@v1
67+
uses: actions/deploy-pages@v2

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ repos:
2222
args: [--markdown-linebreak-ext=md]
2323

2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: "v0.0.281"
25+
rev: "v0.0.291"
2626
hooks:
2727
- id: ruff
2828
args: ["--fix-only", "--target-version=py38"]
2929

3030
- repo: https://github.com/psf/black
31-
rev: 23.3.0
31+
rev: 23.9.1
3232
hooks:
3333
- id: black
3434
args: ["--target-version=py38"]
@@ -40,7 +40,7 @@ repos:
4040
args: ["--profile", "black", "--filter-files"]
4141

4242
- repo: https://github.com/asottile/pyupgrade
43-
rev: v3.3.1
43+
rev: v3.13.0
4444
hooks:
4545
- id: pyupgrade
4646
args:

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 2.0.1
2+
3+
### [Added]
4+
5+
* `storage` : le cache de lecture est configurable en taille (avec ROK4_READING_LRU_CACHE_SIZE) et en temps de rétention (avec ROK4_READING_LRU_CACHE_TTL)
6+
7+
### [Security]
8+
9+
* Montée de version de pillow (faille de sécurité liée à libwebp)
10+
111
## 2.0.0
212

313
### [Fixed]

src/rok4/storage.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
1010
According to functions, all storage types are not necessarily available.
1111
12+
Readings uses a LRU cache system with a TTL. It's possible to configure it with environment variables :
13+
- ROK4_READING_LRU_CACHE_SIZE : Number of cached element. Default 64. Set 0 or a negative integer to configure a cache without bound. A power of two make cache more efficient.
14+
- ROK4_READING_LRU_CACHE_TTL : Validity duration of cached element, in seconds. Default 300. 0 or negative integer to disable time validity.
15+
16+
To disable cache, set ROK4_READING_LRU_CACHE_SIZE to 1 and ROK4_READING_LRU_CACHE_TTL to 0.
17+
1218
Using CEPH storage requires environment variables :
1319
- ROK4_CEPH_CONFFILE
1420
- ROK4_CEPH_USERNAME
@@ -69,10 +75,34 @@
6975
__S3_CLIENTS = {}
7076
__S3_DEFAULT_CLIENT = None
7177

78+
__LRU_SIZE = 64
79+
__LRU_TTL = 300
80+
81+
try:
82+
__LRU_SIZE = int(os.environ["ROK4_READING_LRU_CACHE_SIZE"])
83+
if __LRU_SIZE < 1:
84+
__LRU_SIZE = None
85+
except ValueError:
86+
pass
87+
except KeyError:
88+
pass
89+
90+
try:
91+
__LRU_TTL = int(os.environ["ROK4_READING_LRU_CACHE_TTL"])
92+
if __LRU_TTL < 0:
93+
__LRU_TTL = 0
94+
except ValueError:
95+
pass
96+
except KeyError:
97+
pass
98+
7299

73100
def __get_ttl_hash():
74-
"""Return the same value withing 5 minutes time period"""
75-
return round(time.time() / 300)
101+
"""Return the time string rounded according to time-to-live value"""
102+
if __LRU_TTL == 0:
103+
return time.time()
104+
else:
105+
return round(time.time() / __LRU_TTL)
76106

77107

78108
def __get_s3_client(bucket_name: str) -> Tuple[Dict[str, Union["boto3.client", str]], str, str]:
@@ -294,7 +324,7 @@ def get_data_str(path: str) -> str:
294324
return get_data_binary(path).decode("utf-8")
295325

296326

297-
@lru_cache(maxsize=50)
327+
@lru_cache(maxsize=__LRU_SIZE)
298328
def __get_cached_data_binary(path: str, ttl_hash: int, range: Tuple[int, int] = None) -> str:
299329
"""Load data into a binary string, using a LRU cache
300330

0 commit comments

Comments
 (0)