-
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): Cleans up logic around env var parsing and changes env var…
… name
- Loading branch information
Showing
6 changed files
with
25 additions
and
76 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,15 +1,21 @@ | ||
import os | ||
|
||
SEQREPO_FD_CACHE_SIZE_ENV_NAME = "SEQREPO_FD_CACHE_SIZE" | ||
|
||
try: | ||
seqrepo_env_var = os.environ.get("SEQREPO_LRU_CACHE_MAXSIZE", "1000000") | ||
SEQREPO_LRU_CACHE_MAXSIZE = int(seqrepo_env_var) | ||
except ValueError: | ||
def parse_caching_env_var(env_name, env_default): | ||
seqrepo_env_var = os.environ.get(env_name, env_default) | ||
if seqrepo_env_var.lower() == "none": | ||
SEQREPO_LRU_CACHE_MAXSIZE = None | ||
else: | ||
return None | ||
|
||
try: | ||
seqrepo_env_var_int = int(seqrepo_env_var) | ||
except ValueError: | ||
raise ValueError( | ||
"SEQREPO_LRU_CACHE_MAXSIZE must be a valid int, none, or not set, " | ||
f"{env_name} must be a valid int, none, or not set, " | ||
"currently it is " + seqrepo_env_var | ||
) | ||
return seqrepo_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 value 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
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