File size: 7,756 Bytes
266d7bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Makefile

# Check if .env exists
ifeq (,$(wildcard .env))
$(error .env file is missing at .env. Please create one based on .env.example)
endif

# Load environment variables from .env
include .env

.PHONY: tests mypy clean help ruff-check ruff-check-fix ruff-format ruff-format-fix all-check all-fix

#################################################################################
## Supabase Commands
#################################################################################

supabase-create: ## Create Supabase database
	@echo "Creating Supabase database..."
	uv run python src/infrastructure/supabase/create_db.py

supabase-delete: ## Delete Supabase database
	@echo "Deleting Supabase database..."
	uv run python src/infrastructure/supabase/delete_db.py

#################################################################################
## Qdrant Commands
#################################################################################

qdrant-create-collection: ## Create Qdrant collection
	@echo "Creating Qdrant collection..."
	uv run python src/infrastructure/qdrant/create_collection.py

qdrant-delete-collection: ## Delete Qdrant collection
	@echo "Deleting Qdrant collection..."
	uv run python src/infrastructure/qdrant/delete_collection.py

qdrant-create-index: ## Create Qdrant index
	@echo "Updating HNSW and creating Qdrant indexes..."
	uv run python src/infrastructure/qdrant/create_indexes.py

qdrant-ingest-from-sql: ## Ingest data from SQL to Qdrant
	@echo "Ingesting data from SQL to Qdrant..."
	uv run python src/infrastructure/qdrant/ingest_from_sql.py
	@echo "Data ingestion complete."

#################################################################################
## Prefect Flow Commands
#################################################################################

ingest-rss-articles-flow: ## Ingest RSS articles flow
	@echo "Running ingest RSS articles flow..."
	uv run python src/pipelines/flows/rss_ingestion_flow.py
	@echo "Ingest RSS articles flow completed."

ingest-embeddings-flow: ## Ingest embeddings flow
	@echo "Running ingest embeddings flow..."
	$(if $(FROM_DATE), \
		uv run python src/pipelines/flows/embeddings_ingestion_flow.py --from-date $(FROM_DATE), \
		uv run python src/pipelines/flows/embeddings_ingestion_flow.py)
	@echo "Ingest embeddings flow completed."

#################################################################################
## Prefect Deployment Commands
#################################################################################
deploy-cloud-flows: ## Deploy Prefect flows to Prefect Cloud
	@echo "Deploying Prefect flows to Prefect Cloud..."
	prefect deploy --prefect-file prefect-cloud.yaml
	@echo "Prefect Cloud deployment complete."

deploy-local-flows: ## Deploy Prefect flows to Prefect Local Server
	@echo "Deploying Prefect flows to Prefect Local Server..."
	prefect deploy --prefect-file prefect-local.yaml
	@echo "Prefect Local deployment complete."

#################################################################################
## Recreate Commands
#################################################################################

recreate-supabase: supabase-delete supabase-create ## Recreate Supabase resources

recreate-qdrant: qdrant-delete-collection qdrant-create-collection ## Recreate Qdrant resources

recreate-all: supabase-delete qdrant-delete-collection supabase-create qdrant-create-collection ## Recreate Qdrant and Supabase resources

#################################################################################
## FastAPI Commands
#################################################################################

run-api: ## Run FastAPI application
	@echo "Starting FastAPI application..."
	uv run src/api/main.py
	@echo "FastAPI application stopped."

#################################################################################
## Gradio Commands
#################################################################################

run-gradio: ## Run Gradio application
	@echo "Starting Gradio application..."
	uv run frontend/app.py
	@echo "Gradio application stopped."

#################################################################################
## Testing Commands
#################################################################################

unit-tests: ## Run all unit tests
	@echo "Running all unit tests..."
	uv run pytest tests/unit
	@echo "All unit tests completed."

integration-tests: ## Run all integration tests
	@echo "Running all integration tests..."
	uv run pytest tests/integration
	@echo "All integration tests completed."

all-tests: ## Run all tests
	@echo "Running all tests..."
	uv run pytest
	@echo "All tests completed."

################################################################################
## Pre-commit Commands
################################################################################

pre-commit-run: ## Run pre-commit hooks
	@echo "Running pre-commit hooks..."
	pre-commit run --all-files
	@echo "Pre-commit checks complete."

################################################################################
## Linting
################################################################################

# Linting (just checks)
ruff-check: ## Check code lint violations (--diff to show possible changes)
	@echo "Checking Ruff formatting..."
	uv run ruff check .
	@echo "Ruff lint checks complete."

ruff-check-fix: ## Auto-format code using Ruff
	@echo "Formatting code with Ruff..."
	uv run ruff check . --fix --exit-non-zero-on-fix
	@echo "Formatting complete."

################################################################################
## Formatting
################################################################################

# Formatting (just checks)
ruff-format: ## Check code format violations (--diff to show possible changes)
	@echo "Checking Ruff formatting..."
	uv run ruff format . --check
	@echo "Ruff format checks complete."

ruff-format-fix: ## Auto-format code using Ruff
	@echo "Formatting code with Ruff..."
	uv run ruff format .
	@echo "Formatting complete."

#################################################################################
## Static Type Checking
#################################################################################

mypy: ## Run MyPy static type checker
	@echo "Running MyPy static type checker..."
	uv run mypy
	@echo "MyPy static type checker complete."

################################################################################
## Cleanup
################################################################################

clean: ## Clean up cached generated files
	@echo "Cleaning up generated files..."
	find . -type d -name "__pycache__" -exec rm -rf {} +
	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 f -name "*.pyc" -delete
	@echo "Cleanup complete."

################################################################################
## Composite Commands
################################################################################

all-check: ruff-format ruff-check clean ## Run all: linting, formatting and type checking

all-fix: ruff-format-fix ruff-check-fix mypy clean ## Run all fix: auto-formatting and linting fixes

################################################################################
## Help
################################################################################

help: ## Display this help message
	@echo "Default target: $(.DEFAULT_GOAL)"
	@echo "Available targets:"
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help