|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Development setup script for ModelSync |
| 4 | +""" |
| 5 | + |
| 6 | +import os |
| 7 | +import sys |
| 8 | +import subprocess |
| 9 | +from pathlib import Path |
| 10 | + |
| 11 | +def run_command(cmd, description): |
| 12 | + """Run a command and handle errors""" |
| 13 | + print(f"🔧 {description}...") |
| 14 | + try: |
| 15 | + result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True) |
| 16 | + print(f"✅ {description} completed successfully") |
| 17 | + return True |
| 18 | + except subprocess.CalledProcessError as e: |
| 19 | + print(f"❌ {description} failed:") |
| 20 | + print(f" Error: {e.stderr}") |
| 21 | + return False |
| 22 | + |
| 23 | +def setup_development_environment(): |
| 24 | + """Setup development environment""" |
| 25 | + print("🚀 Setting up ModelSync development environment...") |
| 26 | + |
| 27 | + # Check Python version |
| 28 | + if sys.version_info < (3, 10): |
| 29 | + print("❌ Python 3.10+ is required") |
| 30 | + sys.exit(1) |
| 31 | + |
| 32 | + print(f"✅ Python {sys.version_info.major}.{sys.version_info.minor} detected") |
| 33 | + |
| 34 | + # Install dependencies |
| 35 | + if not run_command("pip install -r requirements.txt", "Installing dependencies"): |
| 36 | + sys.exit(1) |
| 37 | + |
| 38 | + # Install development dependencies |
| 39 | + dev_deps = [ |
| 40 | + "black", |
| 41 | + "flake8", |
| 42 | + "mypy", |
| 43 | + "pre-commit" |
| 44 | + ] |
| 45 | + |
| 46 | + for dep in dev_deps: |
| 47 | + if not run_command(f"pip install {dep}", f"Installing {dep}"): |
| 48 | + print(f"⚠️ Warning: Failed to install {dep}") |
| 49 | + |
| 50 | + # Create .gitignore if it doesn't exist |
| 51 | + gitignore_path = Path(".gitignore") |
| 52 | + if not gitignore_path.exists(): |
| 53 | + gitignore_content = """# ModelSync |
| 54 | +.modelsync/ |
| 55 | +__pycache__/ |
| 56 | +*.pyc |
| 57 | +*.pyo |
| 58 | +*.pyd |
| 59 | +.Python |
| 60 | +env/ |
| 61 | +venv/ |
| 62 | +.venv/ |
| 63 | +pip-log.txt |
| 64 | +pip-delete-this-directory.txt |
| 65 | +.tox/ |
| 66 | +.coverage |
| 67 | +.coverage.* |
| 68 | +.cache |
| 69 | +nosetests.xml |
| 70 | +coverage.xml |
| 71 | +*.cover |
| 72 | +*.log |
| 73 | +.git |
| 74 | +.mypy_cache |
| 75 | +.pytest_cache |
| 76 | +.hypothesis |
| 77 | +
|
| 78 | +# IDEs |
| 79 | +.vscode/ |
| 80 | +.idea/ |
| 81 | +*.swp |
| 82 | +*.swo |
| 83 | +*~ |
| 84 | +
|
| 85 | +# OS |
| 86 | +.DS_Store |
| 87 | +.DS_Store? |
| 88 | +._* |
| 89 | +.Spotlight-V100 |
| 90 | +.Trashes |
| 91 | +ehthumbs.db |
| 92 | +Thumbs.db |
| 93 | +
|
| 94 | +# Model files (examples) |
| 95 | +*.pkl |
| 96 | +*.joblib |
| 97 | +*.h5 |
| 98 | +*.hdf5 |
| 99 | +*.pb |
| 100 | +*.onnx |
| 101 | +*.pt |
| 102 | +*.pth |
| 103 | +""" |
| 104 | + gitignore_path.write_text(gitignore_content) |
| 105 | + print("✅ Created .gitignore file") |
| 106 | + |
| 107 | + # Run tests |
| 108 | + print("\n🧪 Running tests...") |
| 109 | + if run_command("python run_tests.py", "Running tests"): |
| 110 | + print("✅ All tests passed!") |
| 111 | + else: |
| 112 | + print("⚠️ Some tests failed, but setup continues...") |
| 113 | + |
| 114 | + print("\n🎉 Development environment setup complete!") |
| 115 | + print("\nNext steps:") |
| 116 | + print("1. Initialize a repository: python modelsync/cli/main.py init") |
| 117 | + print("2. Start the API server: python modelsync/api/main.py") |
| 118 | + print("3. Run tests: python run_tests.py") |
| 119 | + |
| 120 | +if __name__ == "__main__": |
| 121 | + setup_development_environment() |
0 commit comments