Nx_io.Cache_dirSourceCache directory utilities for the Raven ecosystem.
get_root ?getenv () returns the base cache directory for Raven.
The cache directory is resolved using the following priority order: 1. RAVEN_CACHE_ROOT environment variable (highest priority; absolute cache root) 2. XDG_CACHE_HOME environment variable (if RAVEN_CACHE_ROOT not set) 3. $HOME/.cache (fallback, default behavior)
The resolved path will be RAVEN_CACHE_ROOT or "XDG_CACHE_HOME or HOME/.cache/raven".
Environment Variables
RAVEN_CACHE_ROOT: Custom cache directory root (overrides all other settings)XDG_CACHE_HOME: XDG Base Directory cache location (standard on Linux/Unix)HOME: User home directory (used for fallback cache location)val get_path_in_cache :
?getenv:(string -> string option) ->
scope:string list ->
string ->
stringget_path_in_cache ?getenv ~scope name returns the cache directory path for a specific component.
Parameters
scope: list of directory names forming the scope (e.g. ["datasets"], ["models"; "bert"])name: the specific name within that scope (e.g. "iris", "gpt2")Returns
Examples
Getting cache directory for the iris dataset:
let cache_dir = Nx_core.Cache_dir.get_path_in_cache ~scope:["datasets"] "iris" in
(* With default environment: ~/.cache/raven/datasets/iris/ *)Getting cache directory with custom root:
let getenv var =
if var = "RAVEN_CACHE_ROOT" then Some "/tmp/my-cache" else None
in
let cache_dir =
Nx_core.Cache_dir.get_path_in_cache ~getenv ~scope:["models"] "bert-base-uncased"
in
(* Result: /tmp/my-cache/models/bert-base-uncased/ *)