Commit ·
e8f8c7b
1
Parent(s): d51a89a
Fix Phase 2 validation: Add missing graders for advanced_efficiency and expert_optimization tasks
Browse files- .gitignore +0 -0
- __init__.py +4 -0
- graders.json +54 -2
- graders_manifest.py +45 -4
- openenv_he_demo.egg-info/SOURCES.txt +5 -0
- openenv_he_demo.egg-info/top_level.txt +1 -0
- task_graders.py +88 -0
- validate-submission.sh +185 -0
- validate_comprehensive.py +8 -2
.gitignore
CHANGED
|
Binary files a/.gitignore and b/.gitignore differ
|
|
|
__init__.py
CHANGED
|
@@ -16,6 +16,8 @@ from .task_graders import (
|
|
| 16 |
task_1_basic_ram_reduction_grader,
|
| 17 |
task_2_energy_optimization_grader,
|
| 18 |
task_3_balanced_optimization_grader,
|
|
|
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
__all__ = [
|
|
@@ -30,4 +32,6 @@ __all__ = [
|
|
| 30 |
"task_1_basic_ram_reduction_grader",
|
| 31 |
"task_2_energy_optimization_grader",
|
| 32 |
"task_3_balanced_optimization_grader",
|
|
|
|
|
|
|
| 33 |
]
|
|
|
|
| 16 |
task_1_basic_ram_reduction_grader,
|
| 17 |
task_2_energy_optimization_grader,
|
| 18 |
task_3_balanced_optimization_grader,
|
| 19 |
+
task_4_advanced_efficiency_grader,
|
| 20 |
+
task_5_expert_optimization_grader,
|
| 21 |
)
|
| 22 |
|
| 23 |
__all__ = [
|
|
|
|
| 32 |
"task_1_basic_ram_reduction_grader",
|
| 33 |
"task_2_energy_optimization_grader",
|
| 34 |
"task_3_balanced_optimization_grader",
|
| 35 |
+
"task_4_advanced_efficiency_grader",
|
| 36 |
+
"task_5_expert_optimization_grader",
|
| 37 |
]
|
graders.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"spec_version": "1.0",
|
| 4 |
"type": "rl-environment",
|
| 5 |
"real_world_application": "System resource optimization for data centers, cloud infrastructure, edge computing, and IoT devices",
|
| 6 |
-
"total_graders":
|
| 7 |
"minimum_required_graders": 3,
|
| 8 |
"validation_status": "PASS",
|
| 9 |
"scoring_scale": "0.0 (worst performance) to 1.0 (best performance)",
|
|
@@ -112,10 +112,62 @@
|
|
| 112 |
"score": 0.925
|
| 113 |
}
|
| 114 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
],
|
| 117 |
"summary": {
|
| 118 |
-
"graders_count":
|
| 119 |
"min_graders_required": 3,
|
| 120 |
"graders_detected": true,
|
| 121 |
"different_scores_returned": true,
|
|
|
|
| 3 |
"spec_version": "1.0",
|
| 4 |
"type": "rl-environment",
|
| 5 |
"real_world_application": "System resource optimization for data centers, cloud infrastructure, edge computing, and IoT devices",
|
| 6 |
+
"total_graders": 5,
|
| 7 |
"minimum_required_graders": 3,
|
| 8 |
"validation_status": "PASS",
|
| 9 |
"scoring_scale": "0.0 (worst performance) to 1.0 (best performance)",
|
|
|
|
| 112 |
"score": 0.925
|
| 113 |
}
|
| 114 |
}
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"id": "task_4_advanced_efficiency_grader",
|
| 118 |
+
"name": "advanced_efficiency",
|
| 119 |
+
"display_name": "Advanced Efficiency",
|
| 120 |
+
"difficulty": 4,
|
| 121 |
+
"category": "hard",
|
| 122 |
+
"description": "Achieve RAM below 50% and energy below 4 kWh",
|
| 123 |
+
"targets": {
|
| 124 |
+
"ram_percentage": 50.0,
|
| 125 |
+
"energy_kwh": 4.0,
|
| 126 |
+
"max_steps": 25
|
| 127 |
+
},
|
| 128 |
+
"scoring_methodology": "Balance Score (90%: RAM Score 50% + Energy Score 50%) + Step Efficiency Bonus (10%)",
|
| 129 |
+
"real_world_application": "Highly constrained embedded systems and IoT devices",
|
| 130 |
+
"score_examples": {
|
| 131 |
+
"worst_case": {
|
| 132 |
+
"ram": 100.0,
|
| 133 |
+
"energy": 10.0,
|
| 134 |
+
"steps": 50,
|
| 135 |
+
"score": 0.0
|
| 136 |
+
},
|
| 137 |
+
"target_case": {
|
| 138 |
+
"ram": 50.0,
|
| 139 |
+
"energy": 4.0,
|
| 140 |
+
"steps": 25,
|
| 141 |
+
"score": 0.9
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
"id": "task_5_expert_optimization_grader",
|
| 147 |
+
"name": "expert_optimization",
|
| 148 |
+
"display_name": "Expert Optimization",
|
| 149 |
+
"difficulty": 5,
|
| 150 |
+
"category": "expert",
|
| 151 |
+
"description": "Master level: RAM below 40% and energy below 3 kWh",
|
| 152 |
+
"targets": {
|
| 153 |
+
"ram_percentage": 40.0,
|
| 154 |
+
"energy_kwh": 3.0,
|
| 155 |
+
"max_steps": 30
|
| 156 |
+
},
|
| 157 |
+
"scoring_methodology": "Balance Score (90%: RAM Score 60% + Energy Score 40%) + Step Efficiency Bonus (10%)",
|
| 158 |
+
"real_world_application": "Mission-critical space, deep-sea probes, and highly scaled edge clusters",
|
| 159 |
+
"score_examples": {
|
| 160 |
+
"worst_case": {
|
| 161 |
+
"ram": 100.0,
|
| 162 |
+
"energy": 10.0,
|
| 163 |
+
"steps": 50,
|
| 164 |
+
"score": 0.0
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
}
|
| 168 |
],
|
| 169 |
"summary": {
|
| 170 |
+
"graders_count": 5,
|
| 171 |
"min_graders_required": 3,
|
| 172 |
"graders_detected": true,
|
| 173 |
"different_scores_returned": true,
|
graders_manifest.py
CHANGED
|
@@ -29,7 +29,7 @@ GRADERS_MANIFEST = {
|
|
| 29 |
"environment_type": "OpenEnv RL Environment",
|
| 30 |
"version": "1.0.0",
|
| 31 |
"spec_version": "1",
|
| 32 |
-
"total_graders":
|
| 33 |
"minimum_required_graders": 3,
|
| 34 |
"validation_requirement_met": True, # 3 >= 3
|
| 35 |
"real_world_application": "System resource optimization for production data centers, cloud infrastructure, and edge computing devices",
|
|
@@ -112,6 +112,46 @@ GRADERS_MANIFEST = {
|
|
| 112 |
"score_0_8_or_higher": {"scenario": "Good Performance", "ram": 60.0, "energy": 5.0, "steps": 18},
|
| 113 |
"score_0_9_or_higher": {"scenario": "Excellent Performance", "ram": 50.0, "energy": 4.0, "steps": 15}
|
| 114 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
},
|
| 117 |
|
|
@@ -125,13 +165,14 @@ GRADERS_MANIFEST = {
|
|
| 125 |
},
|
| 126 |
|
| 127 |
"environment_stats": {
|
| 128 |
-
"total_difficulty_levels":
|
| 129 |
"min_difficulty": 1,
|
| 130 |
-
"max_difficulty":
|
| 131 |
"task_distribution": {
|
| 132 |
"easy": 1,
|
| 133 |
"medium": 1,
|
| 134 |
-
"hard":
|
|
|
|
| 135 |
}
|
| 136 |
}
|
| 137 |
}
|
|
|
|
| 29 |
"environment_type": "OpenEnv RL Environment",
|
| 30 |
"version": "1.0.0",
|
| 31 |
"spec_version": "1",
|
| 32 |
+
"total_graders": 5,
|
| 33 |
"minimum_required_graders": 3,
|
| 34 |
"validation_requirement_met": True, # 3 >= 3
|
| 35 |
"real_world_application": "System resource optimization for production data centers, cloud infrastructure, and edge computing devices",
|
|
|
|
| 112 |
"score_0_8_or_higher": {"scenario": "Good Performance", "ram": 60.0, "energy": 5.0, "steps": 18},
|
| 113 |
"score_0_9_or_higher": {"scenario": "Excellent Performance", "ram": 50.0, "energy": 4.0, "steps": 15}
|
| 114 |
}
|
| 115 |
+
},
|
| 116 |
+
|
| 117 |
+
"task_4_advanced_efficiency_grader": {
|
| 118 |
+
"task_name": "advanced_efficiency",
|
| 119 |
+
"display_name": "Task 4: Advanced Efficiency",
|
| 120 |
+
"difficulty_level": 4,
|
| 121 |
+
"difficulty_category": "HARD",
|
| 122 |
+
"description": "Agent must achieve RAM below 50% and energy below 4 kWh",
|
| 123 |
+
"targets": {
|
| 124 |
+
"ram_usage_percentage": 50.0,
|
| 125 |
+
"energy_consumption_kwh": 4.0,
|
| 126 |
+
"max_steps_allowed": 25
|
| 127 |
+
},
|
| 128 |
+
"scoring_methodology": {
|
| 129 |
+
"formula": "((ram_score * 0.5 + energy_score * 0.5) * 0.9) + step_bonus"
|
| 130 |
+
},
|
| 131 |
+
"real_world_context": "Highly constrained embedded systems and IoT devices.",
|
| 132 |
+
"performance_examples": {
|
| 133 |
+
"score_0_0": {"scenario": "Worst Performance", "ram": 100.0, "energy": 10.0, "steps": 50}
|
| 134 |
+
}
|
| 135 |
+
},
|
| 136 |
+
|
| 137 |
+
"task_5_expert_optimization_grader": {
|
| 138 |
+
"task_name": "expert_optimization",
|
| 139 |
+
"display_name": "Task 5: Expert Optimization",
|
| 140 |
+
"difficulty_level": 5,
|
| 141 |
+
"difficulty_category": "EXPERT",
|
| 142 |
+
"description": "Master level: Agent must reduce RAM below 40% and energy below 3 kWh",
|
| 143 |
+
"targets": {
|
| 144 |
+
"ram_usage_percentage": 40.0,
|
| 145 |
+
"energy_consumption_kwh": 3.0,
|
| 146 |
+
"max_steps_allowed": 30
|
| 147 |
+
},
|
| 148 |
+
"scoring_methodology": {
|
| 149 |
+
"formula": "((ram_score * 0.6 + energy_score * 0.4) * 0.9) + step_bonus"
|
| 150 |
+
},
|
| 151 |
+
"real_world_context": "Mission-critical space, deep-sea probes, and highly scaled edge clusters.",
|
| 152 |
+
"performance_examples": {
|
| 153 |
+
"score_0_0": {"scenario": "Worst Performance", "ram": 100.0, "energy": 10.0, "steps": 50}
|
| 154 |
+
}
|
| 155 |
}
|
| 156 |
},
|
| 157 |
|
|
|
|
| 165 |
},
|
| 166 |
|
| 167 |
"environment_stats": {
|
| 168 |
+
"total_difficulty_levels": 5,
|
| 169 |
"min_difficulty": 1,
|
| 170 |
+
"max_difficulty": 5,
|
| 171 |
"task_distribution": {
|
| 172 |
"easy": 1,
|
| 173 |
"medium": 1,
|
| 174 |
+
"hard": 2,
|
| 175 |
+
"expert": 1
|
| 176 |
}
|
| 177 |
}
|
| 178 |
}
|
openenv_he_demo.egg-info/SOURCES.txt
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
README.md
|
| 2 |
__init__.py
|
| 3 |
client.py
|
|
|
|
| 4 |
gym_wrapper.py
|
| 5 |
inference.py
|
| 6 |
models.py
|
|
@@ -10,12 +11,16 @@ train_agent.py
|
|
| 10 |
validate.py
|
| 11 |
./__init__.py
|
| 12 |
./client.py
|
|
|
|
|
|
|
| 13 |
./gym_wrapper.py
|
| 14 |
./inference.py
|
| 15 |
./models.py
|
|
|
|
| 16 |
./test_environment.py
|
| 17 |
./train_agent.py
|
| 18 |
./validate.py
|
|
|
|
| 19 |
openenv_he_demo.egg-info/PKG-INFO
|
| 20 |
openenv_he_demo.egg-info/SOURCES.txt
|
| 21 |
openenv_he_demo.egg-info/dependency_links.txt
|
|
|
|
| 1 |
README.md
|
| 2 |
__init__.py
|
| 3 |
client.py
|
| 4 |
+
graders.py
|
| 5 |
gym_wrapper.py
|
| 6 |
inference.py
|
| 7 |
models.py
|
|
|
|
| 11 |
validate.py
|
| 12 |
./__init__.py
|
| 13 |
./client.py
|
| 14 |
+
./graders.py
|
| 15 |
+
./graders_manifest.py
|
| 16 |
./gym_wrapper.py
|
| 17 |
./inference.py
|
| 18 |
./models.py
|
| 19 |
+
./task_graders.py
|
| 20 |
./test_environment.py
|
| 21 |
./train_agent.py
|
| 22 |
./validate.py
|
| 23 |
+
./validate_comprehensive.py
|
| 24 |
openenv_he_demo.egg-info/PKG-INFO
|
| 25 |
openenv_he_demo.egg-info/SOURCES.txt
|
| 26 |
openenv_he_demo.egg-info/dependency_links.txt
|
openenv_he_demo.egg-info/top_level.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
|
|
|
| 1 |
he_demo
|
|
|
|
| 1 |
+
graders
|
| 2 |
he_demo
|
task_graders.py
CHANGED
|
@@ -186,6 +186,70 @@ def task_3_balanced_optimization_grader(observation: EnergyOptimizationObservati
|
|
| 186 |
return round(composite_score, 3)
|
| 187 |
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
# ============================================================================
|
| 190 |
# Registry and Metadata
|
| 191 |
# ============================================================================
|
|
@@ -227,6 +291,30 @@ TASK_GRADERS: Dict[str, Dict[str, Any]] = {
|
|
| 227 |
"max_steps": 20,
|
| 228 |
"category": "hard",
|
| 229 |
"real_world_application": "Production system optimization with dual constraints"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
}
|
| 231 |
}
|
| 232 |
|
|
|
|
| 186 |
return round(composite_score, 3)
|
| 187 |
|
| 188 |
|
| 189 |
+
# ============================================================================
|
| 190 |
+
# TASK 4: Advanced Efficiency (Hard Level - Difficulty 4)
|
| 191 |
+
# ============================================================================
|
| 192 |
+
|
| 193 |
+
def task_4_advanced_efficiency_grader(observation: EnergyOptimizationObservation) -> float:
|
| 194 |
+
"""
|
| 195 |
+
Grade Task 4: Advanced Efficiency
|
| 196 |
+
|
| 197 |
+
Target: Achieve RAM below 50% and energy below 4 kWh within 25 steps.
|
| 198 |
+
"""
|
| 199 |
+
ram_target = 50.0
|
| 200 |
+
energy_target = 4.0
|
| 201 |
+
max_steps = 25
|
| 202 |
+
|
| 203 |
+
ram_baseline = 100.0
|
| 204 |
+
energy_baseline = 10.0
|
| 205 |
+
|
| 206 |
+
ram_score = max(0.0, min(1.0, (ram_baseline - observation.ram_usage) / (ram_baseline - ram_target)))
|
| 207 |
+
energy_score = max(0.0, min(1.0, (energy_baseline - observation.energy_consumption) / (energy_baseline - energy_target)))
|
| 208 |
+
|
| 209 |
+
balance_score = (ram_score + energy_score) / 2.0
|
| 210 |
+
|
| 211 |
+
if observation.steps_taken <= max_steps:
|
| 212 |
+
step_bonus = min(0.1, (max_steps - observation.steps_taken) / max_steps * 0.1)
|
| 213 |
+
else:
|
| 214 |
+
step_bonus = max(-0.2, -(observation.steps_taken - max_steps) * 0.05)
|
| 215 |
+
|
| 216 |
+
composite_score = max(0.0, min(1.0, (balance_score * 0.9) + step_bonus))
|
| 217 |
+
|
| 218 |
+
return round(composite_score, 3)
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
# ============================================================================
|
| 222 |
+
# TASK 5: Expert Optimization (Master Level - Difficulty 5)
|
| 223 |
+
# ============================================================================
|
| 224 |
+
|
| 225 |
+
def task_5_expert_optimization_grader(observation: EnergyOptimizationObservation) -> float:
|
| 226 |
+
"""
|
| 227 |
+
Grade Task 5: Expert Optimization
|
| 228 |
+
|
| 229 |
+
Target: Master level: RAM below 40% and energy below 3 kWh within 30 steps.
|
| 230 |
+
"""
|
| 231 |
+
ram_target = 40.0
|
| 232 |
+
energy_target = 3.0
|
| 233 |
+
max_steps = 30
|
| 234 |
+
|
| 235 |
+
ram_baseline = 100.0
|
| 236 |
+
energy_baseline = 10.0
|
| 237 |
+
|
| 238 |
+
ram_score = max(0.0, min(1.0, (ram_baseline - observation.ram_usage) / (ram_baseline - ram_target)))
|
| 239 |
+
energy_score = max(0.0, min(1.0, (energy_baseline - observation.energy_consumption) / (energy_baseline - energy_target)))
|
| 240 |
+
|
| 241 |
+
balance_score = (ram_score * 0.6) + (energy_score * 0.4)
|
| 242 |
+
|
| 243 |
+
if observation.steps_taken <= max_steps:
|
| 244 |
+
step_bonus = min(0.1, (max_steps - observation.steps_taken) / max_steps * 0.1)
|
| 245 |
+
else:
|
| 246 |
+
step_bonus = max(-0.3, -(observation.steps_taken - max_steps) * 0.05)
|
| 247 |
+
|
| 248 |
+
composite_score = max(0.0, min(1.0, (balance_score * 0.9) + step_bonus))
|
| 249 |
+
|
| 250 |
+
return round(composite_score, 3)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
# ============================================================================
|
| 254 |
# Registry and Metadata
|
| 255 |
# ============================================================================
|
|
|
|
| 291 |
"max_steps": 20,
|
| 292 |
"category": "hard",
|
| 293 |
"real_world_application": "Production system optimization with dual constraints"
|
| 294 |
+
},
|
| 295 |
+
"advanced_efficiency": {
|
| 296 |
+
"grader": task_4_advanced_efficiency_grader,
|
| 297 |
+
"name": "advanced_efficiency",
|
| 298 |
+
"display_name": "Advanced Efficiency",
|
| 299 |
+
"difficulty": 4,
|
| 300 |
+
"description": "Achieve RAM below 50% and energy below 4 kWh",
|
| 301 |
+
"target_ram": 50.0,
|
| 302 |
+
"target_energy": 4.0,
|
| 303 |
+
"max_steps": 25,
|
| 304 |
+
"category": "hard",
|
| 305 |
+
"real_world_application": "Highly constrained embedded systems and IoT devices"
|
| 306 |
+
},
|
| 307 |
+
"expert_optimization": {
|
| 308 |
+
"grader": task_5_expert_optimization_grader,
|
| 309 |
+
"name": "expert_optimization",
|
| 310 |
+
"display_name": "Expert Optimization",
|
| 311 |
+
"difficulty": 5,
|
| 312 |
+
"description": "Master level: RAM below 40% and energy below 3 kWh",
|
| 313 |
+
"target_ram": 40.0,
|
| 314 |
+
"target_energy": 3.0,
|
| 315 |
+
"max_steps": 30,
|
| 316 |
+
"category": "expert",
|
| 317 |
+
"real_world_application": "Mission-critical space, deep-sea probes, and highly scaled edge clusters"
|
| 318 |
}
|
| 319 |
}
|
| 320 |
|
validate-submission.sh
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
#
|
| 3 |
+
# validate-submission.sh — OpenEnv Submission Validator
|
| 4 |
+
#
|
| 5 |
+
# Checks that your HF Space is live, Docker image builds, and openenv validate passes.
|
| 6 |
+
#
|
| 7 |
+
# Prerequisites:
|
| 8 |
+
# - Docker: https://docs.docker.com/get-docker/
|
| 9 |
+
# - openenv-core: pip install openenv-core
|
| 10 |
+
# - curl (usually pre-installed)
|
| 11 |
+
#
|
| 12 |
+
# Run:
|
| 13 |
+
# curl -fsSL https://raw.githubusercontent.com/<owner>/<repo>/main/scripts/validate-submission.sh | bash -s -- <ping_url> [repo_dir]
|
| 14 |
+
#
|
| 15 |
+
# Or download and run locally:
|
| 16 |
+
# chmod +x validate-submission.sh
|
| 17 |
+
# ./validate-submission.sh <ping_url> [repo_dir]
|
| 18 |
+
#
|
| 19 |
+
# Arguments:
|
| 20 |
+
# ping_url Your HuggingFace Space URL (e.g. https://your-space.hf.space)
|
| 21 |
+
# repo_dir Path to your repo (default: current directory)
|
| 22 |
+
#
|
| 23 |
+
# Examples:
|
| 24 |
+
# ./validate-submission.sh https://my-team.hf.space
|
| 25 |
+
# ./validate-submission.sh https://my-team.hf.space ./my-repo
|
| 26 |
+
#
|
| 27 |
+
|
| 28 |
+
set -uo pipefail
|
| 29 |
+
|
| 30 |
+
DOCKER_BUILD_TIMEOUT=600
|
| 31 |
+
if [ -t 1 ]; then
|
| 32 |
+
RED='\033[0;31m'
|
| 33 |
+
GREEN='\033[0;32m'
|
| 34 |
+
YELLOW='\033[1;33m'
|
| 35 |
+
BOLD='\033[1m'
|
| 36 |
+
NC='\033[0m'
|
| 37 |
+
else
|
| 38 |
+
RED='' GREEN='' YELLOW='' BOLD='' NC=''
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
run_with_timeout() {
|
| 42 |
+
local secs="$1"; shift
|
| 43 |
+
if command -v timeout >/dev/null; then
|
| 44 |
+
timeout "$secs" "$@"
|
| 45 |
+
elif command -v gtimeout >/dev/null; then
|
| 46 |
+
gtimeout "$secs" "$@"
|
| 47 |
+
else
|
| 48 |
+
"$@" &
|
| 49 |
+
local pid=$!
|
| 50 |
+
( sleep "$secs" && kill "$pid" 2>/dev/null ) &
|
| 51 |
+
local watcher=$!
|
| 52 |
+
wait "$pid" 2>/dev/null
|
| 53 |
+
local rc=$?
|
| 54 |
+
kill "$watcher" 2>/dev/null
|
| 55 |
+
wait "$watcher" 2>/dev/null
|
| 56 |
+
return $rc
|
| 57 |
+
fi
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
portable_mktemp() {
|
| 61 |
+
local prefix="${1:-validate}"
|
| 62 |
+
mktemp "${TMPDIR:-/tmp}/${prefix}-XXXXXX" 2>/dev/null || mktemp
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
CLEANUP_FILES=()
|
| 66 |
+
cleanup() { rm -f "${CLEANUP_FILES[@]+"${CLEANUP_FILES[@]}"}"; }
|
| 67 |
+
trap cleanup EXIT
|
| 68 |
+
|
| 69 |
+
PING_URL="${1:-}"
|
| 70 |
+
REPO_DIR="${2:-.}"
|
| 71 |
+
|
| 72 |
+
if [ -z "$PING_URL" ]; then
|
| 73 |
+
printf "Usage: %s <ping_url> [repo_dir]\n" "$0"
|
| 74 |
+
printf "\n"
|
| 75 |
+
printf " ping_url Your HuggingFace Space URL (e.g. https://your-space.hf.space)\n"
|
| 76 |
+
printf " repo_dir Path to your repo (default: current directory)\n"
|
| 77 |
+
exit 1
|
| 78 |
+
fi
|
| 79 |
+
|
| 80 |
+
if ! REPO_DIR="$(cd "$REPO_DIR" 2>/dev/null && pwd)"; then
|
| 81 |
+
printf "Error: directory '%s' not found\n" "${2:-.}"
|
| 82 |
+
exit 1
|
| 83 |
+
fi
|
| 84 |
+
PING_URL="${PING_URL%/}"
|
| 85 |
+
export PING_URL
|
| 86 |
+
PASS=0
|
| 87 |
+
|
| 88 |
+
log() { printf "[%s] %b\n" "$(date -u +%H:%M:%S)" "$*"; }
|
| 89 |
+
pass() { log "${GREEN}PASSED${NC} -- $1"; PASS=$((PASS + 1)); }
|
| 90 |
+
fail() { log "${RED}FAILED${NC} -- $1"; }
|
| 91 |
+
hint() { printf " ${YELLOW}Hint:${NC} %b\n" "$1"; }
|
| 92 |
+
stop_at() {
|
| 93 |
+
printf "\n"
|
| 94 |
+
printf "${RED}${BOLD}Validation stopped at %s.${NC} Fix the above before continuing.\n" "$1"
|
| 95 |
+
exit 1
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
printf "\n"
|
| 99 |
+
printf "${BOLD}========================================${NC}\n"
|
| 100 |
+
printf "${BOLD} OpenEnv Submission Validator${NC}\n"
|
| 101 |
+
printf "${BOLD}========================================${NC}\n"
|
| 102 |
+
log "Repo: $REPO_DIR"
|
| 103 |
+
log "Ping URL: $PING_URL"
|
| 104 |
+
printf "\n"
|
| 105 |
+
|
| 106 |
+
log "${BOLD}Step 1/3: Pinging HF Space${NC} ($PING_URL/reset) ..."
|
| 107 |
+
|
| 108 |
+
CURL_OUTPUT=$(portable_mktemp "validate-curl")
|
| 109 |
+
CLEANUP_FILES+=("$CURL_OUTPUT")
|
| 110 |
+
HTTP_CODE=$(curl -s -o "$CURL_OUTPUT" -w "%{http_code}" -X POST \
|
| 111 |
+
-H "Content-Type: application/json" -d '{}' \
|
| 112 |
+
"$PING_URL/reset" --max-time 30 2>"$CURL_OUTPUT" || printf "000")
|
| 113 |
+
|
| 114 |
+
if [ "$HTTP_CODE" = "200" ]; then
|
| 115 |
+
pass "HF Space is live and responds to /reset"
|
| 116 |
+
elif [ "$HTTP_CODE" = "000" ]; then
|
| 117 |
+
fail "HF Space not reachable (connection failed or timed out)"
|
| 118 |
+
hint "Check your network connection and that the Space is running."
|
| 119 |
+
hint "Try: curl -s -o /dev/null -w '%{http_code}' -X POST $PING_URL/reset"
|
| 120 |
+
stop_at "Step 1"
|
| 121 |
+
else
|
| 122 |
+
fail "HF Space /reset returned HTTP $HTTP_CODE (expected 200)"
|
| 123 |
+
hint "Make sure your Space is running and the URL is correct."
|
| 124 |
+
hint "Try opening $PING_URL in your browser first."
|
| 125 |
+
stop_at "Step 1"
|
| 126 |
+
fi
|
| 127 |
+
|
| 128 |
+
log "${BOLD}Step 2/3: Running docker build${NC} ..."
|
| 129 |
+
|
| 130 |
+
if ! command -v docker >/dev/null; then
|
| 131 |
+
fail "docker command not found"
|
| 132 |
+
hint "Install Docker: https://docs.docker.com/get-docker/"
|
| 133 |
+
stop_at "Step 2"
|
| 134 |
+
fi
|
| 135 |
+
|
| 136 |
+
if [ -f "$REPO_DIR/Dockerfile" ]; then
|
| 137 |
+
DOCKER_CONTEXT="$REPO_DIR"
|
| 138 |
+
elif [ -f "$REPO_DIR/server/Dockerfile" ]; then
|
| 139 |
+
DOCKER_CONTEXT="$REPO_DIR/server"
|
| 140 |
+
else
|
| 141 |
+
fail "No Dockerfile found in repo root or server/ directory"
|
| 142 |
+
stop_at "Step 2"
|
| 143 |
+
fi
|
| 144 |
+
|
| 145 |
+
log " Found Dockerfile in $DOCKER_CONTEXT"
|
| 146 |
+
|
| 147 |
+
BUILD_OK=false
|
| 148 |
+
BUILD_OUTPUT=$(run_with_timeout "$DOCKER_BUILD_TIMEOUT" docker build "$DOCKER_CONTEXT" 2>&1) && BUILD_OK=true
|
| 149 |
+
|
| 150 |
+
if [ "$BUILD_OK" = true ]; then
|
| 151 |
+
pass "Docker build succeeded"
|
| 152 |
+
else
|
| 153 |
+
fail "Docker build failed (timeout=${DOCKER_BUILD_TIMEOUT}s)"
|
| 154 |
+
printf "%s\n" "$BUILD_OUTPUT" | tail -20
|
| 155 |
+
stop_at "Step 2"
|
| 156 |
+
fi
|
| 157 |
+
|
| 158 |
+
log "${BOLD}Step 3/3: Running openenv validate${NC} ..."
|
| 159 |
+
|
| 160 |
+
if ! command -v openenv >/dev/null; then
|
| 161 |
+
fail "openenv command not found"
|
| 162 |
+
hint "Install it: pip install openenv-core"
|
| 163 |
+
stop_at "Step 3"
|
| 164 |
+
fi
|
| 165 |
+
|
| 166 |
+
VALIDATE_OK=false
|
| 167 |
+
VALIDATE_OUTPUT=$(cd "$REPO_DIR" && openenv validate 2>&1) && VALIDATE_OK=true
|
| 168 |
+
|
| 169 |
+
if [ "$VALIDATE_OK" = true ]; then
|
| 170 |
+
pass "openenv validate passed"
|
| 171 |
+
[ -n "$VALIDATE_OUTPUT" ] && log " $VALIDATE_OUTPUT"
|
| 172 |
+
else
|
| 173 |
+
fail "openenv validate failed"
|
| 174 |
+
printf "%s\n" "$VALIDATE_OUTPUT"
|
| 175 |
+
stop_at "Step 3"
|
| 176 |
+
fi
|
| 177 |
+
|
| 178 |
+
printf "\n"
|
| 179 |
+
printf "${BOLD}========================================${NC}\n"
|
| 180 |
+
printf "${GREEN}${BOLD} All 3/3 checks passed!${NC}\n"
|
| 181 |
+
printf "${GREEN}${BOLD} Your submission is ready to submit.${NC}\n"
|
| 182 |
+
printf "${BOLD}========================================${NC}\n"
|
| 183 |
+
printf "\n"
|
| 184 |
+
|
| 185 |
+
exit 0
|
validate_comprehensive.py
CHANGED
|
@@ -115,10 +115,16 @@ def main():
|
|
| 115 |
# ========================================================================
|
| 116 |
# 4. TEST ALL GRADERS WITH MULTIPLE SCENARIOS
|
| 117 |
# ========================================================================
|
| 118 |
-
print("\n[4] Testing All
|
| 119 |
print("-" * 90)
|
| 120 |
|
| 121 |
-
all_task_names = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
for task_name in all_task_names:
|
| 124 |
metadata = get_grader_metadata(task_name)
|
|
|
|
| 115 |
# ========================================================================
|
| 116 |
# 4. TEST ALL GRADERS WITH MULTIPLE SCENARIOS
|
| 117 |
# ========================================================================
|
| 118 |
+
print("\n[4] Testing All 5 Graders with Performance Scenarios")
|
| 119 |
print("-" * 90)
|
| 120 |
|
| 121 |
+
all_task_names = [
|
| 122 |
+
"basic_ram_reduction",
|
| 123 |
+
"energy_optimization",
|
| 124 |
+
"balanced_optimization",
|
| 125 |
+
"advanced_efficiency",
|
| 126 |
+
"expert_optimization"
|
| 127 |
+
]
|
| 128 |
|
| 129 |
for task_name in all_task_names:
|
| 130 |
metadata = get_grader_metadata(task_name)
|