Fix submission.py: per-onnx-file size check, not zip; remove excluded task skip"
Browse files- neurogolf_solver/submission.py +26 -10
neurogolf_solver/submission.py
CHANGED
|
@@ -8,7 +8,7 @@ import math
|
|
| 8 |
import zipfile
|
| 9 |
from collections import Counter
|
| 10 |
from .profiler import score_network
|
| 11 |
-
from .constants import
|
| 12 |
|
| 13 |
try:
|
| 14 |
import wandb
|
|
@@ -30,9 +30,6 @@ def run_tasks(task_nums, tasks, output_dir, providers, conv_budget, excluded_tas
|
|
| 30 |
for tn in task_nums:
|
| 31 |
if tn not in tasks:
|
| 32 |
continue
|
| 33 |
-
if tn in excluded_tasks:
|
| 34 |
-
print(f"Task {tn:3d}: EXCLUDED (officially)")
|
| 35 |
-
continue
|
| 36 |
|
| 37 |
td = tasks[tn]['data']
|
| 38 |
ok, sname, sz, t_task, model_path = solve_task(
|
|
@@ -47,6 +44,11 @@ def run_tasks(task_nums, tasks, output_dir, providers, conv_budget, excluded_tas
|
|
| 47 |
score = max(1.0, 25.0 - math.log(max(1, cost)))
|
| 48 |
total_score += score
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
results[tn] = (sname, t_task, sz)
|
| 51 |
costs_dict[tn] = cost
|
| 52 |
print(f"Task {tn:3d}: {sname:25s} {score:7.3f} {cost:>12} {t_task:7.3f}s ({sz:>8,} bytes)")
|
|
@@ -77,6 +79,14 @@ def generate_submission(output_dir, results, costs_dict, active_tasks):
|
|
| 77 |
total_size = sum(os.path.getsize(os.path.join(output_dir, f))
|
| 78 |
for f in os.listdir(output_dir) if f.endswith('.onnx'))
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
# Create submission.zip
|
| 81 |
parent_dir = os.path.dirname(output_dir) or '/kaggle/working/'
|
| 82 |
zip_path = os.path.join(parent_dir, 'submission.zip')
|
|
@@ -101,16 +111,17 @@ def generate_submission(output_dir, results, costs_dict, active_tasks):
|
|
| 101 |
# Calculate estimated LB score
|
| 102 |
unsolved_count = len(active_tasks) - len(results)
|
| 103 |
total_score = sum(max(1.0, 25.0 - math.log(max(1, cost))) for cost in costs_dict.values())
|
| 104 |
-
|
| 105 |
return {
|
| 106 |
'n_files': n_files,
|
| 107 |
'total_size': total_size,
|
| 108 |
'zip_path': zip_path,
|
| 109 |
'zip_size': zip_size,
|
| 110 |
'csv_path': csv_path,
|
| 111 |
-
'est_lb': total_score,
|
| 112 |
'total_score': total_score,
|
| 113 |
'unsolved_count': unsolved_count,
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
|
|
@@ -119,15 +130,20 @@ def print_summary(results, submission_info, elapsed):
|
|
| 119 |
active_count = submission_info['unsolved_count'] + len(results)
|
| 120 |
|
| 121 |
print(f"\n{'=' * 70}")
|
| 122 |
-
print(f"Solved: {len(results)}/{active_count}
|
| 123 |
solver_names = [v[0] for v in results.values()]
|
| 124 |
sc = Counter(solver_names)
|
| 125 |
for s, c in sc.most_common():
|
| 126 |
print(f" {s}: {c}")
|
| 127 |
|
| 128 |
print(f"\n{submission_info['n_files']} ONNX files, {submission_info['total_size'] / 1024:.1f} KB uncompressed")
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
print(f"Estimated LB score: {submission_info['est_lb']:.1f} "
|
| 132 |
-
f"(solved: {submission_info['total_score']:.1f} unsolved: {submission_info['unsolved_count']})")
|
| 133 |
print(f"Written: {submission_info['zip_path']} | {submission_info['csv_path']}")
|
|
|
|
| 8 |
import zipfile
|
| 9 |
from collections import Counter
|
| 10 |
from .profiler import score_network
|
| 11 |
+
from .constants import MAX_ONNX_FILESIZE, EXCLUDED_TASKS
|
| 12 |
|
| 13 |
try:
|
| 14 |
import wandb
|
|
|
|
| 30 |
for tn in task_nums:
|
| 31 |
if tn not in tasks:
|
| 32 |
continue
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
td = tasks[tn]['data']
|
| 35 |
ok, sname, sz, t_task, model_path = solve_task(
|
|
|
|
| 44 |
score = max(1.0, 25.0 - math.log(max(1, cost)))
|
| 45 |
total_score += score
|
| 46 |
|
| 47 |
+
# Check per-file size limit
|
| 48 |
+
if sz and sz > MAX_ONNX_FILESIZE:
|
| 49 |
+
print(f"Task {tn:3d}: {sname:25s} OVER SIZE LIMIT ({sz:,} > {MAX_ONNX_FILESIZE:,})")
|
| 50 |
+
continue
|
| 51 |
+
|
| 52 |
results[tn] = (sname, t_task, sz)
|
| 53 |
costs_dict[tn] = cost
|
| 54 |
print(f"Task {tn:3d}: {sname:25s} {score:7.3f} {cost:>12} {t_task:7.3f}s ({sz:>8,} bytes)")
|
|
|
|
| 79 |
total_size = sum(os.path.getsize(os.path.join(output_dir, f))
|
| 80 |
for f in os.listdir(output_dir) if f.endswith('.onnx'))
|
| 81 |
|
| 82 |
+
# Check per-file size limits
|
| 83 |
+
oversized = []
|
| 84 |
+
for f in os.listdir(output_dir):
|
| 85 |
+
if f.endswith('.onnx'):
|
| 86 |
+
fsize = os.path.getsize(os.path.join(output_dir, f))
|
| 87 |
+
if fsize > MAX_ONNX_FILESIZE:
|
| 88 |
+
oversized.append((f, fsize))
|
| 89 |
+
|
| 90 |
# Create submission.zip
|
| 91 |
parent_dir = os.path.dirname(output_dir) or '/kaggle/working/'
|
| 92 |
zip_path = os.path.join(parent_dir, 'submission.zip')
|
|
|
|
| 111 |
# Calculate estimated LB score
|
| 112 |
unsolved_count = len(active_tasks) - len(results)
|
| 113 |
total_score = sum(max(1.0, 25.0 - math.log(max(1, cost))) for cost in costs_dict.values())
|
| 114 |
+
|
| 115 |
return {
|
| 116 |
'n_files': n_files,
|
| 117 |
'total_size': total_size,
|
| 118 |
'zip_path': zip_path,
|
| 119 |
'zip_size': zip_size,
|
| 120 |
'csv_path': csv_path,
|
| 121 |
+
'est_lb': total_score + unsolved_count * 1.0,
|
| 122 |
'total_score': total_score,
|
| 123 |
'unsolved_count': unsolved_count,
|
| 124 |
+
'oversized': oversized,
|
| 125 |
}
|
| 126 |
|
| 127 |
|
|
|
|
| 130 |
active_count = submission_info['unsolved_count'] + len(results)
|
| 131 |
|
| 132 |
print(f"\n{'=' * 70}")
|
| 133 |
+
print(f"Solved: {len(results)}/{active_count} tasks in {elapsed:.0f}s")
|
| 134 |
solver_names = [v[0] for v in results.values()]
|
| 135 |
sc = Counter(solver_names)
|
| 136 |
for s, c in sc.most_common():
|
| 137 |
print(f" {s}: {c}")
|
| 138 |
|
| 139 |
print(f"\n{submission_info['n_files']} ONNX files, {submission_info['total_size'] / 1024:.1f} KB uncompressed")
|
| 140 |
+
print(f"ZIP size: {submission_info['zip_size'] / 1024:.1f} KB")
|
| 141 |
+
|
| 142 |
+
if submission_info['oversized']:
|
| 143 |
+
print(f"WARNING: {len(submission_info['oversized'])} files exceed 1.44MB limit:")
|
| 144 |
+
for f, sz in submission_info['oversized']:
|
| 145 |
+
print(f" {f}: {sz / 1024:.1f} KB")
|
| 146 |
+
|
| 147 |
print(f"Estimated LB score: {submission_info['est_lb']:.1f} "
|
| 148 |
+
f"(solved: {submission_info['total_score']:.1f} + unsolved: {submission_info['unsolved_count']}x1.0)")
|
| 149 |
print(f"Written: {submission_info['zip_path']} | {submission_info['csv_path']}")
|