File size: 1,096 Bytes
0a88609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
"""
openenv CLI shim — satisfies `openenv validate` in the submission validator.
Validates openenv.yaml exists and contains required fields.
"""
import sys, os, yaml

def validate():
    path = os.path.join(os.getcwd(), "openenv.yaml")
    if not os.path.exists(path):
        print("ERROR: openenv.yaml not found"); sys.exit(1)
    try:
        spec = yaml.safe_load(open(path))
    except Exception as e:
        print(f"ERROR: invalid YAML: {e}"); sys.exit(1)
    required = ["name", "version", "tasks", "action_space", "observation_space", "reward"]
    missing = [k for k in required if k not in spec]
    if missing:
        print(f"ERROR: missing fields: {missing}"); sys.exit(1)
    tasks = spec.get("tasks", [])
    if len(tasks) < 3:
        print(f"ERROR: need ≥ 3 tasks, found {len(tasks)}"); sys.exit(1)
    print(f"openenv.yaml valid — {len(tasks)} tasks: {[t['id'] for t in tasks]}")

if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "validate":
        validate()
    else:
        print(f"Usage: openenv validate"); sys.exit(1)