CoolFace
Apppublic

WebashalarForML/scratch_chat

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
Makefile171 linesDownload Raw Back to root
1# Makefile for Chat Agent Application
2
3.PHONY: help install setup test clean run docker-build docker-run docker-dev migrate seed
4
5# Default target
6help:
7	@echo "Available commands:"
8	@echo "  install     - Install dependencies"
9	@echo "  setup       - Set up development environment"
10	@echo "  setup-prod  - Set up production environment"
11	@echo "  test        - Run tests"
12	@echo "  test-cov    - Run tests with coverage"
13	@echo "  clean       - Clean up temporary files"
14	@echo "  run         - Run development server"
15	@echo "  run-prod    - Run production server"
16	@echo "  migrate     - Run database migrations"
17	@echo "  seed        - Seed database with sample data"
18	@echo "  reset-db    - Reset database (development only)"
19	@echo "  docker-build - Build Docker image"
20	@echo "  docker-run  - Run with Docker Compose"
21	@echo "  docker-dev  - Run development environment with Docker"
22	@echo "  docker-stop - Stop Docker containers"
23	@echo "  lint        - Run code linting"
24	@echo "  format      - Format code"
25
26# Installation and setup
27install:
28	pip install --upgrade pip
29	pip install -r requirements.txt
30
31setup:
32	python scripts/setup_environment.py --environment development
33
34setup-prod:
35	python scripts/setup_environment.py --environment production
36
37setup-test:
38	python scripts/setup_environment.py --environment testing
39
40# Testing
41test:
42	python -m pytest tests/ -v
43
44test-cov:
45	python -m pytest tests/ --cov=chat_agent --cov-report=html --cov-report=term
46
47test-integration:
48	python -m pytest tests/integration/ -v
49
50test-unit:
51	python -m pytest tests/unit/ -v
52
53# Database operations
54migrate:
55	python scripts/init_db.py init --config development
56
57migrate-prod:
58	python scripts/init_db.py init --config production
59
60seed:
61	python scripts/init_db.py seed --config development
62
63reset-db:
64	python scripts/init_db.py reset --config development
65
66db-status:
67	python scripts/init_db.py status --config development
68
69# Application running
70run:
71	python app.py
72
73run-prod:
74	gunicorn --bind 0.0.0.0:5000 --workers 4 --worker-class eventlet app:app
75
76run-debug:
77	FLASK_DEBUG=True python app.py
78
79# Docker operations
80docker-build:
81	docker build -t chat-agent .
82
83docker-run:
84	docker-compose up -d
85
86docker-dev:
87	docker-compose -f docker-compose.dev.yml up -d
88
89docker-stop:
90	docker-compose down
91	docker-compose -f docker-compose.dev.yml down
92
93docker-logs:
94	docker-compose logs -f chat-agent
95
96docker-clean:
97	docker-compose down -v
98	docker system prune -f
99
100# Code quality
101lint:
102	flake8 chat_agent/ --max-line-length=100 --ignore=E203,W503
103	flake8 tests/ --max-line-length=100 --ignore=E203,W503
104
105format:
106	black chat_agent/ tests/ --line-length=100
107	isort chat_agent/ tests/
108
109type-check:
110	mypy chat_agent/ --ignore-missing-imports
111
112# Cleanup
113clean:
114	find . -type f -name "*.pyc" -delete
115	find . -type d -name "__pycache__" -delete
116	find . -type d -name "*.egg-info" -exec rm -rf {} +
117	rm -rf .coverage htmlcov/ .pytest_cache/ .mypy_cache/
118	rm -rf logs/*.log
119
120clean-all: clean
121	rm -rf venv/
122	rm -rf instance/
123	rm -rf flask_session/
124
125# Health checks
126health:
127	curl -s http://localhost:5000/health/ | python -m json.tool
128
129health-detailed:
130	curl -s http://localhost:5000/health/detailed | python -m json.tool
131
132# Development helpers
133dev-install:
134	pip install -r requirements.txt
135	pip install flask-debugtoolbar ipdb watchdog black flake8 isort mypy
136
137logs:
138	tail -f logs/chat_agent.log
139
140logs-error:
141	tail -f logs/chat_agent.log | grep ERROR
142
143# Production deployment helpers
144deploy-check:
145	@echo "Pre-deployment checklist:"
146	@echo "- [ ] Environment variables configured"
147	@echo "- [ ] Database migrations applied"
148	@echo "- [ ] SSL certificates installed"
149	@echo "- [ ] Firewall configured"
150	@echo "- [ ] Monitoring set up"
151	@echo "- [ ] Backups configured"
152
153backup-db:
154	pg_dump $(DATABASE_URL) > backups/backup_$(shell date +%Y%m%d_%H%M%S).sql
155
156restore-db:
157	@echo "Warning: This will overwrite the current database!"
158	@read -p "Enter backup file path: " backup_file; \
159	psql $(DATABASE_URL) < $$backup_file
160
161# Monitoring
162monitor:
163	watch -n 5 'curl -s http://localhost:5000/health/detailed | python -m json.tool'
164
165# Documentation
166docs:
167	@echo "Documentation available:"
168	@echo "- README.md - Project overview"
169	@echo "- docs/DEPLOYMENT.md - Deployment guide"
170	@echo "- docs/ENVIRONMENT_SETUP.md - Environment setup"
171	@echo "- .kiro/specs/multi-language-chat-agent/ - Feature specifications"