forked from spiceai/spiceai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
431 lines (362 loc) · 15.1 KB
/
Makefile
File metadata and controls
431 lines (362 loc) · 15.1 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
################################################################################
# Target: all #
################################################################################
.PHONY: all
all: build
.PHONY: build-cli
build-cli:
cargo build --release -p spice
.PHONY: build-cli-dev
build-cli-dev:
cargo build -p spice
.PHONY: build-spiced
build-spiced:
make -C bin/spiced
.PHONY: build-spiced-dev
build-spiced-dev:
cargo build -p spiced
.PHONY: build-validator
build-validator:
cargo build --release -p spicepod-validator
.PHONY: build
build: build-cli build-spiced
.PHONY: build-dev
build-dev:
cargo build -p spice
export DEV=true; make -C bin/spiced
.PHONY: build-testoperator-dev
build-testoperator-dev:
cargo build -p testoperator --all-features
.PHONY: build-testoperator
build-testoperator:
cargo build --release -p testoperator --all-features
.PHONY: build-spidapter-dev
build-spidapter-dev:
cargo build -p spidapter --all-features
.PHONY: build-spidapter
build-spidapter:
cargo build --release -p spidapter --all-features
.PHONY: build-cayenne-flightsql-dev
build-cayenne-flightsql-dev:
cargo build -p cayenne-flightsql --all-features
.PHONY: build-cayenne-flightsql
build-cayenne-flightsql:
cargo build --release -p cayenne-flightsql --all-features
.PHONY: ci
ci:
make -C bin/spice
make -C bin/spiced
.PHONY: test
test:
@cargo test --all --lib
ifdef RUST_PROFILE
CARGO_PROFILE := --profile $(RUST_PROFILE)
NEXTEST_CARGO_PROFILE := --cargo-profile $(RUST_PROFILE)
else
CARGO_PROFILE := --profile dev
NEXTEST_CARGO_PROFILE := --cargo-profile dev
endif
.PHONY: nextest
nextest:
@cargo nextest run --all --lib $(NEXTEST_CARGO_PROFILE) $(NEXTEST_FLAG)
@cargo nextest run -p cayenne --tests $(NEXTEST_CARGO_PROFILE)
# Also update .github/workflows/integration.yml with changes to this target
.PHONY: test-integration
test-integration:
# Test if .env file exists, and login to Spice if not
@test -f .env || (`spice login`)
@cargo test -p runtime --test integration --features postgres,mysql,delta_lake,duckdb,sqlite,turso -- --nocapture
.PHONY: test-integration-without-spiceai-dataset
test-integration-without-spiceai-dataset:
@cargo test -p runtime --test integration --features postgres,mysql,delta_lake,duckdb,sqlite,turso -- --nocapture --skip spiceai_integration_test
.PHONY: test-integration-models
test-integration-models:
@cargo test -p runtime --test integration_models --features models,duckdb -- --nocapture
.PHONY: test-integration-models-without-openai
test-integration-models-without-openai:
@cargo test -p runtime --test integration_models --features models,duckdb -- --nocapture --skip openai_test
.PHONY: test-bench
test-bench:
@cargo bench -p runtime --features postgres,spark,mysql
.PHONY: lint lint-rust
lint: lint-rust
lint-rust:
cargo fmt --all -- --check
## All except metal, cuda, nfs (nfs requires system libnfs library)
CLIPPY_CONF_DIR=".ci" cargo clippy $(CARGO_PROFILE) --keep-going --lib --bins --features adbc,aws-secrets-manager,keyring-secret-store,models,odbc,release,mcp,snapshots,elasticsearch,http-functions,wasm-functions,rate-control --workspace --exclude libnfs -- \
-Dwarnings \
-Dclippy::pedantic \
-Dclippy::unwrap_used \
-Dclippy::expect_used \
-Dclippy::clone_on_ref_ptr \
-Aclippy::module_name_repetitions \
-Aclippy::large_futures \
-Aclippy::too_many_lines \
-Dclippy::equatable_if_let \
-Dclippy::needless_collect \
-Dclippy::redundant_clone \
-Dclippy::todo \
-Dclippy::assertions_on_result_states \
-Dclippy::allow_attributes
cargo clippy $(CARGO_PROFILE) --keep-going --tests --features adbc,aws-secrets-manager,keyring-secret-store,models,odbc,release,mcp,snapshots,elasticsearch,http-functions,wasm-functions,rate-control --workspace --exclude libnfs -- \
-Dwarnings \
-Dclippy::pedantic \
-Dclippy::unwrap_used \
-Aclippy::expect_used \
-Dclippy::clone_on_ref_ptr \
-Aclippy::module_name_repetitions \
-Aclippy::large_futures \
-Aclippy::too_many_lines \
-Dclippy::equatable_if_let \
-Dclippy::needless_collect \
-Dclippy::redundant_clone \
-Dclippy::todo \
-Dclippy::assertions_on_result_states \
-Dclippy::allow_attributes \
-Aunfulfilled_lint_expectations
## Optional: PACKAGES="pkg1 pkg2" to lint specific packages instead of the whole workspace
## Optional: FEATURES="feat1,feat2" to override features
## Feature defaults: when FEATURES is unset, uses aws-secrets-manager,keyring-secret-store,models,odbc,release,mcp,snapshots,elasticsearch,http-functions,wasm-functions,rate-control for workspace (unless PACKAGES is set, then uses package defaults)
## Example: make lint-rust-fix PACKAGES="runtime data_components" FEATURES="duckdb,postgres"
PACKAGES ?=
FEATURES ?=
ifdef PACKAGES
_LINT_PKG_FLAGS := $(foreach p,$(PACKAGES),-p $(p))
_LINT_WORKSPACE_FLAGS := $(_LINT_PKG_FLAGS)
_FMT_FLAGS := $(_LINT_PKG_FLAGS)
else
_LINT_WORKSPACE_FLAGS := --workspace --exclude libnfs
_FMT_FLAGS := --all
endif
# Apply FEATURES if provided, otherwise default to hardcoded features only for workspace-wide linting
ifdef FEATURES
_FEATURES_FLAGS := --features $(FEATURES)
else ifdef PACKAGES
_FEATURES_FLAGS :=
else
_FEATURES_FLAGS := --features adbc,aws-secrets-manager,keyring-secret-store,models,odbc,release,mcp,snapshots,elasticsearch,http-functions,wasm-functions,rate-control
endif
lint-rust-fix:
cargo fmt $(_FMT_FLAGS)
## All except metal, cuda, nfs (nfs requires system libnfs library)
CLIPPY_CONF_DIR=".ci" cargo clippy $(CARGO_PROFILE) --lib --bins --fix --allow-dirty $(_FEATURES_FLAGS) $(_LINT_WORKSPACE_FLAGS) -- \
-Dwarnings \
-Dclippy::pedantic \
-Dclippy::unwrap_used \
-Dclippy::expect_used \
-Dclippy::clone_on_ref_ptr \
-Aclippy::module_name_repetitions \
-Aclippy::large_futures \
-Aclippy::too_many_lines \
-Dclippy::equatable_if_let \
-Dclippy::needless_collect \
-Dclippy::redundant_clone \
-Dclippy::todo \
-Dclippy::assertions_on_result_states \
-Dclippy::allow_attributes
cargo clippy $(CARGO_PROFILE) --fix --allow-dirty --tests $(_FEATURES_FLAGS) $(_LINT_WORKSPACE_FLAGS) -- \
-Dwarnings \
-Dclippy::pedantic \
-Dclippy::unwrap_used \
-Aclippy::expect_used \
-Dclippy::clone_on_ref_ptr \
-Aclippy::module_name_repetitions \
-Aclippy::large_futures \
-Aclippy::too_many_lines \
-Dclippy::equatable_if_let \
-Dclippy::needless_collect \
-Dclippy::redundant_clone \
-Dclippy::todo \
-Dclippy::assertions_on_result_states \
-Dclippy::allow_attributes \
-Aunfulfilled_lint_expectations
check-rust-features:
cargo check $(CARGO_PROFILE) --no-default-features
cargo check $(CARGO_PROFILE) --no-default-features --features adbc
cargo check $(CARGO_PROFILE) --no-default-features --features duckdb
cargo check $(CARGO_PROFILE) --no-default-features --features postgres
cargo check $(CARGO_PROFILE) --no-default-features --features sqlite
cargo check $(CARGO_PROFILE) --no-default-features --features mysql
cargo check $(CARGO_PROFILE) --no-default-features --features keyring-secret-store
cargo check $(CARGO_PROFILE) --no-default-features --features flightsql
cargo check $(CARGO_PROFILE) --no-default-features --features http-functions
cargo check $(CARGO_PROFILE) --no-default-features --features wasm-functions
cargo check $(CARGO_PROFILE) --no-default-features --features wasm-functions-compile
cargo check $(CARGO_PROFILE) --no-default-features --features aws-secrets-manager
cargo check $(CARGO_PROFILE) --no-default-features --features databricks
cargo check $(CARGO_PROFILE) --no-default-features --features delta_lake
cargo check $(CARGO_PROFILE) --no-default-features --features dremio
cargo check $(CARGO_PROFILE) --no-default-features --features clickhouse
cargo check $(CARGO_PROFILE) --no-default-features --features cosmosdb
cargo check $(CARGO_PROFILE) --no-default-features --features debezium
cargo check $(CARGO_PROFILE) --no-default-features --features runtime/openapi
cargo check $(CARGO_PROFILE) --no-default-features --features dynamodb
cargo check $(CARGO_PROFILE) --no-default-features --features oracle
cargo check $(CARGO_PROFILE) --no-default-features --features mongodb
cargo check $(CARGO_PROFILE) --no-default-features --features snapshots
.PHONY: fmt-toml
fmt-toml:
taplo fmt
.PHONY: run
run:
~/.spice/bin/spiced
.PHONY: docker
docker:
docker buildx build --build-arg RUST_PROFILE=release -t spiceai-rust:local-dev .
.PHONY: docker-run
docker-run:
docker stop spiceai && docker rm spiceai || true
docker run --name spiceai -p 8090:8090 -p 50051:50051 spiceai-rust:local-dev
.PHONY: docker-local
docker-local:
cp ~/.spice/bin/spiced .spiced-local-tmp
docker build -f Dockerfile.local -t spiceai.org/spiceai:local .
rm .spiced-local-tmp
.PHONY: deps-licenses
dep-licenses:
@cargo install cargo-license --quiet
@cargo license -d
.PHONY: display-deps
display-deps:
@cargo install cargo-license --quiet
@cargo license -d --tsv --direct-deps-only --all-features | grep -v "github.com/spiceai"
################################################################################
# Target: install #
################################################################################
# Honour CARGO_TARGET_DIR if set (e.g. for custom build directories / sccache setups),
# otherwise fall back to the default Cargo output directory.
TARGET_DIR := $(or $(CARGO_TARGET_DIR),target)
# Default install includes models. Use -data suffix variants to build without models.
# Data-only features (default features minus models)
# Note: postgres-accel enables the PostgreSQL data accelerator (separate from postgres connector)
SPICED_DATA_FEATURES := duckdb,postgres,postgres-accel,sqlite,mysql,flightsql,delta_lake,databricks,dremio,clickhouse,cosmosdb,sharepoint,snapshots,snowflake,spark,ftp,sftp,debezium,kafka,anonymous_telemetry,mssql,dynamodb,imap,alloc-snmalloc,oracle,runtime/s3_vectors,mongodb,iceberg-write,turso,smb,pingora,scylladb
.PHONY: install
install: build
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/spice ~/.spice/bin/spice
install -m 755 $(TARGET_DIR)/release/spiced ~/.spice/bin/spiced
.PHONY: install-dev
install-dev: build-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/spice ~/.spice/bin/spice
install -m 755 $(TARGET_DIR)/debug/spiced ~/.spice/bin/spiced
# Data-only variants (without models)
.PHONY: install-data-only
install-data-only:
make install SPICED_CUSTOM_FEATURES="$(SPICED_DATA_FEATURES)"
.PHONY: install-data-only-dev
install-data-only-dev:
make install-dev SPICED_CUSTOM_FEATURES="$(SPICED_DATA_FEATURES)"
# Metal variants (with GPU acceleration)
.PHONY: install-metal
install-metal:
make install SPICED_NON_DEFAULT_FEATURES="metal"
.PHONY: install-metal-dev
install-metal-dev:
make install-dev SPICED_NON_DEFAULT_FEATURES="metal"
.PHONY: install-data-only-metal
install-data-only-metal:
make install SPICED_CUSTOM_FEATURES="$(SPICED_DATA_FEATURES),metal"
.PHONY: install-data-only-metal-dev
install-data-only-metal-dev:
make install-dev SPICED_CUSTOM_FEATURES="$(SPICED_DATA_FEATURES),metal"
# CUDA variants
.PHONY: install-cuda
install-cuda:
make install SPICED_NON_DEFAULT_FEATURES="cuda"
.PHONY: install-data-only-cuda
install-data-only-cuda:
make install SPICED_CUSTOM_FEATURES="$(SPICED_DATA_FEATURES),cuda"
# ODBC variants
.PHONY: install-odbc
install-odbc:
make install SPICED_NON_DEFAULT_FEATURES="odbc"
# NFS variants
.PHONY: install-nfs
install-nfs:
make install SPICED_NON_DEFAULT_FEATURES="nfs"
# Install from a CI build artifact (branch or commit SHA)
# Usage:
# make install-build # Latest build from trunk
# make install-build REF=<branch> # Latest build from a branch
# make install-build REF=<sha> # Build for a specific commit
REF ?= trunk
.PHONY: install-build
install-build:
./install/install-build.sh $(REF)
.PHONY: install-testoperator-dev
install-testoperator-dev: build-testoperator-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/testoperator ~/.spice/bin/testoperator
.PHONY: install-testoperator
install-testoperator: build-testoperator
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/testoperator ~/.spice/bin/testoperator
.PHONY: install-spidapter-dev
install-spidapter-dev: build-spidapter-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/spidapter ~/.spice/bin/spidapter
.PHONY: install-spidapter
install-spidapter: build-spidapter
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/spidapter ~/.spice/bin/spidapter
.PHONY: install-cayenne-flightsql-dev
install-cayenne-flightsql-dev: build-cayenne-flightsql-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/cayenne-flightsql ~/.spice/bin/cayenne-flightsql
.PHONY: install-cayenne-flightsql
install-cayenne-flightsql: build-cayenne-flightsql
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/cayenne-flightsql ~/.spice/bin/cayenne-flightsql
.PHONY: install-cli
install-cli: build-cli
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/spice ~/.spice/bin/spice
.PHONY: install-spiced
install-spiced: build-spiced
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/release/spiced ~/.spice/bin/spiced
.PHONY: install-cli-dev
install-cli-dev: build-cli-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/spice ~/.spice/bin/spice
.PHONY: install-spiced-dev
install-spiced-dev: build-spiced-dev
mkdir -p ~/.spice/bin
install -m 755 $(TARGET_DIR)/debug/spiced ~/.spice/bin/spiced
################################################################################
# Target: distributed #
################################################################################
.PHONY: distributed
distributed:
make install SPICED_NON_DEFAULT_FEATURES="vortex"
./scripts/distributed.sh
.PHONY: distributed-dev
distributed-dev:
make install-dev SPICED_NON_DEFAULT_FEATURES="vortex"
./scripts/distributed.sh
################################################################################
# Target: generate-acknowledgements #
################################################################################
ACKNOWLEDGEMENTS_PATH := acknowledgements.md
.PHONY: generate-acknowledgements
generate-acknowledgements:
echo "# Open Source Acknowledgements\n\nSpice.ai acknowledges the following open source projects for making this project possible:\n\n" > $(ACKNOWLEDGEMENTS_PATH)
make generate-acknowledgements-rust
make generate-acknowledgements-formatting
.PHONY: generate-acknowledgements-rust
generate-acknowledgements-rust:
@echo "\n## Rust Crates\n" >> "$(ACKNOWLEDGEMENTS_PATH)"
@make display-deps 2>/dev/null | awk -F'\t' 'NR>1 {printf "- %s %s, %s %s\n <br/>%s\n\n", $$1, $$2, $$5, $$6, $$4}' >> "$(ACKNOWLEDGEMENTS_PATH)"
.PHONY: generate-acknowledgements-formatting
generate-acknowledgements-formatting:
@if [[ "$(UNAME)" -eq "Darwin" ]]; then\
sed -i '' 's/\"//g' $(ACKNOWLEDGEMENTS_PATH); \
sed -i '' 's/,/, /g' $(ACKNOWLEDGEMENTS_PATH); \
sed -i '' 's/, /, /g' $(ACKNOWLEDGEMENTS_PATH); \
else\
sed -i 's/\"//g' $(ACKNOWLEDGEMENTS_PATH); \
sed -i 's/,/, /g' $(ACKNOWLEDGEMENTS_PATH); \
sed -i 's/, /, /g' $(ACKNOWLEDGEMENTS_PATH); \
fi
-include Makefile.local