-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
106 lines (85 loc) · 3.43 KB
/
Copy pathmakefile
File metadata and controls
106 lines (85 loc) · 3.43 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
# Makefile for Two-Stage RAG System
# Help target: Lists all make commands
help:
@echo "Usage: make <target>"
@echo ""
@echo "Available targets:"
@echo " install Set up virtual environment and install requirements"
@echo " install-dev Set up virtual environment and install development requirements"
@echo " install-cloud Set up virtual environment and install cloud deployment requirements"
@echo ""
@echo " export-local Export requirements-local.txt (with llama-cpp-python)"
@echo " export-cloud Export requirements.txt (without llama-cpp-python)"
@echo ""
@echo " run Run Streamlit app (frontend/app.py)"
@echo ""
@echo " lint Lint backend and frontend using Ruff"
@echo " format Auto-format code using Black"
@echo " test Run unit tests with pytest"
@echo ""
@echo " docker-build Build Docker image"
@echo " docker-run Run Docker container"
@echo ""
@echo " clean Remove __pycache__, .pyc files, and virtual environment"
IMAGE_NAME := two-stage-conrag
IMAGE_TAG := latest
# Phony targets: These targets are not files, so make will always run them
.PHONY: help run install-dev install install-cloud lint format test clean export-local export-cloud docker-build docker-run docker-stop
# Launch the Streamlit UI inside Poetry's venv
run:
poetry run streamlit run frontend/app.py
# Create venv & install all dependencies (including dev)
install-dev:
@echo "Installing all dependencies (dev + prod) via Poetry"
poetry config virtualenvs.in-project true --local
poetry install --with local
# Create venv & install only production dependencies
install:
@echo "Installing production dependencies (including llama-cpp-python)"
poetry config virtualenvs.in-project true --local
poetry install --without dev --with local
# Create venv & install for cloud deployment (without llama-cpp-python)
install-cloud:
@echo "Installing dependencies for cloud deployment (without llama-cpp-python)"
poetry config virtualenvs.in-project true --local
poetry install --without dev --without local --with cloud
# Code linting (using Ruff inside the venv)
lint:
poetry run ruff check backend frontend scripts --fix
# Auto-format with Black
format:
poetry run black backend frontend scripts
# Run all unit tests with pytest + coverage
test:
@echo "Running tests with pytest…"
poetry run pytest \
--strict-markers \
--tb=short \
--disable-warnings \
--maxfail=1 \
--cov=backend \
--cov-report=term-missing
# Export requirements.txt
export-local:
@echo "Exporting requirements for local deployment (with llama-cpp-python)"
poetry export -f requirements.txt --output requirements-local.txt --without-hashes --with local
export-cloud:
@echo "Exporting requirements for cloud deployment (with pysqlite3-binary, without llama-cpp-python)"
poetry export -f requirements.txt --output requirements.txt --without-hashes --without local --with cloud
# Docker-related targets
docker-build:
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
docker-run:
docker run --rm \
--env-file .env \
-p 8501:8501 \
$(IMAGE_NAME):$(IMAGE_TAG)
docker-stop:
@docker ps -q --filter ancestor=$(IMAGE_NAME):$(IMAGE_TAG) | xargs -r docker stop
# Clean pyc, cache, logs, etc.
clean:
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type f -name "*.pyc" -delete
rm -rf .pytest_cache .ruff_cache .mypy_cache
rm -rf .venv
@echo "Cleaned up cache files and virtual environment"