Spaces:
Sleeping
Sleeping
| """ | |
| LifeOS — OpenEnv YAML Validator | |
| =============================== | |
| Validates that openenv.yaml contains all required fields for the | |
| OpenEnv hackathon submission. | |
| Usage: | |
| python validate_yaml.py | |
| """ | |
| import sys | |
| from pathlib import Path | |
| try: | |
| import yaml | |
| except ImportError: | |
| print("[FAIL] pyyaml is not installed. Install with: pip install pyyaml") | |
| sys.exit(1) | |
| REQUIRED_FIELDS = [ | |
| "name", | |
| "version", | |
| "description", | |
| "entry_point", | |
| "action_space", | |
| "observation_space", | |
| "reward_range", | |
| "tags", | |
| "author", | |
| "huggingface_repo" | |
| ] | |
| def main(): | |
| root = Path(__file__).resolve().parent | |
| yaml_path = root / "openenv.yaml" | |
| if not yaml_path.exists(): | |
| print(f"[FAIL] openenv.yaml not found at {yaml_path}") | |
| sys.exit(1) | |
| with open(yaml_path, "r", encoding="utf-8") as f: | |
| try: | |
| data = yaml.safe_load(f) | |
| except yaml.YAMLError as e: | |
| print(f"[FAIL] openenv.yaml is not valid YAML:\n{e}") | |
| sys.exit(1) | |
| if not isinstance(data, dict): | |
| print("[FAIL] openenv.yaml must be a dictionary at the top level") | |
| sys.exit(1) | |
| missing = [] | |
| for field in REQUIRED_FIELDS: | |
| if field not in data: | |
| missing.append(field) | |
| if missing: | |
| print("[FAIL] openenv.yaml is missing required fields:") | |
| for m in missing: | |
| print(f" - {m}") | |
| sys.exit(1) | |
| print("[OK] openenv.yaml is valid and contains all required fields.") | |
| sys.exit(0) | |
| if __name__ == "__main__": | |
| main() | |