# Makefile for Hugging Face Spaces Project # Provides convenient commands for development, testing, and deployment .PHONY: help install test test-unit test-integration test-coverage test-fast test-slow clean lint format type-check security-check build run dev docs # Default target help: @echo "Available commands:" @echo " install - Install all dependencies" @echo " test - Run all tests" @echo " test-unit - Run unit tests only" @echo " test-integration - Run integration tests only" @echo " test-coverage - Run tests with coverage report" @echo " test-fast - Run fast tests only (exclude slow tests)" @echo " test-slow - Run slow tests only" @echo " test-parallel - Run tests in parallel" @echo " lint - Run code linting" @echo " format - Format code with black" @echo " type-check - Run type checking with mypy" @echo " security-check - Run security checks" @echo " clean - Clean up generated files" @echo " build - Build the project" @echo " run - Run the application" @echo " dev - Run in development mode" @echo " docs - Generate documentation" # Installation install: @echo "Installing dependencies..." pip install -r requirements.txt pip install -e . # Testing commands test: @echo "Running all tests..." pytest -v test-unit: @echo "Running unit tests..." pytest tests/unit/ -v -m "unit or not integration" test-integration: @echo "Running integration tests..." pytest tests/integration/ -v -m integration --runintegration test-coverage: @echo "Running tests with coverage..." pytest --cov=src --cov=. --cov-report=html --cov-report=term-missing --cov-report=xml test-fast: @echo "Running fast tests..." pytest -v -m "not slow" test-slow: @echo "Running slow tests..." pytest -v -m slow --runslow test-parallel: @echo "Running tests in parallel..." pytest -n auto -v test-watch: @echo "Running tests in watch mode..." pytest-watch -- -v test-debug: @echo "Running tests in debug mode..." pytest -v -s --pdb # Code quality commands lint: @echo "Running linting..." flake8 src/ tests/ --max-line-length=88 --extend-ignore=E203,W503 pylint src/ --rcfile=.pylintrc || true format: @echo "Formatting code..." black src/ tests/ --line-length=88 isort src/ tests/ --profile black format-check: @echo "Checking code formatting..." black src/ tests/ --check --line-length=88 isort src/ tests/ --check-only --profile black type-check: @echo "Running type checking..." mypy src/ --ignore-missing-imports --no-strict-optional security-check: @echo "Running security checks..." bandit -r src/ -f json -o reports/security-report.json || true safety check --json --output reports/safety-report.json || true # Cleanup commands clean: @echo "Cleaning up..." find . -type f -name "*.pyc" -delete find . -type d -name "__pycache__" -delete find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true rm -rf build/ dist/ .coverage htmlcov/ .pytest_cache/ .mypy_cache/ rm -rf reports/*.xml reports/*.json reports/*.html clean-cache: @echo "Cleaning cache..." rm -rf cache/ai_cache/* rm -rf .pytest_cache/ rm -rf __pycache__/ # Build and run commands build: @echo "Building project..." python setup.py build run: @echo "Running application..." python app.py dev: @echo "Running in development mode..." GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 python app.py # Development tools shell: @echo "Starting Python shell with project context..." python -i -c "import sys; sys.path.insert(0, 'src')" jupyter: @echo "Starting Jupyter notebook..." jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser # Documentation docs: @echo "Generating documentation..." sphinx-build -b html docs/ docs/_build/html/ docs-serve: @echo "Serving documentation..." python -m http.server 8000 --directory docs/_build/html/ # Database commands db-init: @echo "Initializing database..." python -c "from src.core.database_logger import DatabaseLogger; DatabaseLogger.init_database()" db-migrate: @echo "Running database migrations..." python scripts/migrate_database.py db-reset: @echo "Resetting database..." rm -f logs/application.db make db-init # Log analysis commands logs-analyze: @echo "Analyzing logs..." python scripts/log_analysis/advanced_log_analyzer.py logs-monitor: @echo "Starting log monitoring..." python scripts/log_analysis/realtime_monitor.py logs-demo: @echo "Running log analysis demo..." python scripts/log_analysis/demo.py # Performance commands profile: @echo "Running performance profiling..." python -m cProfile -o profile_results.prof app.py profile-view: @echo "Viewing profile results..." python -c "import pstats; p = pstats.Stats('profile_results.prof'); p.sort_stats('cumulative'); p.print_stats(20)" benchmark: @echo "Running benchmarks..." pytest tests/ -m performance --benchmark-only # Git hooks pre-commit: @echo "Running pre-commit checks..." make format-check make lint make type-check make test-fast pre-push: @echo "Running pre-push checks..." make test make security-check # CI/CD commands ci-test: @echo "Running CI tests..." pytest --junitxml=reports/junit.xml --cov=src --cov-report=xml --cov-report=term ci-quality: @echo "Running CI quality checks..." make lint make type-check make security-check ci-build: @echo "Running CI build..." make clean make install make ci-quality make ci-test # Docker commands (if using Docker) docker-build: @echo "Building Docker image..." docker build -t huggingface-spaces . docker-run: @echo "Running Docker container..." docker run -p 7860:7860 huggingface-spaces docker-test: @echo "Running tests in Docker..." docker run --rm huggingface-spaces make test # Utility commands check-deps: @echo "Checking for outdated dependencies..." pip list --outdated update-deps: @echo "Updating dependencies..." pip-review --local --interactive freeze-deps: @echo "Freezing current dependencies..." pip freeze > requirements-frozen.txt # Environment setup setup-dev: @echo "Setting up development environment..." python -m venv venv @echo "Activate virtual environment with: source venv/bin/activate (Linux/Mac) or venv\\Scripts\\activate (Windows)" @echo "Then run: make install" setup-hooks: @echo "Setting up git hooks..." echo "#!/bin/bash\nmake pre-commit" > .git/hooks/pre-commit echo "#!/bin/bash\nmake pre-push" > .git/hooks/pre-push chmod +x .git/hooks/pre-commit .git/hooks/pre-push # Release commands version-patch: @echo "Bumping patch version..." bump2version patch version-minor: @echo "Bumping minor version..." bump2version minor version-major: @echo "Bumping major version..." bump2version major release: @echo "Creating release..." make ci-build make version-patch git push origin main --tags # Health check health-check: @echo "Running health checks..." @echo "Python version: $$(python --version)" @echo "Pip version: $$(pip --version)" @echo "Project structure:" @find . -name "*.py" -path "./src/*" | head -10 @echo "Database status:" @ls -la logs/ 2>/dev/null || echo "No logs directory found" @echo "Cache status:" @ls -la cache/ 2>/dev/null || echo "No cache directory found" # All-in-one commands full-check: @echo "Running full project check..." make clean make install make format-check make lint make type-check make test-coverage make security-check quick-check: @echo "Running quick project check..." make format-check make test-fast