|
1 | | -.PHONY: all build clean test docker-build podman-build docker-run podman-run |
| 1 | +.PHONY: all build clean test docker-build podman-build docker-run podman-run start-milvus stop-milvus restart-milvus milvus-status clean-milvus test-milvus-cache test-semantic-router-milvus help |
2 | 2 |
|
3 | 3 | # Default target |
4 | 4 | all: build |
5 | 5 |
|
| 6 | +# Help target |
| 7 | +help: |
| 8 | + @echo "Available targets:" |
| 9 | + @echo " Build targets:" |
| 10 | + @echo " all - Build everything (default)" |
| 11 | + @echo " build - Build Rust library and Go router" |
| 12 | + @echo " rust - Build only the Rust library" |
| 13 | + @echo " build-router - Build only the Go router" |
| 14 | + @echo " clean - Clean build artifacts" |
| 15 | + @echo "" |
| 16 | + @echo " Run targets:" |
| 17 | + @echo " run-router - Run the router (CONFIG_FILE=config/config.yaml)" |
| 18 | + @echo " run-envoy - Run Envoy proxy" |
| 19 | + @echo "" |
| 20 | + @echo " Test targets:" |
| 21 | + @echo " test - Run all tests" |
| 22 | + @echo " test-binding - Test candle-binding" |
| 23 | + @echo " test-semantic-router - Test semantic router" |
| 24 | + @echo " test-category-classifier - Test category classifier" |
| 25 | + @echo " test-pii-classifier - Test PII classifier" |
| 26 | + @echo " test-jailbreak-classifier - Test jailbreak classifier" |
| 27 | + @echo "" |
| 28 | + @echo " Milvus targets (CONTAINER_RUNTIME=docker|podman):" |
| 29 | + @echo " start-milvus - Start Milvus container for testing" |
| 30 | + @echo " stop-milvus - Stop and remove Milvus container" |
| 31 | + @echo " restart-milvus - Restart Milvus container" |
| 32 | + @echo " milvus-status - Check Milvus container status" |
| 33 | + @echo " clean-milvus - Stop container and clean data" |
| 34 | + @echo " test-milvus-cache - Test cache with Milvus backend" |
| 35 | + @echo " test-semantic-router-milvus - Test router with Milvus cache" |
| 36 | + @echo " Example: CONTAINER_RUNTIME=podman make start-milvus" |
| 37 | + @echo "" |
| 38 | + @echo " Demo targets:" |
| 39 | + @echo " test-auto-prompt-reasoning - Test reasoning mode" |
| 40 | + @echo " test-auto-prompt-no-reasoning - Test normal mode" |
| 41 | + @echo " test-pii - Test PII detection" |
| 42 | + @echo " test-prompt-guard - Test jailbreak detection" |
| 43 | + @echo " test-tools - Test tool auto-selection" |
| 44 | + @echo "" |
| 45 | + @echo " Documentation targets:" |
| 46 | + @echo " docs-dev - Start documentation dev server" |
| 47 | + @echo " docs-build - Build documentation" |
| 48 | + @echo " docs-serve - Serve built documentation" |
| 49 | + @echo " docs-clean - Clean documentation artifacts" |
| 50 | + @echo "" |
| 51 | + @echo " Environment variables:" |
| 52 | + @echo " CONTAINER_RUNTIME - Container runtime (docker|podman, default: docker)" |
| 53 | + @echo " CONFIG_FILE - Config file path (default: config/config.yaml)" |
| 54 | + @echo " VLLM_ENDPOINT - vLLM endpoint URL for testing" |
| 55 | + @echo "" |
| 56 | + @echo " Usage examples:" |
| 57 | + @echo " make start-milvus # Use Docker (default)" |
| 58 | + @echo " CONTAINER_RUNTIME=podman make start-milvus # Use Podman" |
| 59 | + @echo " CONFIG_FILE=custom.yaml make run-router # Use custom config" |
| 60 | + |
| 61 | +# Container runtime (docker or podman) |
| 62 | +CONTAINER_RUNTIME ?= docker |
| 63 | + |
6 | 64 | # vLLM env var |
7 | 65 | VLLM_ENDPOINT ?= |
8 | 66 |
|
|
30 | 88 | build-router: rust |
31 | 89 | @echo "Building router..." |
32 | 90 | @mkdir -p bin |
33 | | - @cd src/semantic-router && go build -o ../../bin/router cmd/main.go |
| 91 | + @cd src/semantic-router && go build --tags=milvus -o ../../bin/router cmd/main.go |
34 | 92 |
|
35 | 93 | # Config file path with default |
36 | 94 | CONFIG_FILE ?= config/config.yaml |
@@ -104,9 +162,12 @@ test-jailbreak-classifier: rust |
104 | 162 | cd src/training/prompt_guard_fine_tuning && CGO_ENABLED=1 go run jailbreak_classifier_verifier.go |
105 | 163 |
|
106 | 164 | # Unit test semantic-router |
| 165 | +# By default, Milvus tests are skipped. To enable them, set SKIP_MILVUS_TESTS=false |
| 166 | +# Example: make test-semantic-router SKIP_MILVUS_TESTS=false |
107 | 167 | test-semantic-router: build-router |
108 | 168 | @echo "Testing semantic-router..." |
109 | 169 | @export LD_LIBRARY_PATH=${PWD}/candle-binding/target/release && \ |
| 170 | + export SKIP_MILVUS_TESTS=$${SKIP_MILVUS_TESTS:-true} && \ |
110 | 171 | cd src/semantic-router && CGO_ENABLED=1 go test -v ./... |
111 | 172 |
|
112 | 173 | # Test the Rust library and the Go binding |
@@ -195,6 +256,65 @@ download-models: |
195 | 256 | hf download LLM-Semantic-Router/pii_classifier_modernbert-base_presidio_token_model --local-dir models/pii_classifier_modernbert-base_presidio_token_model; \ |
196 | 257 | fi |
197 | 258 |
|
| 259 | +# Milvus container management |
| 260 | +start-milvus: |
| 261 | + @echo "Starting Milvus container for testing with $(CONTAINER_RUNTIME)..." |
| 262 | + @mkdir -p /tmp/milvus-data |
| 263 | + @$(CONTAINER_RUNTIME) run -d \ |
| 264 | + --name milvus-semantic-cache \ |
| 265 | + --security-opt seccomp:unconfined \ |
| 266 | + -e ETCD_USE_EMBED=true \ |
| 267 | + -e ETCD_DATA_DIR=/var/lib/milvus/etcd \ |
| 268 | + -e ETCD_CONFIG_PATH=/milvus/configs/advanced/etcd.yaml \ |
| 269 | + -e COMMON_STORAGETYPE=local \ |
| 270 | + -e CLUSTER_ENABLED=false \ |
| 271 | + -p 19530:19530 \ |
| 272 | + -p 9091:9091 \ |
| 273 | + -v /tmp/milvus-data:/var/lib/milvus \ |
| 274 | + milvusdb/milvus:v2.3.3 \ |
| 275 | + milvus run standalone |
| 276 | + @echo "Waiting for Milvus to be ready..." |
| 277 | + @sleep 15 |
| 278 | + @echo "Milvus should be available at localhost:19530" |
| 279 | + |
| 280 | +stop-milvus: |
| 281 | + @echo "Stopping Milvus container..." |
| 282 | + @$(CONTAINER_RUNTIME) stop milvus-semantic-cache || true |
| 283 | + @$(CONTAINER_RUNTIME) rm milvus-semantic-cache || true |
| 284 | + @sudo rm -rf /tmp/milvus-data || true |
| 285 | + @echo "Milvus container stopped and removed" |
| 286 | + |
| 287 | +restart-milvus: stop-milvus start-milvus |
| 288 | + |
| 289 | +milvus-status: |
| 290 | + @echo "Checking Milvus container status..." |
| 291 | + @if $(CONTAINER_RUNTIME) ps --filter "name=milvus-semantic-cache" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -q milvus-semantic-cache; then \ |
| 292 | + echo "Milvus container is running:"; \ |
| 293 | + $(CONTAINER_RUNTIME) ps --filter "name=milvus-semantic-cache" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"; \ |
| 294 | + else \ |
| 295 | + echo "Milvus container is not running"; \ |
| 296 | + echo "Run 'make start-milvus' to start it"; \ |
| 297 | + fi |
| 298 | + |
| 299 | +clean-milvus: stop-milvus |
| 300 | + @echo "Cleaning up Milvus data..." |
| 301 | + @sudo rm -rf milvus-data || rm -rf milvus-data |
| 302 | + @echo "Milvus data directory cleaned" |
| 303 | + |
| 304 | +# Test semantic cache with Milvus backend |
| 305 | +test-milvus-cache: start-milvus rust |
| 306 | + @echo "Testing semantic cache with Milvus backend..." |
| 307 | + @export LD_LIBRARY_PATH=$${PWD}/candle-binding/target/release && \ |
| 308 | + cd src/semantic-router && CGO_ENABLED=1 go test -tags=milvus -v ./pkg/cache/ |
| 309 | + @echo "Consider running 'make stop-milvus' when done testing" |
| 310 | + |
| 311 | +# Test semantic-router with Milvus enabled |
| 312 | +test-semantic-router-milvus: build-router start-milvus |
| 313 | + @echo "Testing semantic-router with Milvus cache backend..." |
| 314 | + @export LD_LIBRARY_PATH=$${PWD}/candle-binding/target/release && \ |
| 315 | + cd src/semantic-router && CGO_ENABLED=1 go test -tags=milvus -v ./... |
| 316 | + @echo "Consider running 'make stop-milvus' when done testing" |
| 317 | + |
198 | 318 | # Documentation targets |
199 | 319 | docs-install: |
200 | 320 | @echo "Installing documentation dependencies..." |
|
0 commit comments