| |
| """Quick smoke test: build_data + train_ranker with 100k sample to verify bugfix.""" |
| import os, sys, warnings, subprocess |
| warnings.filterwarnings("ignore") |
| sys.path.insert(0, "/tmp") |
| from huggingface_hub import HfApi, hf_hub_download |
|
|
| DS = "cedwyh/jinjing-shared-data" |
| hf_token = os.environ.get("HF_TOKEN") |
|
|
| |
| bd = hf_hub_download(DS, "build_data.py", repo_type="dataset") |
| tr = hf_hub_download(DS, "scripts/train_ranker.py", repo_type="dataset") |
|
|
| |
| print("=" * 60) |
| print("SMOKE TEST: build_data (100k sample)") |
| print("=" * 60) |
| r1 = subprocess.run( |
| [sys.executable, bd, "--output", "/tmp/ranking_smoke.parquet", |
| "--dataset", DS, "--no-use-priors", "--sample", "100000"], |
| capture_output=True, text=True, timeout=300 |
| ) |
| print(r1.stdout) |
| if r1.returncode != 0: |
| print(f"❌ FAILED: {r1.stderr[-500:]}") |
| sys.exit(1) |
|
|
| |
| import pandas as pd |
| df = pd.read_parquet("/tmp/ranking_smoke.parquet") |
| print(f"\n✅ Build data: {len(df):,} rows x {len(df.columns)} cols") |
| v5 = [c for c in ['buy_decay','sell_decay','zs_pos','zs_width','zs_time', |
| 'momentum_div','volume_div','slope','trend_consistency', |
| 'regime_prob','leg_progress','structure_progress'] if c in df.columns] |
| print(f"V5 features present: {len(v5)}/12") |
| ret = [c for c in ['ret_1d','ret_5d','ret_10d','ret_20d','ret_30d','ret_60d'] if c in df.columns] |
| print(f"ret features present: {len(ret)}/6") |
| zs = [c for c in ['zs_pos','zs_width','zs_time'] if c in df.columns] |
| print(f"zs features present: {len(zs)}/3") |
| print(f"Total columns: {len(df.columns)}") |
| print(f"Features: {[c for c in df.columns if c not in ['date','symbol','query_group','label_rank']]}") |
| del df |
|
|
| |
| with open(tr) as f: |
| content = f.read() |
| assert 'zs_width' not in content or 'zs_width' in content and 'Dead' not in content, "train_ranker still excludes zs!" |
| assert 'ret_1d' not in content or 'ret_1d' in content and 'Forward' not in content, "train_ranker still excludes ret!" |
| print("\n✅ train_ranker.py NON_FEATURE_COLS fix verified") |
|
|
| |
| tr_patched = "/tmp/tr_smoke.py" |
| with open(tr) as f: |
| c = f.read() |
| c = c.replace('TARGET_COL = "label"', 'TARGET_COL = "label_rank"') |
| with open(tr_patched, "w") as f: |
| f.write(c) |
|
|
| print("\n" + "=" * 60) |
| print("SMOKE TEST: train_ranker (100k sample, 1 window)") |
| print("=" * 60) |
| r2 = subprocess.run( |
| [sys.executable, tr_patched, "--data", "/tmp/ranking_smoke.parquet", |
| "--output", "/tmp/smoke_ranker"], |
| capture_output=True, text=True, timeout=300 |
| ) |
| print(r2.stdout[-1000:]) |
| if r2.returncode != 0: |
| print(f"❌ FAILED: {r2.stderr[-500:]}") |
| sys.exit(1) |
|
|
| print("\n" + "=" * 60) |
| print("✅ SMOKE TEST PASSED — All bugfixes verified") |
| print("=" * 60) |
|
|