diff --git a/openml/utils.py b/openml/utils.py index 7e72e7aee..156a6257f 100644 --- a/openml/utils.py +++ b/openml/utils.py @@ -427,6 +427,18 @@ def safe_func(*args: P.args, **kwargs: P.kwargs) -> R: return func +def get_cache_size() -> int: + """Calculate the size of OpenML cache directory + + Returns + ------- + cache_size: int + Total size of cache in bytes + """ + path = Path(config.get_cache_directory()) + return sum(f.stat().st_size for f in path.rglob("*") if f.is_file()) + + def _create_lockfiles_dir() -> Path: path = Path(config.get_cache_directory()) / "locks" # TODO(eddiebergman): Not sure why this is allowed to error and ignore???