Spaces:
Sleeping
Sleeping
| import os | |
| import logging | |
| from huggingface_hub import hf_hub_download | |
| logger = logging.getLogger(__name__) | |
| REPO_ID = "saiteja020/EnergyStock_SAC" | |
| FILENAME = "bess_RL_master_bundle.safetensors" | |
| def sync_hub_models(local_dir: str): | |
| """ | |
| Downloads the model bundle from Hugging Face Hub if not already present. | |
| """ | |
| os.makedirs(local_dir, exist_ok=True) | |
| local_path = os.path.join(local_dir, FILENAME) | |
| if os.path.exists(local_path): | |
| logger.info(f"Model bundle '{FILENAME}' already exists at {local_dir}") | |
| return local_path | |
| logger.info(f"Attempting to download '{FILENAME}' from Hub repository '{REPO_ID}'...") | |
| try: | |
| downloaded_path = hf_hub_download( | |
| repo_id=REPO_ID, | |
| filename=FILENAME, | |
| local_dir=local_dir, | |
| local_dir_use_symlinks=False | |
| ) | |
| logger.info(f"Successfully downloaded model bundle to {downloaded_path}") | |
| return downloaded_path | |
| except Exception as e: | |
| logger.error(f"Failed to download model bundle from HF Hub: {e}") | |
| return None | |