-
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.
- Loading branch information
Showing
1 changed file
with
8 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import os | ||
from typing import Optional | ||
|
||
|
||
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": | ||
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: | ||
seqrepo_env_var_int = int(seqrepo_env_var) | ||
caching_env_var_int = int(caching_env_var) | ||
except ValueError: | ||
raise ValueError( | ||
f"{env_name} must be a valid int, none, or not set, " | ||
"currently it is " + seqrepo_env_var | ||
"currently it is " + caching_env_var | ||
) | ||
return seqrepo_env_var_int | ||
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 value and an explicit None (unbounded cache) | ||
# 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") |