numerai_all_48_models / FIX_ALL_SCRIPT_PATHS.py
dirven's picture
Upload folder using huggingface_hub
5bfc765 verified
Raw History Blame Contribute Delete
3.83 kB
"""
Batch fix all 48 scripts to:
1. Skip API calls
2. Use existing round 1253 data
"""
import os
from pathlib import Path
scripts_dir = Path("c:/numerai48models/scripts")
# All script paths to fix
script_patterns = [
"main/*.py",
"main_v2/*.py",
"main_v3/*.py",
"main_nlp/*.py",
"main_ultimate/*.py",
"signals/*.py",
"signals_v2/*.py",
"signals_v3/*.py",
"signals_nlp/*.py",
"signals_ultimate/*.py",
"crypto/*.py",
"crypto_v3/*.py",
"crypto_nlp/*.py",
"3tournaments_main/*.py",
"3tournaments_signals/*.py",
"3tournaments_crypto/*.py",
"3tournaments_crypto_v2/*.py"
]
all_scripts = []
for pattern in script_patterns:
all_scripts.extend(scripts_dir.glob(pattern))
patched = 0
for script in all_scripts:
try:
with open(script, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
if 'SKIP_API' in content:
continue # Already patched
# Patch 1: Add SKIP_API check before NumerAPI
old1 = 'napi = NumerAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'
new1 = '''SKIP_API = os.getenv('SKIP_API_CALLS', 'false').lower() == 'true'
if SKIP_API:
print("[SKIP_API] Using existing data")
napi = None
current_round = 1253
else:
napi = NumerAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'''
if old1 in content:
content = content.replace(old1, new1, 1)
# Patch 2: Same for SignalsAPI
old2 = 'sapi = SignalsAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'
new2 = '''SKIP_API = os.getenv('SKIP_API_CALLS', 'false').lower() == 'true'
if SKIP_API:
print("[SKIP_API] Using existing data")
sapi = None
current_round = 1253
else:
sapi = SignalsAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'''
if old2 in content:
content = content.replace(old2, new2, 1)
# Patch 3: Same for CryptoAPI
old3 = 'capi = CryptoAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'
new3 = '''SKIP_API = os.getenv('SKIP_API_CALLS', 'false').lower() == 'true'
if SKIP_API:
print("[SKIP_API] Using existing data")
capi = None
current_round = 1253
else:
capi = CryptoAPI(public_id=NUMERAI_PUBLIC_ID, secret_key=NUMERAI_SECRET_KEY)'''
if old3 in content:
content = content.replace(old3, new3, 1)
# Patch 4: Skip get_current_round calls
content = content.replace(
'current_round = napi.get_current_round()',
'current_round = 1253 if SKIP_API else napi.get_current_round()'
)
content = content.replace(
'current_round = sapi.get_current_round()',
'current_round = 1253 if SKIP_API else sapi.get_current_round()'
)
content = content.replace(
'current_round = capi.get_current_round()',
'current_round = 1253 if SKIP_API else capi.get_current_round()'
)
# Patch 5: Skip downloads
content = content.replace(
'napi.download_dataset(',
'napi.download_dataset( if not SKIP_API else print(" [SKIP_API] Skip download") or ('
)
content = content.replace(
'sapi.download_dataset(',
'sapi.download_dataset( if not SKIP_API else print(" [SKIP_API] Skip download") or ('
)
with open(script, 'w', encoding='utf-8', errors='ignore') as f:
f.write(content)
print(f"[OK] {script.relative_to(scripts_dir)}")
patched += 1
except Exception as e:
print(f"[ERR] {script.name}: {e}")
print(f"\nPatched {patched}/{len(all_scripts)} scripts!")