numerai_all_48_models / UPDATE_ALL_SCRIPT_PATHS.py
dirven's picture
Upload folder using huggingface_hub
5bfc765 verified
Raw History Blame Contribute Delete
2.21 kB
"""
Update all scripts to use c:\numerai48models as base path in testing mode
"""
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
# Replace backup detection with simpler Windows check
if 'BACKUP_DIR = Path("C:/NUMERAI_BACKUP_20260410")' in content:
old_config = '''# Auto-detect if running from backup folder
BACKUP_DIR = Path("C:/NUMERAI_BACKUP_20260410")
if Path.cwd().resolve().is_relative_to(BACKUP_DIR.resolve()) or BACKUP_DIR in Path(__file__).resolve().parents:
print("[BACKUP MODE] Running from backup - Using backup paths")
BASE_DIR = BACKUP_DIR'''
new_config = '''# Auto-detect testing mode
TESTING_MODE = os.getenv('TESTING_MODE', 'true').lower() == 'true'
if TESTING_MODE or os.name == 'nt': # Windows or TESTING_MODE set
print("[TESTING MODE] Using local paths")
BASE_DIR = Path("c:/numerai48models")'''
if old_config in content:
content = content.replace(old_config, new_config)
modified = True
# Replace production paths check
if 'print("[PRODUCTION] Production mode - Using production paths")' in content:
old_prod = '''else:
print("[PRODUCTION] Production mode - Using production paths")
BASE_DIR = Path("/app")'''
new_prod = '''else:
print("[PRODUCTION] Production mode - Using production paths")
BASE_DIR = Path("/app")'''
if old_prod in content:
content = content.replace(old_prod, new_prod)
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!")