Cache¶
Unified model cache directory management for OmniDocs.
When OMNIDOCS_MODELS_DIR is set, ALL model downloads (PyTorch, VLLM, MLX, snapshot_download) go into that directory. It overwrites HF_HOME so every backend respects the same path.
Environment Variables
OMNIDOCS_MODELS_DIR: Primary cache directory for all OmniDocs models. Overwrites HF_HOME when set. HF_HOME: HuggingFace cache directory (used as fallback).
Example
get_model_cache_dir
¶
Get unified model cache directory.
Priority order: 1. custom_dir parameter (if provided) 2. OMNIDOCS_MODELS_DIR environment variable 3. HF_HOME environment variable 4. Default: ~/.cache/huggingface
| PARAMETER | DESCRIPTION |
|---|---|
custom_dir
|
Optional custom cache directory path. Overrides environment variables if provided.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
Path object pointing to the cache directory. |
Path
|
Directory is created if it doesn't exist. |
Source code in omnidocs/utils/cache.py
configure_backend_cache
¶
Configure cache directories for all backends.
When OMNIDOCS_MODELS_DIR is set (or cache_dir is passed), this OVERWRITES HF_HOME and TRANSFORMERS_CACHE so every backend downloads to the same place.
This is called automatically on import omnidocs.
| PARAMETER | DESCRIPTION |
|---|---|
cache_dir
|
Optional cache directory path. If None, uses get_model_cache_dir().
TYPE:
|
Source code in omnidocs/utils/cache.py
get_storage_info
¶
Get current cache directory configuration information.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Dictionary with cache paths and environment variable values. |