| #!/usr/bin/env python3 | |
| """ | |
| Training wrapper with checkpoint support and better logging | |
| """ | |
| import sys | |
| import os | |
| import shutil | |
| from pathlib import Path | |
| # Clear cache before training | |
| print("🧹 Clearing HuggingFace cache...") | |
| cache_dir = Path("/workspace/.hf_home/hub/models--mistralai--Mistral-7B-v0.1") | |
| if cache_dir.exists(): | |
| try: | |
| shutil.rmtree(cache_dir) | |
| print("✓ Cache cleared") | |
| except Exception as e: | |
| print(f"⚠️ Cache clear warning: {e}") | |
| # Force unbuffered output for real-time logs | |
| sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1) | |
| sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', buffering=1) | |
| print("=" * 70) | |
| print("🚀 Starting Training with Real-time Logging") | |
| print("=" * 70) | |
| sys.stdout.flush() | |
| # Import and run training | |
| sys.path.insert(0, "/workspace/ftt/ft/models/msp") | |
| from ft.finetune_mistral7b import main | |
| if __name__ == "__main__": | |
| main() | |