-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
219 lines (188 loc) · 6.81 KB
/
Taskfile.yml
File metadata and controls
219 lines (188 loc) · 6.81 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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
version: '3'
tasks:
default:
desc: Displays this help menu listing all available commands
silent: true
cmds:
- task --list
# ==========================================
# CODE QUALITY & LINTING
# ==========================================
qa:lint-fix:
desc: QA - Run Ruff linter and automatically fix fixable issues
cmds:
- uv run ruff check --fix .
qa:format:
desc: QA - Run Ruff formatter to auto-format Python code
cmds:
- uv run ruff format .
qa:check:
desc: QA - Run local workflow (Fix lint issues, format, and check types)
cmds:
- task: qa:lint-fix
- task: qa:format
qa:ci-check:
desc: QA - Run all checks strictly for CI
cmds:
- uv run ruff check .
- uv run ruff format --check .
# ==========================================
# ENVIRONMENT
# ==========================================
env:install:
desc: ENV - Installs project dependencies and sets up the development environment
cmds:
- uv sync
- uv run pre-commit install
# ==========================================
# MLOPS & DATA PIPELINE
# ==========================================
ml:fetch:
desc: ML - Downloads raw data and verifies integrity using SHA-256
cmds:
- uv run python -m src.data.ingestion
ml:preprocess:
desc: ML - Splits train/test sets and applies preprocessing without data leakage
deps: [ml:fetch]
cmds:
- uv run python -m src.features.preprocessing
ml:train:
desc: ML - Trains the champion model (XGBoost) and exports it to ONNX format
deps: [ml:preprocess]
cmds:
- uv run python -m src.models.trainer
ml:pipeline:
desc: ML - Runs the complete end-to-end machine learning pipeline
deps: [ml:train]
silent: true
cmds:
- 'echo "SUCCESS: Full Machine Learning Pipeline Completed!"'
ml:clean:
desc: ML - Wipes all generated datasets, scaled files, and trained models
silent: true
ignore_error: true
cmds:
- rm -f data/raw/creditcard.csv
- rm -f data/processed/*.csv
- rm -f models/*.joblib
- rm -f models/*.onnx
- echo "All generated data and models have been wiped clean."
# ==========================================
# TESTS
# ==========================================
test:run:
desc: TEST - Run all unit and integration tests in the tests directory
cmds:
- pytest tests/
test:load-health:
desc: TEST - Run OHA load test for 1 minute with 250 concurrent workers on health endpoint
cmds:
- oha -c 250 -z 1m http://localhost:8000/
# ==========================================
# DOCKER
# ==========================================
# ----- START PART -----
docker:up:
desc: Docker - Builds images and starts infrastructure containers in the background
cmds:
- docker compose up --build -d
- cmd: echo "All infrastructure containers are successfully running."
silent: true
- cmd: 'echo "API Gateway: http://localhost:8000"'
silent: true
- cmd: 'echo "Redpanda Console: http://localhost:8080"'
silent: true
# ----- OFF PART -----
docker:off:
desc: Docker - Sequentially stops containers and clears all unused images
cmds:
- task: docker:down
- task: docker:clear
- cmd: echo "Docker environment has been completely shut down and cleaned."
silent: true
docker:down:
desc: Docker - Stops and removes Docker containers, networks, and volumes
cmds:
- docker compose down
docker:clear:
desc: Docker - Forcefully removes all unused and dangling images to free up space
cmds:
- docker image prune -a -f
# ----- STATUS PART -----
docker:ps:
desc: Docker - Shows the current status of running containers
cmds:
- docker compose ps
# ==========================================
# KUBERNETES
# ==========================================
# ----- START PART -----
k8s:start:
desc: Kubernetes - One-click local environment setup! Creates cluster, builds images, and deploys the stack.
cmds:
- task: _cluster-create
- task: k8s:build-load
- task: k8s:up
- cmd: echo "Kubernetes cluster is successfully provisioned and workloads are deployed!"
silent: true
- cmd: echo "Run 'task k8s:status' to monitor pod startup."
silent: true
- cmd: echo "Once all pods are 'Running', execute 'task k8s:forward' in a new terminal."
silent: true
_cluster-create:
desc: Internal task to create multi-node cluster and configure workload isolation
internal: true
cmds:
- kind create cluster --config k8s/config/kind-config.yaml
# Node 1: Dedicated for Stateful Storage (Postgres, Redis, Redpanda)
- kubectl label nodes kind-worker role=storage --overwrite
# Node 2: Dedicated & Tainted for AI Inference (Consumer)
- kubectl taint nodes kind-worker2 dedicated=ai-inference:NoSchedule --overwrite=true
- kubectl label nodes kind-worker2 role=ai-inference --overwrite
k8s:build-load:
desc: Kubernetes - Build local images and load all dependencies into the Kind cluster
cmds:
- docker build -f docker/api/Dockerfile -t sentinel-api:1.0.0 .
- docker build -f docker/consumer/Dockerfile -t sentinel-consumer:1.0.0 .
- kind load docker-image sentinel-api:1.0.0 --name kind
- kind load docker-image sentinel-consumer:1.0.0 --name kind
k8s:up:
desc: Kubernetes - Deploys entire infrastructure and application stack sequentially
cmds:
- kubectl apply -f k8s/infrastructure/
- kubectl apply -f k8s/apps/
# ----- OFF PART -----
k8s:off:
desc: Kubernetes - Sequentially removes the stack and completely destroys the cluster
cmds:
- task: k8s:down
- task: k8s:clean
- cmd: echo "Kubernetes environment has been completely shut down and cleaned."
silent: true
k8s:down:
desc: Kubernetes - Remove the Sentinel stack from Kubernetes
cmds:
- kubectl delete -f k8s/apps/ --ignore-not-found
- kubectl delete -f k8s/infrastructure/ --ignore-not-found
k8s:clean:
desc: Kubernetes - Completely destroys the local Kind cluster and all its data
cmds:
- kind delete cluster
- cmd: echo "Kubernetes cluster and all associated data have been completely wiped clean."
silent: true
# ----- STATUS PART -----
k8s:status:
desc: Kubernetes - Check the current status of all Kubernetes pods
cmd: kubectl get pods -o wide
# ----- FORWARD PART -----
k8s:forward:
desc: Kubernetes - Forward all necessary K8s ports in parallel
deps:
- task: _forward-api
- task: _forward-console
_forward-api:
internal: true
cmd: kubectl port-forward svc/sentinel-api-service 8000:8000
_forward-console:
internal: true
cmd: kubectl port-forward svc/console 8080:8080