File size: 3,341 Bytes
3d6cc8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Makefile for GOXY ML/AI Service

.PHONY: help install install-dev setup test lint format clean run docker-build docker-up docker-down migration

# Default target
help:
	@echo "GOXY ML/AI Service - Available Commands:"
	@echo ""
	@echo "  make install         - Install production dependencies"
	@echo "  make install-dev     - Install development dependencies"
	@echo "  make setup           - Complete development setup"
	@echo "  make test            - Run tests"
	@echo "  make test-cov        - Run tests with coverage"
	@echo "  make lint            - Run linters"
	@echo "  make format          - Format code with black and ruff"
	@echo "  make clean           - Clean generated files"
	@echo "  make run             - Run development server"
	@echo "  make docker-build    - Build Docker image"
	@echo "  make docker-up       - Start Docker containers"
	@echo "  make docker-down     - Stop Docker containers"
	@echo "  make migration       - Create database migration"
	@echo "  make upgrade         - Apply database migrations"
	@echo ""

# Install production dependencies
install:
	pip install --upgrade pip setuptools wheel
	pip install -r requirements.txt

# Install development dependencies
install-dev:
	pip install --upgrade pip setuptools wheel
	pip install -r requirements-dev.txt
	pre-commit install

# Complete development setup
setup: install-dev
	@echo "Setting up development environment..."
	mkdir -p logs data/models data/datasets data/cache data/uploads
	cp -n .env.example .env || true
	@echo "✓ Development environment ready!"
	@echo "⚠️  Please edit .env file with your configuration"

# Run tests
test:
	pytest -v -m "not slow"

# Run tests with coverage
test-cov:
	pytest --cov=app --cov-report=html --cov-report=term-missing

# Run all linters
lint:
	@echo "Running linters..."
	ruff check app/ tests/
	mypy app/
	black --check app/ tests/
	@echo "✓ All linters passed!"

# Format code
format:
	@echo "Formatting code..."
	black app/ tests/
	ruff check --fix app/ tests/
	@echo "✓ Code formatted!"

# Clean generated files
clean:
	@echo "Cleaning generated files..."
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete
	find . -type f -name "*.pyo" -delete
	find . -type f -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
	rm -rf .pytest_cache .coverage htmlcov dist build .ruff_cache .mypy_cache
	@echo "✓ Cleanup complete!"

# Run development server
run:
	uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 --log-level info

# Build Docker image
docker-build:
	docker-compose build

# Start Docker containers
docker-up:
	docker-compose up -d
	@echo "✓ Containers started!"
	@echo "  API: http://localhost:8000"
	@echo "  Docs: http://localhost:8000/docs"
	@echo "  Database: localhost:5432"
	@echo "  Redis: localhost:6379"

# Stop Docker containers
docker-down:
	docker-compose down

# Create database migration
migration:
	@read -p "Enter migration message: " msg; \
	alembic revision --autogenerate -m "$$msg"

# Apply database migrations
upgrade:
	alembic upgrade head

# Downgrade database
downgrade:
	alembic downgrade -1

# Show migration history
history:
	alembic history

# Check code security
security:
	bandit -r app/ -c pyproject.toml

# Run pre-commit on all files
pre-commit:
	pre-commit run --all-files