Skip to content

Commit b2b47ba

Browse files
committed
feat(model): ✨ enable cache configuration in ValidationSettings
1 parent 36ca0ac commit b2b47ba

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

rocrate_validator/models.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
from rocrate_validator.utils import log as logging
3535
from rocrate_validator import __version__
36-
from rocrate_validator.constants import (DEFAULT_ONTOLOGY_FILE,
36+
from rocrate_validator.constants import (DEFAULT_HTTP_CACHE_MAX_AGE,
37+
DEFAULT_ONTOLOGY_FILE,
3738
DEFAULT_PROFILE_IDENTIFIER,
3839
DEFAULT_PROFILE_README_FILE,
3940
IGNORED_PROFILE_DIRECTORIES,
@@ -2388,11 +2389,21 @@ class ValidationSettings:
23882389
metadata_dict: dict = None
23892390
#: Verbose output
23902391
verbose: bool = False
2392+
#: Cache max age in seconds
2393+
cache_max_age: Optional[int] = DEFAULT_HTTP_CACHE_MAX_AGE
2394+
#: Cache path
2395+
cache_path: Optional[Path] = None
23912396

23922397
def __post_init__(self):
23932398
# if requirement_severity is a str, convert to Severity
23942399
if isinstance(self.requirement_severity, str):
23952400
self.requirement_severity = Severity[self.requirement_severity]
2401+
# initialize the HTTP cache
2402+
from rocrate_validator.utils import HttpRequester
2403+
# HttpRequester.initialize_cache(cache_path=self.cache_path, cache_max_age=self.cache_max_age)
2404+
HttpRequester.initialize_cache(cache_path=self.cache_path, cache_max_age=self.cache_max_age)
2405+
logger.debug("HTTP cache initialized at %s with max age %s seconds",
2406+
self.cache_path, self.cache_max_age)
23962407

23972408
def to_dict(self):
23982409
"""

0 commit comments

Comments
 (0)