#!/usr/bin/env python3 """ Test script to verify environment setup for Lab Agent. Run this in your Codespace to diagnose issues. """ import os import sys import importlib import subprocess def check_dependency(module_name): """Check if a Python module is installed and can be imported.""" try: importlib.import_module(module_name) return True except ImportError: return False def check_command(command): """Check if a shell command exists and can be executed.""" try: subprocess.run(command, shell=True, check=True, capture_output=True) return True except subprocess.CalledProcessError: return False def main(): print("šŸ” Lab Agent Environment Test") print("-----------------------------") # Check Python version print(f"Python version: {sys.version}") # Check required modules print("\nšŸ“¦ Checking Python dependencies:") dependencies = [ "openai", "yaml", "chromadb", "git", "Bio", "requests", "langchain", "faiss", "json" ] for dep in dependencies: status = "āœ…" if check_dependency(dep) else "āŒ" print(f"{status} {dep}") # Check environment variables print("\nšŸ”‘ Checking environment variables:") env_vars = ["OPENAI_API_KEY", "GITHUB_TOKEN"] for var in env_vars: value = os.environ.get(var) if value: # Hide actual key values display = f"{value[:4]}...{value[-4:]}" if len(value) > 8 else "****" print(f"āœ… {var} = {display}") else: print(f"āŒ {var} is not set") # Check file structure print("\nšŸ“ Checking repository structure:") directories = ["Agent", "Protocols", "Experiments", "Data", "Templates"] for directory in directories: if os.path.isdir(directory): print(f"āœ… {directory}/ exists") else: print(f"āŒ {directory}/ is missing") # Check GitHub CLI print("\nšŸ”§ Checking GitHub CLI:") if check_command("gh --version"): print("āœ… GitHub CLI is installed") # Check if authenticated if check_command("gh auth status"): print("āœ… GitHub CLI is authenticated") else: print("āŒ GitHub CLI is not authenticated") else: print("āŒ GitHub CLI is not installed") print("\n-----------------------------") print("If you see any āŒ errors above, they need to be fixed before the Lab Agent will work properly.") print("For GitHub authentication in Codespaces, try running 'gh auth status' and follow any prompts.") if __name__ == "__main__": main()