Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| NFL Training Data Generator - Interactive Runner | |
| """ | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| def main(): | |
| print("π NFL Training Data Generator") | |
| print("=" * 50) | |
| print("Choose processing mode:") | |
| print("1. Test with 10 random rules (recommended for first run)") | |
| print("2. Process ALL rules in the file") | |
| print("3. Custom number of rules") | |
| print("4. Exit") | |
| while True: | |
| choice = input("\nEnter your choice (1-4): ").strip() | |
| if choice == "1": | |
| # 10 random rules | |
| cmd = [ | |
| sys.executable, | |
| "generate_nfl_training_data.py", | |
| "sample_2024_nfl_rulebook.csv", | |
| "--sample", "10", | |
| "--output-dir", "output_10_random" | |
| ] | |
| print("π― Processing 10 random rules...") | |
| break | |
| elif choice == "2": | |
| # All rules | |
| cmd = [ | |
| sys.executable, | |
| "generate_nfl_training_data.py", | |
| "sample_2024_nfl_rulebook.csv", | |
| "--output-dir", "output_full" | |
| ] | |
| print("π― Processing ALL rules...") | |
| break | |
| elif choice == "3": | |
| # Custom number | |
| try: | |
| num_rules = int(input("Enter number of random rules to process: ")) | |
| cmd = [ | |
| sys.executable, | |
| "generate_nfl_training_data.py", | |
| "sample_2024_nfl_rulebook.csv", | |
| "--sample", str(num_rules), | |
| "--output-dir", f"output_{num_rules}_random" | |
| ] | |
| print(f"π― Processing {num_rules} random rules...") | |
| break | |
| except ValueError: | |
| print("β Please enter a valid number") | |
| continue | |
| elif choice == "4": | |
| print("π Goodbye!") | |
| return 0 | |
| else: | |
| print("β Please enter 1, 2, 3, or 4") | |
| continue | |
| # Run the command | |
| try: | |
| print(f"\nπ Running command: {' '.join(cmd)}") | |
| print("-" * 50) | |
| result = subprocess.run(cmd, check=True) | |
| print("\nβ Generation completed successfully!") | |
| # Show generated files | |
| output_dir = Path(cmd[cmd.index("--output-dir") + 1]) | |
| if output_dir.exists(): | |
| files = list(output_dir.glob("*.jsonl")) | |
| if files: | |
| print(f"\nπ Generated files:") | |
| for file in files: | |
| print(f" - {file}") | |
| # Show file size and line count | |
| with open(file, 'r') as f: | |
| lines = f.readlines() | |
| print(f" π {len(lines)} training examples") | |
| # Show sample content | |
| if lines: | |
| print(f" π Sample content:") | |
| sample_line = lines[0][:150] + "..." if len(lines[0]) > 150 else lines[0] | |
| print(f" {sample_line}") | |
| return 0 | |
| except subprocess.CalledProcessError as e: | |
| print(f"\nβ Generation failed with exit code {e.returncode}") | |
| return 1 | |
| except KeyboardInterrupt: | |
| print(f"\nβ οΈ Generation interrupted by user") | |
| return 1 | |
| except Exception as e: | |
| print(f"\nβ Unexpected error: {e}") | |
| return 1 | |
| if __name__ == "__main__": | |
| exit(main()) |