-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(130): Introduces SEQREPO_FD_CACHE_MAXSIZE env var (#131)
* feat(130): Introduce SEQREPO_FD_CACHE_SIZE env var to override the internal fd_cache_size to allow for increased performance with forcing code changes to any SeqRepo clients. * feat(130): Cleans up logic around env var parsing and changes env var name * feat(130): Type hinting and cleanup
- Loading branch information
Showing
5 changed files
with
38 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import os | ||
from typing import Optional | ||
|
||
try: | ||
seqrepo_env_var = os.environ.get("SEQREPO_LRU_CACHE_MAXSIZE", "1000000") | ||
SEQREPO_LRU_CACHE_MAXSIZE = int(seqrepo_env_var) | ||
except ValueError: | ||
if seqrepo_env_var.lower() == "none": | ||
SEQREPO_LRU_CACHE_MAXSIZE = None | ||
else: | ||
|
||
def parse_caching_env_var(env_name: str, env_default: str) -> Optional[int]: | ||
caching_env_var = os.environ.get(env_name, env_default) | ||
if caching_env_var.lower() == "none": | ||
return None | ||
|
||
try: | ||
caching_env_var_int = int(caching_env_var) | ||
except ValueError: | ||
raise ValueError( | ||
"SEQREPO_LRU_CACHE_MAXSIZE must be a valid int, none, or not set, " | ||
"currently it is " + seqrepo_env_var | ||
f"{env_name} must be a valid int, none, or not set, " | ||
"currently it is " + caching_env_var | ||
) | ||
return caching_env_var_int | ||
|
||
|
||
SEQREPO_LRU_CACHE_MAXSIZE = parse_caching_env_var("SEQREPO_LRU_CACHE_MAXSIZE", "1000000") | ||
# Using a default value here of -1 to differentiate not setting this env var and an explicit None (unbounded cache) | ||
SEQREPO_FD_CACHE_MAXSIZE = parse_caching_env_var("SEQREPO_FD_CACHE_MAXSIZE", "-1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters