Spaces:
No application file
No application file
sam133
οΏ½ Restructure repo following successful MCP Hackathon pattern: Clean modular architecture with mcp_client.py, design_tools.py, and organized app.py
fe37569
| #!/usr/bin/env python3 | |
| """ | |
| Record trial videos with timestamps to avoid overriding existing files | |
| """ | |
| import os | |
| import time | |
| from datetime import datetime | |
| import main_orchestrator_enhanced | |
| def record_trial_videos(): | |
| """Run trial and record videos with unique timestamps""" | |
| # Create timestamp for this session | |
| timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| print(f"π¬ Recording Trial Videos - Session: {timestamp}") | |
| print("=" * 60) | |
| # Ensure outputs directory exists | |
| os.makedirs("outputs", exist_ok=True) | |
| # List existing videos | |
| existing_videos = [f for f in os.listdir("outputs") if f.endswith('.gif')] | |
| print(f"π Existing videos: {len(existing_videos)} files") | |
| for video in existing_videos[:5]: # Show first 5 | |
| print(f" β’ {video}") | |
| if len(existing_videos) > 5: | |
| print(f" β’ ... and {len(existing_videos) - 5} more") | |
| print(f"\nπ Starting Enhanced Trial with Video Recording...") | |
| print(f"πΉ New videos will be saved with timestamp: {timestamp}") | |
| try: | |
| # Test Robot Design | |
| print(f"\nπ€ Testing Robot Design...") | |
| robot_success, robot_specs = main_orchestrator_enhanced.console_design_vehicle_for_obstacle( | |
| vehicle_type='robot', | |
| user_task_description=f'Design a robot that can pass the 5cm high obstacle - Session {timestamp}' | |
| ) | |
| print(f"β Robot trial completed!") | |
| print(f" Success: {robot_success}") | |
| print(f" Final specs: {robot_specs}") | |
| # Test Drone Design | |
| print(f"\nπ Testing Drone Design...") | |
| drone_success, drone_specs = main_orchestrator_enhanced.console_design_vehicle_for_obstacle( | |
| vehicle_type='drone', | |
| user_task_description=f'Design a drone that can pass the 5cm high obstacle - Session {timestamp}' | |
| ) | |
| print(f"β Drone trial completed!") | |
| print(f" Success: {drone_success}") | |
| print(f" Final specs: {drone_specs}") | |
| # List new videos created | |
| print(f"\nπΉ VIDEO RECORDING RESULTS:") | |
| new_videos = [f for f in os.listdir("outputs") if f.endswith('.gif')] | |
| new_count = len(new_videos) - len(existing_videos) | |
| print(f"Total videos now: {len(new_videos)} files (+{new_count} new)") | |
| # Show newest videos (those created in this session) | |
| newest_videos = sorted([f for f in new_videos if f not in existing_videos]) | |
| if newest_videos: | |
| print(f"\n㪠NEW VIDEOS CREATED:") | |
| for video in newest_videos: | |
| file_path = os.path.join("outputs", video) | |
| file_size = os.path.getsize(file_path) | |
| print(f" β’ {video} ({file_size:,} bytes)") | |
| # Check JSON files | |
| json_files = [f for f in os.listdir(".") if f.startswith("best_") and f.endswith(".json")] | |
| latest_json = sorted(json_files)[-2:] if len(json_files) >= 2 else json_files | |
| if latest_json: | |
| print(f"\nπ LATEST JSON RESULTS:") | |
| for json_file in latest_json: | |
| print(f" β’ {json_file}") | |
| print(f"\nπ― TRIAL SESSION {timestamp} COMPLETED SUCCESSFULLY!") | |
| print(f" Robot moved: {robot_success}") | |
| print(f" Drone moved: {drone_success}") | |
| print(f" Videos created: {new_count}") | |
| print(f" No existing videos were overridden β ") | |
| return { | |
| "timestamp": timestamp, | |
| "robot_success": robot_success, | |
| "drone_success": drone_success, | |
| "videos_created": new_count, | |
| "newest_videos": newest_videos | |
| } | |
| except Exception as e: | |
| print(f"β Error during trial recording: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return None | |
| if __name__ == "__main__": | |
| result = record_trial_videos() | |
| if result: | |
| print(f"\nπ FINAL SUMMARY:") | |
| print(f"Session: {result['timestamp']}") | |
| print(f"Robot performance: {'β Success' if result['robot_success'] else 'β Failed'}") | |
| print(f"Drone performance: {'β Success' if result['drone_success'] else 'β Failed'}") | |
| print(f"Videos recorded: {result['videos_created']}") | |
| print(f"All videos preserved! π¬") | |
| else: | |
| print("β Trial recording failed") |