-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (131 loc) · 3.88 KB
/
Copy pathMakefile
File metadata and controls
159 lines (131 loc) · 3.88 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# RLaaS Platform Makefile
.PHONY: help install dev test lint format clean build deploy docs
# Default target
help:
@echo "RLaaS Platform Development Commands"
@echo "=================================="
@echo "install Install dependencies"
@echo "dev Start development environment"
@echo "test Run tests"
@echo "lint Run linting"
@echo "format Format code"
@echo "clean Clean build artifacts"
@echo "build Build Docker images"
@echo "deploy Deploy to Kubernetes"
@echo "docs Build documentation"
@echo "setup Initial project setup"
# Install dependencies
install:
pip install -r requirements.txt
pip install -e ".[dev]"
pre-commit install
# Start development environment
dev:
docker-compose up -d
@echo "Development environment started!"
@echo "API Gateway: http://localhost:8000"
@echo "Web Console: http://localhost:8080"
@echo "MLflow: http://localhost:5000"
@echo "Grafana: http://localhost:3000"
# Stop development environment
dev-stop:
docker-compose down
# Run tests
test:
pytest tests/ -v --cov=src --cov-report=html --cov-report=term
# Run linting
lint:
flake8 src/ tests/
mypy src/
black --check src/ tests/
# Format code
format:
black src/ tests/
isort src/ tests/
# Clean build artifacts
clean:
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type d -name "*.egg-info" -exec rm -rf {} +
rm -rf build/
rm -rf dist/
rm -rf htmlcov/
rm -rf .coverage
rm -rf .pytest_cache/
rm -rf .mypy_cache/
# Build Docker images
build:
docker build -t rlaas:latest .
docker build -t rlaas:dev --target development .
# Deploy to Kubernetes
deploy:
./scripts/deploy.sh
# Deploy to local development
deploy-local:
./scripts/deploy.sh --environment local
# Build documentation
docs:
mkdocs build
# Serve documentation locally
docs-serve:
mkdocs serve
# Initial project setup
setup:
cp .env.example .env
@echo "Please edit .env file with your configuration"
@echo "Then run 'make install' to install dependencies"
# Database migrations
migrate:
alembic upgrade head
# Create new migration
migration:
alembic revision --autogenerate -m "$(MSG)"
# Reset database
reset-db:
docker-compose exec postgres psql -U rlaas -d rlaas -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
make migrate
# Run security checks
security:
bandit -r src/
safety check
# Run performance tests
perf-test:
locust -f tests/performance/locustfile.py --host=http://localhost:8000
# Generate API documentation
api-docs:
python -c "import uvicorn; uvicorn.run('rlaas.api.main:app', host='0.0.0.0', port=8000)" &
sleep 5
curl http://localhost:8000/openapi.json > docs/api/openapi.json
pkill -f uvicorn
# Backup data
backup:
kubectl exec -n rlaas-system deployment/postgresql -- pg_dump -U rlaas rlaas > backup_$(shell date +%Y%m%d_%H%M%S).sql
# Restore data
restore:
kubectl exec -i -n rlaas-system deployment/postgresql -- psql -U rlaas -d rlaas < $(FILE)
# Monitor logs
logs:
kubectl logs -f -n rlaas-system -l app.kubernetes.io/name=rlaas
# Port forward services
port-forward:
kubectl port-forward -n rlaas-system svc/rlaas-api-gateway 8000:80 &
kubectl port-forward -n rlaas-system svc/rlaas-web-console 8080:80 &
kubectl port-forward -n monitoring svc/prometheus-grafana 3000:80 &
@echo "Services forwarded:"
@echo "API Gateway: http://localhost:8000"
@echo "Web Console: http://localhost:8080"
@echo "Grafana: http://localhost:3000"
# Check code quality
quality: lint test security
@echo "Code quality checks completed!"
# Full CI pipeline
ci: clean install quality build
@echo "CI pipeline completed successfully!"
# Release preparation
release:
@echo "Preparing release..."
python scripts/bump_version.py
git add .
git commit -m "Bump version for release"
git tag v$(shell python -c "import src.rlaas; print(src.rlaas.__version__)")
@echo "Release prepared. Push with: git push origin main --tags"