@@ -456,3 +456,43 @@ def check_required_fields(params: dict[str, Any]) -> dict[str, Any]:
456456 f"{ arg } is required, please set it in the command arguments or environment variables"
457457 )
458458 return env_overrides
459+
460+
461+ def check_and_warn_hf_cache (
462+ model_weights_exists : bool ,
463+ model_weights_path : str ,
464+ env_dict : dict [str , str ],
465+ model_name : str | None = None ,
466+ ) -> None :
467+ """Warn if model weights don't exist and HuggingFace cache directory is not set.
468+
469+ Parameters
470+ ----------
471+ model_weights_exists : bool
472+ Whether the model weights exist at the expected path.
473+ model_weights_path : str
474+ The expected path to the model weights.
475+ env_dict : dict[str, str]
476+ Dictionary of environment variables to check (from --env parameter).
477+ model_name : str | None, optional
478+ Optional model name to include in the warning message (for batch mode).
479+ """
480+ if model_weights_exists :
481+ return
482+
483+ hf_cache_vars = ["HF_HOME" , "HF_HUB_CACHE" , "HUGGINGFACE_HUB_CACHE" ]
484+ hf_cache_set = any (
485+ os .environ .get (var ) or env_dict .get (var ) for var in hf_cache_vars
486+ )
487+
488+ if not hf_cache_set :
489+ model_prefix = f"Model weights for '{ model_name } ' " if model_name else "Model weights "
490+ warnings .warn (
491+ f"{ model_prefix } not found at '{ model_weights_path } ' and no "
492+ f"HuggingFace cache directory is set (HF_HOME, HF_HUB_CACHE, or "
493+ f"HUGGINGFACE_HUB_CACHE). The model may be downloaded to your home "
494+ f"directory, which could consume your storage quota. Consider setting "
495+ f"one of these environment variables to a shared cache location." ,
496+ UserWarning ,
497+ stacklevel = 4 ,
498+ )
0 commit comments