File size: 3,242 Bytes
65dc75d
a3ae041
f1f6f45
 
 
 
a3ae041
 
f1f6f45
 
 
 
 
 
 
65dc75d
 
f1f6f45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65dc75d
 
 
 
 
 
 
 
 
 
 
f1f6f45
 
 
a3ae041
f1f6f45
 
 
a3ae041
f1f6f45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3ae041
 
f1f6f45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
.PHONY: help install dev clean test format lint status run notebook docker-build docker-run requirements update

IMAGE_NAME := classify-text-with-bert-hate-speech
IMAGE_TAG := local

# Default target - show help
.DEFAULT_GOAL := help

.ONESHELL:

help:
	@echo "Project - Available Commands:"
	@echo ""
	@echo "  make install     - Install production dependencies with uv"
	@echo "  make dev         - Install development dependencies with uv"
	@echo "  make requirements- Generate requirements.txt from uv.lock"
	@echo "  make update      - Update all dependencies to latest versions"
	@echo "  make run         - Run the application (app.py)"
	@echo "  make notebook    - Launch jupyter notebook/lab"
	@echo "  make test        - Run tests (requires pytest)"
	@echo "  make format      - Format code (ruff or black if available)"
	@echo "  make lint        - Run linter (ruff if available)"
	@echo "  make clean       - Remove venv and build/test artifacts"
	@echo "  make status      - Show python version and installed packages summary"
	@echo "  make docker-build- Build a local docker image"
	@echo "  make docker-run  - Run the docker image locally"
	@echo ""

install:
	@echo "πŸ“¦ Installing production dependencies with uv..."
	uv sync --no-dev
	@echo "βœ… Production dependencies installed successfully!"

dev:
	@echo "πŸ“¦ Installing development dependencies with uv..."
	uv sync --dev
	@echo "βœ… Development dependencies installed successfully!"

requirements: update
	@echo "πŸ“ Generating requirements.txt from uv.lock..."
	uv pip compile pyproject.toml -o requirements.txt
	@echo "βœ… requirements.txt generated successfully!"

update: dev
	@echo "πŸ”„ Updating all dependencies to latest versions..."
	uv lock --upgrade
	@echo "βœ… Dependencies updated! Run 'make install' or 'make dev' to apply changes."
	@echo "πŸ’‘ Tip: Run 'make requirements' to regenerate requirements.txt"

run:
	@echo "Running app.py..."
	uv run python app.py

notebook:
	@echo "Launching Jupyter Notebook (or lab if available)..."
	uv run jupyter lab || uv run jupyter notebook

test:
	@echo "Running tests with pytest..."
	uv run pytest -q tests || true

format:
	@echo "Formatting code with ruff..."
	uv run ruff format . || true
	-uv run ruff check --fix . || true

lint:
	@echo "Running linter with ruff..."
	uv run ruff check .

status:
	@uv run python --version
	@echo "Installed packages:"
	@uv pip list

clean:
	@echo "🧹 Cleaning up build and Python artifacts..."
	-rm -rf .venv build/ dist/ *.egg-info .eggs
	-find . -type d -name "__pycache__" -exec rm -rf {} +
	-find . -type f -name "*.py[co]" -delete
	-find . -type f -name ".coverage" -delete
	-find . -type d -name ".pytest_cache" -exec rm -rf {} +
	-find . -type d -name ".ruff_cache" -exec rm -rf {} +
	-find . -type d -name ".mypy_cache" -exec rm -rf {} +
	-find . -type d -name "htmlcov" -exec rm -rf {} +
	-find . -type f -name ".DS_Store" -delete
	@echo "βœ… Cleanup completed!"

docker-build:
	@echo "Building docker image ${IMAGE_NAME}:${IMAGE_TAG} (requires Docker)"
	@docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . || true

docker-run:
	@echo "Running docker image ${IMAGE_NAME}:${IMAGE_TAG} (port 7860 forwarded)"
	@docker run --rm -p 7860:7860 ${IMAGE_NAME}:${IMAGE_TAG}