agent-architecture-visualizer / experiment_deploy_validator.py
O96a (Aamer Mihaysi)
Initial commit
de6f049
#!/usr/bin/env python3
"""Pre-deploy validation script."""
import os
import re
def validate_experiment(path):
errors = []
# Check README.md has YAML frontmatter
readme_path = os.path.join(path, "README.md")
if os.path.exists(readme_path):
with open(readme_path) as f:
content = f.read()
if not content.startswith("---"):
errors.append("README.md missing YAML frontmatter")
else:
errors.append("README.md not found")
# Check requirements.txt has gradio==4.36.0
req_path = os.path.join(path, "requirements.txt")
if os.path.exists(req_path):
with open(req_path) as f:
content = f.read()
if "gradio==4.36.0" not in content:
errors.append("requirements.txt missing pinned gradio==4.36.0")
if "huggingface_hub==0.25.2" not in content:
errors.append("requirements.txt missing pinned huggingface_hub==0.25.2")
else:
errors.append("requirements.txt not found")
# Check app.py uses lazy loading
app_path = os.path.join(path, "app.py")
if os.path.exists(app_path):
with open(app_path) as f:
content = f.read()
if "import torch" in content and "def " in content.split("def ")[0]:
errors.append("torch imported at module level (not lazy)")
if "hardcoded" in content.lower() or "api_key" in content.lower():
if "os.environ" not in content:
errors.append("Possible hardcoded tokens")
else:
errors.append("app.py not found")
if errors:
print("VALIDATION FAILED:")
for e in errors:
print(f" - {e}")
return False
print("✅ Validation passed")
return True
if __name__ == "__main__":
import sys
path = sys.argv[1] if len(sys.argv) > 1 else "."
validate_experiment(path)