Spaces:
Sleeping
Sleeping
| #!/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) | |