numerai_all_48_models / UPDATE_ALL_DOWNLOADS.py
dirven's picture
Upload folder using huggingface_hub
5bfc765 verified
Raw History Blame Contribute Delete
2.98 kB
"""
Fix all scripts to check for existing round data before downloading
"""
import os
from pathlib import Path
scripts_dir = Path("c:/numerai48models/scripts")
all_scripts = list(scripts_dir.rglob("*.py"))
fixed = 0
for script in all_scripts:
try:
with open(script, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
modified = False
# Pattern 1: Remove file deletion before download
old_delete = """# Check if file exists and is valid
if live_path.exists():
print(f" [FOUND] Using existing round {current_round} data: {live_path.name}")
# No need to download again
skip_wait.set() # Skip download loop"""
new_check = """# Check if we already have this round's data
if live_path.exists():
try:
# Verify it's the right round
temp_df = pd.read_parquet(live_path)
if 'era' in temp_df.columns:
data_round = int(str(temp_df['era'].iloc[0]).replace('era', ''))
if data_round == current_round:
print(f" [EXISTS] Round {current_round} data found - using existing file")
break # Skip download loop
print(f" [INFO] Existing file is for different round - will re-download")
except Exception as e:
print(f" [WARNING] Could not verify existing file: {e}")"""
if old_delete in content:
content = content.replace(old_delete, new_check)
modified = True
# Pattern 2: Also look for simpler patterns that just delete
if '[CLEAN] Deleting existing file' in content:
# Remove the deletion code
lines = content.split('\n')
new_lines = []
skip_next = 0
for i, line in enumerate(lines):
if skip_next > 0:
skip_next -= 1
continue
if '[CLEAN] Deleting existing file' in line:
# Skip this and the next 1-2 lines (the unlink)
if i + 1 < len(lines) and 'unlink()' in lines[i + 1]:
skip_next = 1
continue
new_lines.append(line)
if len(new_lines) != len(lines):
content = '\n'.join(new_lines)
modified = True
if modified:
with open(script, 'w', encoding='utf-8', errors='ignore') as f:
f.write(content)
print(f"[OK] {script.relative_to(scripts_dir)}")
fixed += 1
except Exception as e:
print(f"[ERR] {script.name}: {e}")
print(f"\nFixed {fixed} scripts!")
print("\nNow scripts will:")
print(" 1. Check if round data file exists")
print(" 2. Verify it matches current round number")
print(" 3. Use existing file if valid")
print(" 4. Only download if file missing or wrong round")