openenv-cloudsoc / _test_hf_env.py
OpenEnv Contributor
fix: update score range to 0.1-0.9 per hackathon spec, add inference tests, update validator
cd7807c
Raw
History Blame Contribute Delete
2.5 kB
#!/usr/bin/env python3
"""
Simulate what will happen in HF Space during evaluation
"""
print("=" * 70)
print("SIMULATING HF SPACE EVALUATION ENVIRONMENT")
print("=" * 70)
# Test 1: Can we import the modules?
print("\n1. Testing imports...")
try:
import cloud_soc_env
print(" βœ“ cloud_soc_env imports successfully")
except Exception as e:
print(f" βœ— Failed to import cloud_soc_env: {e}")
try:
import graders
print(" βœ“ graders imports successfully")
except Exception as e:
print(f" βœ— Failed to import graders: {e}")
try:
import yaml
print(" βœ“ yaml imports successfully")
except Exception as e:
print(f" βœ— Failed to import yaml: {e}")
# Test 2: Can we load openenv.yaml?
print("\n2. Testing openenv.yaml loading...")
try:
with open('openenv.yaml', encoding='utf-8') as f:
data = yaml.safe_load(f)
print(f" βœ“ openenv.yaml loaded successfully")
print(f" βœ“ Found {len(data.get('tasks', []))} tasks")
except Exception as e:
print(f" βœ— Failed to load openenv.yaml: {e}")
# Test 3: Can we access grader functions?
print("\n3. Testing grader function access...")
try:
func_easy = getattr(graders, 'grade_easy')
func_medium = getattr(graders, 'grade_medium')
func_hard = getattr(graders, 'grade_hard')
print(f" βœ“ All 3 grader functions accessible")
except Exception as e:
print(f" βœ— Failed to access grader functions: {e}")
# Test 4: Can we call the graders?
print("\n4. Testing grader function execution...")
try:
result_easy = graders.grade_easy([])
result_medium = graders.grade_medium([])
result_hard = graders.grade_hard([])
print(f" βœ“ grade_easy([]) = {result_easy}")
print(f" βœ“ grade_medium([]) = {result_medium}")
print(f" βœ“ grade_hard([]) = {result_hard}")
# Validate all are in range
all_in_range = all(0 < s < 1 for s in [result_easy, result_medium, result_hard])
if all_in_range:
print(f" βœ“ ALL SCORES IN VALID RANGE (0, 1)")
else:
print(f" βœ— SOME SCORES OUT OF RANGE")
except Exception as e:
print(f" βœ— Failed to execute graders: {e}")
# Test 5: Test inference.py imports
print("\n5. Testing inference.py imports...")
try:
import inference
print(f" βœ“ inference.py imports successfully")
except Exception as e:
print(f" βœ— Failed to import inference.py: {e}")
print("\n" + "=" * 70)
print("βœ… HF SPACE ENVIRONMENT SIMULATION: PASSED")
print("=" * 70)