forked from mlrun/mlrun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
924 lines (805 loc) · 37.6 KB
/
Makefile
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
# Copyright 2023 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS BLOCK IS FOR VARIABLES USER MAY OVERRIDE
MLRUN_VERSION ?= unstable
# pip requires the python version to be according to some regex (so "unstable" is not valid for example) this regex only
# allows us to have free text (like unstable) after the "+". on the contrary in a docker tag "+" is not a valid
# character so we're doing best effort - if the provided version doesn't look valid (like unstable), we prefix the
# version for the python package with 0.0.0+
# if the provided version includes a "+" we replace it with "-" for the docker tag
MLRUN_DOCKER_TAG ?= $(shell echo "$(MLRUN_VERSION)" | sed -E 's/\+/\-/g')
MLRUN_DOCKER_REPO ?= mlrun
# empty by default (dockerhub), can be set to something like "quay.io/".
# This will be used to tag the images built using this makefile
MLRUN_DOCKER_REGISTRY ?=
# empty by default (use cache), set it to anything to disable caching (will add flags to pip and docker commands to
# disable caching)
MLRUN_NO_CACHE ?=
MLRUN_ML_DOCKER_IMAGE_NAME_PREFIX ?= ml-
# do not specify the patch version so that we can easily upgrade it when needed - it is determined by the base image
# mainly used for mlrun, base and mlrun-gpu. mlrun API version >= 1.3.0 should always have python 3.9
MLRUN_PYTHON_VERSION ?= 3.9
MLRUN_SKIP_COMPILE_SCHEMAS ?=
INCLUDE_PYTHON_VERSION_SUFFIX ?=
MLRUN_PIP_VERSION ?= 24.2
MLRUN_UV_VERSION ?= 0.5.13
MLRUN_UV_IMAGE ?= ghcr.io/astral-sh/uv:$(MLRUN_UV_VERSION)
MLRUN_CACHE_DATE ?= $(shell date +%s)
# empty by default, can be set to something like "tag-name" which will cause to:
# 1. docker pull the same image with the given tag (cache image) before the build
# 2. add the --cache-from flag to the docker build
# 3. docker tag and push (also) the (updated) cache image
MLRUN_DOCKER_CACHE_FROM_TAG ?=
MLRUN_DOCKER_CACHE_FROM_REGISTRY ?= $(MLRUN_DOCKER_REGISTRY)
MLRUN_PUSH_DOCKER_CACHE_IMAGE ?=
MLRUN_GIT_ORG ?= mlrun
MLRUN_RELEASE_BRANCH ?= master
MLRUN_RAISE_ON_ERROR ?= true
MLRUN_SKIP_CLONE ?= false
MLRUN_RELEASE_NOTES_OUTPUT_FILE ?=
MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES ?= true
MLRUN_SYSTEM_TEST_MARKERS ?=
MLRUN_SYSTEM_TESTS_GITHUB_RUN_URL ?=
MLRUN_GPU_CUDA_VERSION ?= 11.8.0-cudnn8-devel-ubuntu22.04
# THIS BLOCK IS FOR COMPUTED VARIABLES
MLRUN_DOCKER_IMAGE_PREFIX := $(if $(MLRUN_DOCKER_REGISTRY),$(strip $(MLRUN_DOCKER_REGISTRY))$(MLRUN_DOCKER_REPO),$(MLRUN_DOCKER_REPO))
MLRUN_CACHE_DOCKER_IMAGE_PREFIX := $(if $(MLRUN_DOCKER_CACHE_FROM_REGISTRY),$(strip $(MLRUN_DOCKER_CACHE_FROM_REGISTRY))$(MLRUN_DOCKER_REPO),$(MLRUN_DOCKER_REPO))
MLRUN_DOCKER_CACHE_FROM_FLAG :=
# if MLRUN_NO_CACHE passed we don't want to use cache, this is mainly used for cleaner if statements
MLRUN_USE_CACHE := $(if $(MLRUN_NO_CACHE),,true)
MLRUN_DOCKER_NO_CACHE_FLAG := $(if $(MLRUN_NO_CACHE),--no-cache,)
MLRUN_PIP_NO_CACHE_FLAG := $(if $(MLRUN_NO_CACHE),--no-cache-dir,)
# expected to be in the form of '-py<major><minor>' e.g. '-py39'
MLRUN_ANACONDA_PYTHON_DISTRIBUTION := $(shell echo "$(MLRUN_PYTHON_VERSION)" | awk -F. '{print "-py"$$1$$2}')
MLRUN_PYTHON_VERSION_SUFFIX := $(if $(INCLUDE_PYTHON_VERSION_SUFFIX),$(MLRUN_ANACONDA_PYTHON_DISTRIBUTION),)
# expected to be in the form of 'py<major><minor>' e.g. 'py39'
MLRUN_LINT_PYTHON_VERSION := $(shell echo "$(MLRUN_PYTHON_VERSION)" | awk -F. '{print "py"$$1$$2}')
MLRUN_PIPELINES_KFP_VERSION := $(if $(filter 3.9,$(MLRUN_PYTHON_VERSION)),1-8,2)
MLRUN_OLD_VERSION_ESCAPED = $(shell echo "$(MLRUN_OLD_VERSION)" | sed 's/\./\\\./g')
MLRUN_BC_TESTS_OPENAPI_OUTPUT_PATH ?= $(shell pwd)
# if MLRUN_SYSTEM_TESTS_COMPONENT isn't set, we'll run all system tests
# if MLRUN_SYSTEM_TESTS_COMPONENT is set, we'll run only the system tests for the given component
# if MLRUN_SYSTEM_TESTS_COMPONENT starts with "no_", we'll ignore that component in the system tests
MLRUN_SYSTEM_TESTS_COMPONENT ?=
MLRUN_SYSTEM_TESTS_IGNORE_COMPONENT := $(shell echo "$(MLRUN_SYSTEM_TESTS_COMPONENT)" | sed 's/^no_\(.*\)/\1/g')
ifndef MLRUN_SYSTEM_TESTS_COMPONENT
MLRUN_SYSTEM_TESTS_COMMAND_SUFFIX = "tests/system"
else ifeq ($(MLRUN_SYSTEM_TESTS_COMPONENT),$(MLRUN_SYSTEM_TESTS_IGNORE_COMPONENT))
MLRUN_SYSTEM_TESTS_COMMAND_SUFFIX = "tests/system/$(MLRUN_SYSTEM_TESTS_COMPONENT)"
else
MLRUN_SYSTEM_TESTS_COMMAND_SUFFIX = "--ignore=tests/system/$(MLRUN_SYSTEM_TESTS_COMPONENT) tests/system"
endif
MLRUN_PYTHON_PACKAGE_INSTALLER ?= pip
ifeq ($(MLRUN_PYTHON_PACKAGE_INSTALLER),pip)
MLRUN_PYTHON_VENV_PIP_INSTALL ?= python -m pip install
else ifeq ($(MLRUN_PYTHON_PACKAGE_INSTALLER),uv)
MLRUN_PYTHON_VENV_PIP_INSTALL ?= uv pip install
else
$(error MLRUN_PYTHON_PACKAGE_INSTALLER must be either "pip" or "uv")
endif
# Change to `--upgrade-package <package-name>` to upgrade only a specific package
MLRUN_UV_UPGRADE_FLAG ?= --upgrade
.PHONY: help
help: ## Display available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all:
$(error please pick a target)
.PHONY: install-requirements
install-requirements: ## Install all requirements needed for development
# relevant for pip package installer only
@if [ "$(MLRUN_PYTHON_PACKAGE_INSTALLER)" = "pip" ]; then \
$(MLRUN_PYTHON_VENV_PIP_INSTALL) --upgrade $(MLRUN_PIP_NO_CACHE_FLAG) pip~=$(MLRUN_PIP_VERSION); \
fi
$(MLRUN_PYTHON_VENV_PIP_INSTALL) \
$(MLRUN_PIP_NO_CACHE_FLAG) \
-r requirements.txt \
-r extras-requirements.txt \
-r dev-requirements.txt \
-r dockerfiles/mlrun-api/requirements.txt
.PHONY: install-conda-requirements
install-conda-requirements: ## Install all requirements needed for development with specific conda packages for arm64
make install-requirements
.PHONY: install-complete-requirements
install-complete-requirements: ## Install all requirements needed for development and testing
$(MLRUN_PYTHON_VENV_PIP_INSTALL) --upgrade $(MLRUN_PIP_NO_CACHE_FLAG) pip~=$(MLRUN_PIP_VERSION)
$(MLRUN_PYTHON_VENV_PIP_INSTALL) .[complete]
.PHONY: install-complete-kfp-requirements
install-complete-kfp-requirements: ## Install all requirements needed for development and testing + KFP 1.8
$(MLRUN_PYTHON_VENV_PIP_INSTALL) --upgrade $(MLRUN_PIP_NO_CACHE_FLAG) pip~=$(MLRUN_PIP_VERSION)
$(MLRUN_PYTHON_VENV_PIP_INSTALL) .[complete,kfp18]
.PHONY: install-all-requirements
install-all-requirements: ## Install all requirements needed for development and testing
$(MLRUN_PYTHON_VENV_PIP_INSTALL) --upgrade $(MLRUN_PIP_NO_CACHE_FLAG) pip~=$(MLRUN_PIP_VERSION)
$(MLRUN_PYTHON_VENV_PIP_INSTALL) .[all]
.PHONY: create-migration-mysql
create-migration-mysql: ## Create a DB migration (MLRUN_MIGRATION_MESSAGE must be set)
./automation/scripts/create_migration_mysql.sh
.PHONY: create-migration
create-migration: create-migration-mysql
@echo "Migrations created successfully"
.PHONY: bump-version
bump-version: ## Bump version in all needed places in code
ifndef MLRUN_NEW_VERSION
$(error MLRUN_NEW_VERSION is undefined)
endif
ifndef MLRUN_OLD_VERSION
$(error MLRUN_OLD_VERSION is undefined)
endif
echo $(MLRUN_OLD_VERSION_ESCAPED)
find . \( ! -regex '.*/\..*' \) -a \( -iname \*.md -o -iname \*.txt -o -iname \*.yaml -o -iname \*.yml \) \
-type f -print0 | xargs -0 sed -i '' -e 's/:$(MLRUN_OLD_VERSION_ESCAPED)/:$(MLRUN_NEW_VERSION)/g'
find ./docs/install/*.yaml -type f -print0 | xargs -0 sed -i '' -e 's/{TAG:-.*}/{TAG:-$(MLRUN_NEW_VERSION)}/g'
.PHONY: update-version-file
update-version-file: ## Update the version file
python ./automation/version/version_file.py ensure --mlrun-version $(MLRUN_VERSION)
.PHONY: generate-dockerignore
generate-dockerignore: ## Copies the root .dockerignore and removes the tests pattern from it
$(eval TARGET := dockerfiles/${DEST}/Dockerfile.dockerignore)
@if [ -f "$(TARGET)" ]; then \
temp_file=$$(mktemp) && \
sed '/\*\*\/tests/d' .dockerignore > $$temp_file && \
if cmp -s $$temp_file "$(TARGET)"; then \
echo "File $(TARGET) already exists and content is identical"; \
rm $$temp_file; \
exit 0; \
else \
echo "File $(TARGET) exists but content differs, updating..."; \
mv $$temp_file "$(TARGET)"; \
fi; \
else \
sed '/\*\*\/tests/d' .dockerignore > "$(TARGET)"; \
fi
.PHONY: build
build: docker-images package-wheel ## Build all artifacts
@echo Done.
DEFAULT_DOCKER_IMAGES_RULES = \
api \
mlrun \
mlrun-gpu \
mlrun-kfp \
jupyter \
base \
log-collector
.PHONY: docker-images
docker-images: $(DEFAULT_DOCKER_IMAGES_RULES) ## Build all docker images
@echo Done.
.PHONY: push-docker-images
push-docker-images: docker-images ## Push all docker images
@echo "Pushing images concurrently $(DEFAULT_IMAGES)"
@echo $(DEFAULT_IMAGES) | xargs -n 1 -P 5 docker push
@echo Done.
.PHONY: print-docker-images
print-docker-images: ## Print all docker images
@for image in $(DEFAULT_IMAGES); do \
echo $$image ; \
done
MLRUN_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/mlrun
MLRUN_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/mlrun
MLRUN_IMAGE_NAME_TAGGED := $(MLRUN_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)), docker pull $(MLRUN_CACHE_IMAGE_NAME_TAGGED) || true,)
MLRUN_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_IMAGE_NAME_TAGGED) $(MLRUN_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_CACHE_IMAGE_NAME_TAGGED),)
DEFAULT_IMAGES += $(MLRUN_IMAGE_NAME_TAGGED)
.PHONY: mlrun
mlrun: update-version-file ## Build mlrun docker image
$(MLRUN_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/mlrun/Dockerfile \
--build-arg MLRUN_ANACONDA_PYTHON_DISTRIBUTION=$(MLRUN_ANACONDA_PYTHON_DISTRIBUTION) \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_UV_IMAGE=$(MLRUN_UV_IMAGE) \
$(MLRUN_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_IMAGE_NAME_TAGGED) .
.PHONY: push-mlrun
push-mlrun: mlrun ## Push mlrun docker image
docker push $(MLRUN_IMAGE_NAME_TAGGED)
$(MLRUN_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-mlrun
pull-mlrun: ## Pull mlrun docker image
docker pull $(MLRUN_IMAGE_NAME_TAGGED)
MLRUN_KFP_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/mlrun-kfp
MLRUN_KFP_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/mlrun-kfp
MLRUN_KFP_IMAGE_NAME_TAGGED := $(MLRUN_KFP_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_KFP_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_KFP_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_KFP_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_KFP_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_KFP_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)), docker pull $(MLRUN_CACHE_IMAGE_NAME_TAGGED) || true,)
MLRUN_KFP_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_KFP_IMAGE_NAME_TAGGED) $(MLRUN_KFP_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_KFP_CACHE_IMAGE_NAME_TAGGED),)
DEFAULT_IMAGES += $(MLRUN_KFP_IMAGE_NAME_TAGGED)
.PHONY: mlrun-kfp
mlrun-kfp: update-version-file ## Build mlrun docker image with KFP
$(MLRUN_KFP_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/mlrun-kfp/Dockerfile \
--build-arg MLRUN_DOCKER_REGISTRY=$(MLRUN_DOCKER_REGISTRY) \
--build-arg MLRUN_VERSION=$(MLRUN_VERSION) \
$(MLRUN_KFP_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_KFP_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX) .
.PHONY: push-mlrun-kfp
push-mlrun-kfp: mlrun-kfp ## Push mlrun docker image
docker push $(MLRUN_KFP_IMAGE_NAME_TAGGED)
$(MLRUN_KFP_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-mlrun-kfp
pull-mlrun-kfp: ## Pull mlrun docker image
docker pull $(MLRUN_KFP_CACHE_IMAGE_PULL_COMMAND)
MLRUN_GPU_PREBAKED_IMAGE_NAME_TAGGED := quay.io/mlrun/prebaked-cuda:$(MLRUN_GPU_CUDA_VERSION)
MLRUN_GPU_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/mlrun-gpu
MLRUN_GPU_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/mlrun-gpu
MLRUN_GPU_IMAGE_NAME_TAGGED := $(MLRUN_GPU_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_GPU_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_GPU_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_GPU_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_GPU_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)), docker pull $(MLRUN_CACHE_IMAGE_NAME_TAGGED) || true,)
MLRUN_GPU_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_GPU_IMAGE_NAME_TAGGED) $(MLRUN_GPU_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_GPU_CACHE_IMAGE_NAME_TAGGED),)
DEFAULT_IMAGES += $(MLRUN_GPU_IMAGE_NAME_TAGGED)
.PHONY: mlrun-gpu
mlrun-gpu: update-version-file ## Build mlrun gpu docker image
$(MLRUN_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/gpu/Dockerfile \
--build-arg MLRUN_GPU_BASE_IMAGE=$(MLRUN_GPU_PREBAKED_IMAGE_NAME_TAGGED) \
--build-arg MLRUN_UV_IMAGE=$(MLRUN_UV_IMAGE) \
$(MLRUN_GPU_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_GPU_IMAGE_NAME_TAGGED) \
.
.PHONY: push-mlrun-gpu
push-mlrun-gpu: mlrun-gpu ## Push mlrun gpu docker image
docker push $(MLRUN_GPU_IMAGE_NAME_TAGGED)
$(MLRUN_GPU_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-mlrun-gpu
pull-mlrun-gpu: ## Pull mlrun gpu docker image
docker pull $(MLRUN_GPU_IMAGE_NAME_TAGGED)
.PHONY: prebake-mlrun-gpu
prebake-mlrun-gpu: ## Build prebake mlrun GPU based docker image
docker build \
--file dockerfiles/gpu/prebaked.Dockerfile \
--build-arg CUDA_VER=$(MLRUN_GPU_CUDA_VERSION) \
--build-arg MLRUN_ANACONDA_PYTHON_DISTRIBUTION=$(MLRUN_ANACONDA_PYTHON_DISTRIBUTION) \
--tag $(MLRUN_GPU_PREBAKED_IMAGE_NAME_TAGGED) \
.
.PHONY: push-prebake-mlrun-gpu
push-prebake-mlrun-gpu: ## Push prebake mlrun GPU based docker image
docker push $(MLRUN_GPU_PREBAKED_IMAGE_NAME_TAGGED)
MLRUN_BASE_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/$(MLRUN_ML_DOCKER_IMAGE_NAME_PREFIX)base
MLRUN_BASE_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/$(MLRUN_ML_DOCKER_IMAGE_NAME_PREFIX)base
MLRUN_BASE_IMAGE_NAME_TAGGED := $(MLRUN_BASE_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_BASE_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_BASE_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_BASE_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_BASE_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_BASE_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_BASE_IMAGE_NAME_TAGGED) $(MLRUN_BASE_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_BASE_CACHE_IMAGE_NAME_TAGGED),)
DEFAULT_IMAGES += $(MLRUN_BASE_IMAGE_NAME_TAGGED)
.PHONY: base
base: pull-cache update-version-file ## Build base docker image
docker build \
--file dockerfiles/base/Dockerfile \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_ANACONDA_PYTHON_DISTRIBUTION=$(MLRUN_ANACONDA_PYTHON_DISTRIBUTION) \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_UV_IMAGE=$(MLRUN_UV_IMAGE) \
$(MLRUN_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_BASE_IMAGE_NAME_TAGGED) .
.PHONY: push-base
push-base: base ## Push base docker image
docker push $(MLRUN_BASE_IMAGE_NAME_TAGGED)
$(MLRUN_BASE_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-base
pull-base: ## Pull base docker image
docker pull $(MLRUN_BASE_IMAGE_NAME_TAGGED)
MLRUN_JUPYTER_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/jupyter
MLRUN_JUPYTER_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/jupyter
MLRUN_JUPYTER_IMAGE_NAME_TAGGED := $(MLRUN_JUPYTER_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_JUPYTER_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_JUPYTER_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_JUPYTER_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_JUPYTER_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_JUPYTER_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_JUPYTER_IMAGE_NAME_TAGGED) $(MLRUN_JUPYTER_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_JUPYTER_CACHE_IMAGE_NAME_TAGGED),)
MLRUN_JUPYTER_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),docker pull $(MLRUN_JUPYTER_CACHE_IMAGE_NAME_TAGGED) || true,)
DEFAULT_IMAGES += $(MLRUN_JUPYTER_IMAGE_NAME)
.PHONY: jupyter
jupyter: update-version-file ## Build mlrun jupyter docker image
$(MLRUN_JUPYTER_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/jupyter/Dockerfile \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_CACHE_DATE=$(MLRUN_CACHE_DATE) \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_UV_IMAGE=$(MLRUN_UV_IMAGE) \
$(MLRUN_JUPYTER_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_JUPYTER_IMAGE_NAME_TAGGED) \
.
.PHONY: push-jupyter
push-jupyter: jupyter ## Push mlrun jupyter docker image
docker push $(MLRUN_JUPYTER_IMAGE_NAME_TAGGED)
$(MLRUN_JUPYTER_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-jupyter
pull-jupyter: ## Pull mlrun jupyter docker image
docker pull $(MLRUN_JUPYTER_IMAGE_NAME_TAGGED)
.PHONY: log-collector
log-collector: update-version-file
@MLRUN_VERSION=$(MLRUN_VERSION) \
MLRUN_DOCKER_REGISTRY=$(MLRUN_DOCKER_REGISTRY) \
MLRUN_DOCKER_REPO=$(MLRUN_DOCKER_REPO) \
MLRUN_DOCKER_TAG=$(MLRUN_DOCKER_TAG) \
MLRUN_DOCKER_IMAGE_PREFIX=$(MLRUN_DOCKER_IMAGE_PREFIX) \
make --no-print-directory -C $(shell pwd)/server/go log-collector
.PHONY: push-log-collector
push-log-collector: log-collector
@MLRUN_VERSION=$(MLRUN_VERSION) \
MLRUN_DOCKER_REGISTRY=$(MLRUN_DOCKER_REGISTRY) \
MLRUN_DOCKER_REPO=$(MLRUN_DOCKER_REPO) \
MLRUN_DOCKER_TAG=$(MLRUN_DOCKER_TAG) \
MLRUN_DOCKER_IMAGE_PREFIX=$(MLRUN_DOCKER_IMAGE_PREFIX) \
make --no-print-directory -C $(shell pwd)/server/go push-log-collector
.PHONY: pull-log-collector
pull-log-collector:
@MLRUN_VERSION=$(MLRUN_VERSION) \
MLRUN_DOCKER_REGISTRY=$(MLRUN_DOCKER_REGISTRY) \
MLRUN_DOCKER_REPO=$(MLRUN_DOCKER_REPO) \
MLRUN_DOCKER_TAG=$(MLRUN_DOCKER_TAG) \
MLRUN_DOCKER_IMAGE_PREFIX=$(MLRUN_DOCKER_IMAGE_PREFIX) \
make --no-print-directory -C $(shell pwd)/server/go pull-log-collector
.PHONY: compile-schemas
compile-schemas: ## Compile schemas over docker
ifdef MLRUN_SKIP_COMPILE_SCHEMAS
@echo "Skipping compile schemas"
else
$(MAKE) -C server/go compile-schemas
endif
MLRUN_API_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/mlrun-api
MLRUN_API_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/mlrun-api
MLRUN_API_IMAGE_NAME_TAGGED := $(MLRUN_API_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_API_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_API_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_API_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_API_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_API_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),docker pull $(MLRUN_API_CACHE_IMAGE_NAME_TAGGED) || true,)
MLRUN_API_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_API_IMAGE_NAME_TAGGED) $(MLRUN_API_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_API_CACHE_IMAGE_NAME_TAGGED),)
DEFAULT_IMAGES += $(MLRUN_API_IMAGE_NAME_TAGGED)
.PHONY: api
api: compile-schemas update-version-file ## Build mlrun-api docker image
$(MLRUN_API_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/mlrun-api/Dockerfile \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_UV_IMAGE=$(MLRUN_UV_IMAGE) \
$(MLRUN_API_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_API_IMAGE_NAME_TAGGED) .
.PHONY: push-api
push-api: api ## Push api docker image
docker push $(MLRUN_API_IMAGE_NAME_TAGGED)
$(MLRUN_API_CACHE_IMAGE_PUSH_COMMAND)
.PHONY: pull-api
pull-api: ## Pull api docker image
docker pull $(MLRUN_API_IMAGE_NAME_TAGGED)
MLRUN_TEST_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/test
MLRUN_TEST_CACHE_IMAGE_NAME := $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/test
MLRUN_TEST_IMAGE_NAME_TAGGED := $(MLRUN_TEST_IMAGE_NAME):$(MLRUN_DOCKER_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_TEST_CACHE_IMAGE_NAME_TAGGED := $(MLRUN_TEST_CACHE_IMAGE_NAME):$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX)
MLRUN_TEST_IMAGE_DOCKER_CACHE_FROM_FLAG := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),--cache-from $(strip $(MLRUN_TEST_CACHE_IMAGE_NAME_TAGGED)),)
MLRUN_TEST_CACHE_IMAGE_PULL_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_USE_CACHE)),docker pull $(MLRUN_TEST_CACHE_IMAGE_NAME_TAGGED) || true,)
MLRUN_TEST_CACHE_IMAGE_PUSH_COMMAND := $(if $(and $(MLRUN_DOCKER_CACHE_FROM_TAG),$(MLRUN_PUSH_DOCKER_CACHE_IMAGE)),docker tag $(MLRUN_TEST_IMAGE_NAME_TAGGED) $(MLRUN_TEST_CACHE_IMAGE_NAME_TAGGED) && docker push $(MLRUN_TEST_CACHE_IMAGE_NAME_TAGGED),)
.PHONY: build-test
build-test: compile-schemas update-version-file ## Build test docker image
$(MAKE) generate-dockerignore DEST=test
$(MLRUN_TEST_CACHE_IMAGE_PULL_COMMAND)
docker build \
--file dockerfiles/test/Dockerfile \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_PIPELINES_KFP_VERSION=$(MLRUN_PIPELINES_KFP_VERSION) \
--build-arg MLRUN_UV_VERSION=$(MLRUN_UV_VERSION) \
$(MLRUN_TEST_IMAGE_DOCKER_CACHE_FROM_FLAG) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_TEST_IMAGE_NAME_TAGGED) .
.PHONY: push-test
push-test: build-test ## Push test docker image
docker push $(MLRUN_TEST_IMAGE_NAME_TAGGED)
$(MLRUN_TEST_CACHE_IMAGE_PUSH_COMMAND)
MLRUN_SYSTEM_TEST_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/test-system:$(MLRUN_DOCKER_TAG)
.PHONY: build-test-system
build-test-system: compile-schemas update-version-file ## Build system tests docker image
$(MAKE) generate-dockerignore DEST=test-system
docker build \
--file dockerfiles/test-system/Dockerfile \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--build-arg MLRUN_PIP_VERSION=$(MLRUN_PIP_VERSION) \
--build-arg MLRUN_UV_VERSION=$(MLRUN_UV_VERSION) \
$(MLRUN_DOCKER_NO_CACHE_FLAG) \
--tag $(MLRUN_SYSTEM_TEST_IMAGE_NAME) .
.PHONY: package-wheel
package-wheel: clean update-version-file ## Build python package wheel
python -m build --wheel
.PHONY: publish-package
publish-package: package-wheel ## Publish python package wheel
python -m twine upload dist/mlrun-*.whl
.PHONY: test-publish
test-publish: package-wheel ## Test python package publishing
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/mlrun-*.whl
.PHONY: clean
clean: ## Clean python package build artifacts
rm -rf build dist mlrun.egg-info
find . -name '*.pyc' -not -path "./venv" -exec rm {} \;
.PHONY: test-dockerized
test-dockerized: build-test ## Run mlrun tests in docker container
docker run \
-t \
--rm \
--network='host' \
-v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \
$(MLRUN_TEST_IMAGE_NAME_TAGGED) make test
.PHONY: test
test: clean ## Run mlrun tests
python \
-X faulthandler \
-m pytest -v \
--capture=no \
--disable-warnings \
--durations=100 \
--ignore=tests/integration \
--ignore=tests/system \
--ignore=tests/rundb/test_httpdb.py \
--ignore=server/py/services/api/migrations \
--forked \
-rf
.PHONY: test-integration-dockerized
test-integration-dockerized: build-test ## Run mlrun integration tests in docker container
docker run \
-t \
--rm \
--network='host' \
-v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \
$(MLRUN_TEST_IMAGE_NAME_TAGGED) make test-integration
.PHONY: test-integration
test-integration: clean ## Run mlrun integration tests
python -m pytest -v \
--capture=no \
--disable-warnings \
--durations=100 \
-rf \
tests/integration \
tests/rundb/test_httpdb.py
.PHONY: test-migrations-dockerized
test-migrations-dockerized: build-test ## Run mlrun db migrations tests in docker container
docker run \
-t \
--rm \
--network='host' \
-v $(shell pwd):/mlrun \
-v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \
$(MLRUN_TEST_IMAGE_NAME_TAGGED) make test-migrations
.PHONY: test-migrations
test-migrations: clean ## Run mlrun db migrations tests
./automation/scripts/test_migration_mysql.sh
.PHONY: test-system-dockerized
test-system-dockerized: build-test-system ## Run mlrun system tests in docker container
docker run \
--env MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES=$(MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES) \
--env MLRUN_SYSTEM_TESTS_COMPONENT=$(MLRUN_SYSTEM_TESTS_COMPONENT) \
--env MLRUN_VERSION=$(MLRUN_VERSION) \
-t \
--rm \
$(MLRUN_SYSTEM_TEST_IMAGE_NAME)
.PHONY: test-system
test-system: ## Run mlrun system tests
MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES=$(MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES) \
MLRUN_SYSTEM_TESTS_GITHUB_RUN_URL=$(MLRUN_SYSTEM_TESTS_GITHUB_RUN_URL) \
python -m pytest -v \
--capture=no \
--disable-warnings \
--durations=100 \
-rf \
$(MLRUN_SYSTEM_TESTS_COMMAND_SUFFIX)
.PHONY: test-system-open-source
test-system-open-source: update-version-file ## Run mlrun system tests with opensource configuration
MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES=$(MLRUN_SYSTEM_TESTS_CLEAN_RESOURCES) python -m pytest -v \
--capture=no \
--disable-warnings \
--durations=100 \
-rf \
-m $(if $(MLRUN_SYSTEM_TEST_MARKERS),"$(MLRUN_SYSTEM_TEST_MARKERS)","not enterprise") \
$(MLRUN_SYSTEM_TESTS_COMMAND_SUFFIX)
.PHONY: test-package compile-schemas
test-package: ## Run mlrun package tests
python ./automation/package_test/test.py run
.PHONY: test-go
test-go-unit: ## Run mlrun go unit tests
$(MAKE) -C server/go test-unit-local
.PHONY: test-go-dockerized
test-go-unit-dockerized: ## Run mlrun go unit tests in docker container
$(MAKE) -C server/go test-unit-dockerized
.PHONY: test-go
test-go-integration: ## Run mlrun go unit tests
$(MAKE) -C server/go test-integration-local
.PHONY: test-go-dockerized
test-go-integration-dockerized: ## Run mlrun go integration tests in docker container
$(MAKE) -C server/go test-integration-dockerized
.PHONY: run-api-undockerized
run-api-undockerized: ## Run mlrun api locally (un-dockerized)
python -m mlrun db
.PHONY: run-api
run-api: api ## Run mlrun api (dockerized)
# clean up any previous api container. Don't remove it after run to be able to debug failures
docker rm mlrun-api --force || true
docker run \
--name mlrun-api \
--detach \
--publish 8080 \
--add-host host.docker.internal:host-gateway \
--env MLRUN_HTTPDB__DSN=$(MLRUN_HTTPDB__DSN) \
--env MLRUN_LOG_LEVEL=$(MLRUN_LOG_LEVEL) \
--env MLRUN_LOG_FORMATTER=$(MLRUN_LOG_FORMATTER) \
--env MLRUN_SECRET_STORES__TEST_MODE_MOCK_SECRETS=$(MLRUN_SECRET_STORES__TEST_MODE_MOCK_SECRETS) \
--env MLRUN_HTTPDB__REAL_PATH=$(MLRUN_HTTPDB__REAL_PATH) \
$(MLRUN_API_IMAGE_NAME_TAGGED)
.PHONY: run-test-db
run-test-db:
# clean up any previous test db container. Don't remove it after run to be able to debug failures
docker rm test-db --force || true
docker run \
--name=test-db \
--volume $(shell pwd):/mlrun \
--publish 3306:3306 \
--env MYSQL_ROOT_PASSWORD="" \
--env MYSQL_ALLOW_EMPTY_PASSWORD="true" \
--env MYSQL_ROOT_HOST=% \
--env MYSQL_DATABASE="mlrun" \
--detach \
gcr.io/iguazio/mlrun-mysql:8.0 \
--character-set-server=utf8 \
--collation-server=utf8_bin
.PHONY: clean-html-docs
clean-html-docs: ## Clean html docs
rm -f docs/external/*.md
make -C docs clean
.PHONY: html-docs
html-docs: clean-html-docs ## Build html docs
make -C docs html
.PHONY: html-docs-dockerized
html-docs-dockerized: build-test ## Build html docs dockerized
docker run \
--rm \
-v $(shell pwd)/docs/_build:/mlrun/docs/_build \
$(MLRUN_TEST_IMAGE_NAME_TAGGED) \
make html-docs
.PHONY: fmt
fmt: ## Format the code using Ruff and blacken-docs
@echo "Running ruff checks and fixes..."
python -m ruff check --fix-only
python -m ruff format
@echo "Formatting the code blocks with blacken-docs..."
git ls-files -z -- '*.md' | xargs -0 blacken-docs -t="$(MLRUN_LINT_PYTHON_VERSION)"
.PHONY: lint-docs
lint-docs: ## Format the code blocks in markdown files
@echo "Checking the code blocks with blacken-docs"
git ls-files -z -- '*.md' | xargs -0 blacken-docs -t="$(MLRUN_LINT_PYTHON_VERSION)" --check
@if [ "$(SKIP_VALE_CHECK)" != "true" ]; then \
make vale-docs; \
fi
.PHONY: lint-imports
lint-imports: ## Validates import dependencies
@echo "Running import linter"
lint-imports
.PHONY: lint
lint: lint-check lint-imports ## Run lint on the code
.PHONY: lint-check
lint-check: ## Check the code (using ruff)
@echo "Running ruff checks..."
python -m ruff check --exit-non-zero-on-fix
python -m ruff check --preview --select=CPY001 --exit-non-zero-on-fix
python -m ruff format --check
.PHONY: lint-go
lint-go:
$(MAKE) -C server/go lint
.PHONY: fmt-go
fmt-go:
$(MAKE) -C server/go fmt
.PHONY: vale-docs
vale-docs: ## Run vale check for docs and sorts ignore.txt file
vale docs
@sort .github/styles/MLRun/ignore.txt -o .github/styles/MLRun/ignore.txt
.PHONY: linkcheck
linkcheck:
make -C docs/ linkcheck
.PHONY: release
release: ## Release a version
ifndef MLRUN_VERSION
$(error MLRUN_VERSION is undefined)
endif
TAG_SUFFIX=$$(echo $${MLRUN_VERSION%.*}.x); \
BRANCH_NAME=$$(echo release/$$TAG_SUFFIX-latest); \
git fetch origin $$BRANCH_NAME || EXIT_CODE=$$?; \
echo $$EXIT_CODE; \
if [ "$$EXIT_CODE" = "" ]; \
then \
echo "Branch $$BRANCH_NAME exists. Adding changes"; \
git checkout $$BRANCH_NAME; \
rm -rf /tmp/mlrun; \
git clone --branch $(MLRUN_VERSION) https://github.com/$(MLRUN_GIT_ORG)/mlrun.git /tmp/mlrun; \
find . -path ./.git -prune -o -exec rm -rf {} \; 2> /dev/null; \
rsync -avr --exclude='.git/' /tmp/mlrun/ .; \
git add -A; \
else \
echo "Creating new branch: $$BRANCH_NAME"; \
git checkout --orphan $$BRANCH_NAME; \
fi; \
git commit -m "Adding $(MLRUN_VERSION) tag contents" --allow-empty; \
git push origin $$BRANCH_NAME
.PHONY: test-backward-compatibility-dockerized
test-backward-compatibility-dockerized: build-test ## Run backward compatibility tests in docker container
ifndef MLRUN_BC_TESTS_BASE_CODE_PATH
$(error MLRUN_BC_TESTS_BASE_CODE_PATH is undefined)
endif
docker run \
-t \
--rm \
--network='host' \
-v /tmp:/tmp \
-v $(shell pwd):$(shell pwd) \
-v $(MLRUN_BC_TESTS_BASE_CODE_PATH):$(MLRUN_BC_TESTS_BASE_CODE_PATH) \
-v /var/run/docker.sock:/var/run/docker.sock \
--env MLRUN_BC_TESTS_BASE_CODE_PATH=$(MLRUN_BC_TESTS_BASE_CODE_PATH) \
--env MLRUN_BC_TESTS_OPENAPI_OUTPUT_PATH=$(shell pwd) \
--workdir=$(shell pwd) \
$(MLRUN_TEST_IMAGE_NAME_TAGGED) make test-backward-compatibility
.PHONY: test-backward-compatibility
test-backward-compatibility: ## Run backward compatibility tests
ifndef MLRUN_BC_TESTS_BASE_CODE_PATH
$(error MLRUN_BC_TESTS_BASE_CODE_PATH is undefined)
endif
ifndef MLRUN_BC_TESTS_OPENAPI_OUTPUT_PATH
$(error MLRUN_BC_TESTS_OPENAPI_OUTPUT_PATH is undefined)
endif
# Run tests for the base code
export MLRUN_HTTPDB__DSN='sqlite:////mlrun/db/mlrun.db?check_same_thread=false' && \
export MLRUN_OPENAPI_JSON_NAME=mlrun_bc_base_oai.json && \
cd $(MLRUN_BC_TESTS_BASE_CODE_PATH) && \
pip install ./pipeline-adapters/mlrun-pipelines-kfp-common && \
pip install ./pipeline-adapters/mlrun-pipelines-kfp-v1-8 && \
python -m pytest -v --capture=no --disable-warnings --durations=100 server/py/services/api/tests/unit/api/test_docs.py::test_save_openapi_json && \
cd ..
# Run tests for the head code (feature branch)
export MLRUN_OPENAPI_JSON_NAME=mlrun_bc_head_oai.json && \
pip install ./pipeline-adapters/mlrun-pipelines-kfp-common && \
pip install ./pipeline-adapters/mlrun-pipelines-kfp-v1-8 && \
python -m pytest -v --capture=no --disable-warnings --durations=100 server/py/services/api/tests/unit/api/test_docs.py::test_save_openapi_json
# Run OpenAPI diff to check compatibility
docker run --rm -t -v $(MLRUN_BC_TESTS_OPENAPI_OUTPUT_PATH):/specs:ro openapitools/openapi-diff:latest /specs/mlrun_bc_base_oai.json /specs/mlrun_bc_head_oai.json --fail-on-incompatible
.PHONY: release-notes
release-notes: ## Create release notes
ifndef MLRUN_VERSION
$(error MLRUN_VERSION is undefined)
endif
ifndef MLRUN_OLD_VERSION
$(error MLRUN_OLD_VERSION is undefined)
endif
ifndef MLRUN_RELEASE_BRANCH
$(error MLRUN_RELEASE_BRANCH is undefined)
endif
python ./automation/release_notes/generate.py \
run \
--release $(MLRUN_VERSION) \
--previous-release $(MLRUN_OLD_VERSION) \
--release-branch $(MLRUN_RELEASE_BRANCH) \
--raise-on-failed-parsing $(MLRUN_RAISE_ON_ERROR) \
--tmp-file-path $(MLRUN_RELEASE_NOTES_OUTPUT_FILE) \
--skip-clone $(MLRUN_SKIP_CLONE)
.PHONY: pull-cache
pull-cache: ## Pull images to be used as cache for build
ifdef MLRUN_DOCKER_CACHE_FROM_TAG
targets="$(subst push-,,$(MAKECMDGOALS))" ; \
for image_name in $$targets; do \
tag=$(MLRUN_DOCKER_CACHE_FROM_TAG)$(MLRUN_PYTHON_VERSION_SUFFIX) ; \
case "$$image_name" in \
*base*) image_name=$(MLRUN_ML_DOCKER_IMAGE_NAME_PREFIX)$$image_name ;; \
esac; \
docker pull $(MLRUN_CACHE_DOCKER_IMAGE_PREFIX)/$$image_name:$$tag || true ; \
done;
MLRUN_DOCKER_CACHE_FROM_FLAG := $(MLRUN_BASE_IMAGE_DOCKER_CACHE_FROM_FLAG)
endif
.PHONY: verify-uv-version
verify-uv-version:
@{ \
uv_version=$$(uv version | cut -d' ' -f2); \
result=$$(python -m semver compare $$uv_version $(MLRUN_UV_VERSION)); \
if [ "$$result" -eq -1 ]; then \
echo "Error: The running uv version ($$uv_version) is outdated. Upgrade uv to version $(MLRUN_UV_VERSION)."; \
exit 1; \
fi; \
}
.PHONY: upgrade-mlrun-api-deps-lock
upgrade-mlrun-api-deps-lock: verify-uv-version ## Upgrade mlrun-api locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/mlrun-api/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/mlrun-api/locked-requirements.txt
.PHONY: upgrade-mlrun-mlrun-deps-lock
upgrade-mlrun-mlrun-deps-lock: verify-uv-version ## Upgrade mlrun-mlrun locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/mlrun/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/mlrun/locked-requirements.txt
.PHONY: upgrade-mlrun-base-deps-lock
upgrade-mlrun-base-deps-lock: verify-uv-version ## Upgrade mlrun-base locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/base/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/base/locked-requirements.txt
.PHONY: upgrade-mlrun-gpu-deps-lock
upgrade-mlrun-gpu-deps-lock: verify-uv-version ## Upgrade mlrun-gpu locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/mlrun/requirements.txt \
dockerfiles/base/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/gpu/locked-requirements.txt
.PHONY: upgrade-mlrun-jupyter-deps-lock
upgrade-mlrun-jupyter-deps-lock: verify-uv-version ## Upgrade mlrun-jupyter locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/jupyter/requirements.txt \
dockerfiles/mlrun-api/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/jupyter/locked-requirements.txt
.PHONY: upgrade-mlrun-test-deps-lock
upgrade-mlrun-test-deps-lock: verify-uv-version ## Upgrade mlrun test locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/mlrun-api/requirements.txt \
dockerfiles/mlrun-kfp/requirements.txt \
dev-requirements.txt \
docs/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/test/locked-requirements.txt
.PHONY: upgrade-mlrun-system-test-deps-lock
upgrade-mlrun-system-test-deps-lock: verify-uv-version ## Upgrade mlrun system test locked requirements file
uv pip compile \
requirements.txt \
extras-requirements.txt \
dockerfiles/mlrun-kfp/requirements.txt \
dockerfiles/mlrun-api/requirements.txt \
dev-requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/test-system/locked-requirements.txt
upgrade-mlrun-kfp-deps-lock: verify-uv-version ## Upgrade mlrun-kfp locked requirements file
uv pip compile \
requirements.txt \
dockerfiles/mlrun-kfp/requirements.txt \
$(MLRUN_UV_UPGRADE_FLAG) \
--output-file dockerfiles/mlrun-kfp/locked-requirements.txt
.PHONY: upgrade-mlrun-deps-lock
upgrade-mlrun-deps-lock: verify-uv-version ## Upgrade mlrun-* locked requirements file
@$(MAKE) -j \
upgrade-mlrun-mlrun-deps-lock \
upgrade-mlrun-api-deps-lock \
upgrade-mlrun-jupyter-deps-lock \
upgrade-mlrun-base-deps-lock \
upgrade-mlrun-gpu-deps-lock \
upgrade-mlrun-kfp-deps-lock \
upgrade-mlrun-test-deps-lock \
upgrade-mlrun-system-test-deps-lock