From 250e19ffd051865f7bfc6cf9763fd811e8a08c7e Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Wed, 17 May 2023 08:53:00 +0200 Subject: [PATCH 1/3] Add Makefile documentation Signed-off-by: ddelange <14880945+ddelange@users.noreply.github.com> --- Makefile | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 2aed0426..a08ba097 100644 --- a/Makefile +++ b/Makefile @@ -44,64 +44,68 @@ GOBIN=$(shell go env GOBIN) endif .PHONY: all +## Alias for `manager` all: manager -# Run unit tests .PHONY: test +## Run unit tests test: go test -coverprofile cover.out `go list ./... | grep -v fvt` -# Run fvt tests. This requires an etcd, kubernetes connection, and model serving installation. Ginkgo CLI is used to run them in parallel .PHONY: fvt +## Run fvt tests. This requires an etcd, kubernetes connection, and model serving installation. Ginkgo CLI is used to run them in parallel fvt: ginkgo -v -procs=2 --progress --fail-fast fvt/predictor fvt/scaleToZero fvt/storage fvt/hpa --timeout=50m -# Command to regenerate the grpc go files from the proto files .PHONY: fvt-protoc +## Regenerate the grpc go files from the proto files fvt-protoc: rm -rf fvt/generated protoc -I=fvt/proto --go_out=plugins=grpc:. --go_opt=module=github.com/kserve/modelmesh-serving $(shell find fvt/proto -iname "*.proto") .PHONY: fvt-with-deploy +## Alias for `oc-login, deploy-release-dev-mode, fvt` fvt-with-deploy: oc-login deploy-release-dev-mode fvt .PHONY: oc-login +## Login oc-login: oc login --token=${OCP_TOKEN} --server=https://${OCP_ADDRESS} --insecure-skip-tls-verify=true -# Build manager binary .PHONY: manager +## Build manager binary manager: generate fmt go build -o bin/manager main.go -# Run against the configured Kubernetes cluster in ~/.kube/config .PHONY: start +## Run against a k8s cluster start: generate fmt manifests go run ./main.go -# Install CRDs into a cluster .PHONY: install +## Install CRDs into a k8s cluster install: manifests kustomize build config/crd | kubectl apply -f - -# Uninstall CRDs from a cluster .PHONY: uninstall +## Uninstall CRDs from a k8s cluster uninstall: manifests kustomize build config/crd | kubectl delete -f - -# Deploy controller in the configured Kubernetes cluster in ~/.kube/config .PHONY: deploy +## Deploy controller in a k8s cluster deploy: manifests cd config/manager && kustomize edit set image controller=${IMG} kustomize build config/default | kubectl apply -f - -# artifactory creds set via env var .PHONY: deploy-release +## Deploy release (artifactory creds set via env var) deploy-release: ./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config .PHONY: deploy-release-dev-mode +## Deploy release in dev mode (artifactory creds set via env var) deploy-release-dev-mode: ./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging @@ -119,8 +123,8 @@ endif delete: oc-login ./scripts/delete.sh --namespace ${NAMESPACE} --local-config-path config -# Generate manifests e.g. CRD, RBAC etc. .PHONY: manifests +## Generate manifests e.g. CRD, RBAC etc. manifests: controller-gen # NOTE: We're currently copying the CRD manifests from KServe rather than using this target to regenerate those # that are common (all apart from predictors) because the formatting ends up different depending on the version @@ -133,50 +137,48 @@ manifests: controller-gen rm -f ./config/crd/bases/serving.kserve.io_trainedmodels.yaml pre-commit run --all-files prettier > /dev/null || true -# Run go fmt against code .PHONY: fmt +## Run go fmt against code fmt: ./scripts/fmt.sh || (echo "Linter failed: $$?"; git status; exit 1) -# Generate code .PHONY: generate +## Generate code generate: controller-gen $(CONTROLLER_GEN) object:headerFile="scripts/controller-gen-header.go.tmpl" paths="./..." pre-commit run --all-files prettier > /dev/null || true -# Build the final runtime docker image .PHONY: build +## Build runtime docker image build: ./scripts/build_docker.sh --target runtime --engine $(ENGINE) -# Build the develop docker image .PHONY: build.develop +## Build develop docker image build.develop: ./scripts/build_devimage.sh $(ENGINE) -# Start a terminal session in the develop docker container .PHONY: develop +## Build develop docker image and run an interactive shell in the develop envionment develop: build.develop ./scripts/develop.sh -# Run make commands from within the develop docker container -# For example, `make run fmt` will execute `make fmt` within the docker container .PHONY: run +## Build develop docker image and run a make command in the develop envionment (e.g. `make run fmt` will execute `make fmt` within the docker container) run: build.develop ./scripts/develop.sh make $(RUN_ARGS) -# Build the docker image .PHONY: docker-build +## Build the docker image docker-build: build -# Push the docker image .PHONY: docker-push +## Push the docker image docker-push: docker push ${IMG} -# find or download controller-gen -# download controller-gen if necessary .PHONY: controller-gen +## Find or download controller-gen controller-gen: ifeq (, $(shell which controller-gen)) @{ \ @@ -192,15 +194,21 @@ else CONTROLLER_GEN=$(shell which controller-gen) endif -# Model Mesh gRPC codegen .PHONY: mmesh-codegen +## Model Mesh gRPC codegen mmesh-codegen: protoc -I proto/ --go_out=plugins=grpc:generated/ $(PROTO_FILES) -# Check markdown files for invalid links .PHONY: check-doc-links +## Check markdown files for invalid links check-doc-links: @python3 scripts/verify_doc_links.py && echo "$@: OK" +.PHONY: help +## Print Makefile documentation +help: + @perl -0 -nle 'printf("%-25s - %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+):[^=]/gm' $(MAKEFILE_LIST) | sort +.DEFAULT_GOAL := help + # Override targets if they are included in RUN_ARGs so it doesn't run them twice $(eval $(RUN_ARGS):;@:) From a24bbe86816487989cc783a310dd63e993fe64a4 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Thu, 3 Aug 2023 09:52:57 +0200 Subject: [PATCH 2/3] PR suggestions https://github.com/kserve/modelmesh-runtime-adapter/pull/50 Signed-off-by: ddelange <14880945+ddelange@users.noreply.github.com> --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a08ba097..10e1bb20 100644 --- a/Makefile +++ b/Makefile @@ -149,31 +149,31 @@ generate: controller-gen pre-commit run --all-files prettier > /dev/null || true .PHONY: build -## Build runtime docker image +## Build runtime Docker image build: ./scripts/build_docker.sh --target runtime --engine $(ENGINE) .PHONY: build.develop -## Build develop docker image +## Build develop container image build.develop: ./scripts/build_devimage.sh $(ENGINE) .PHONY: develop -## Build develop docker image and run an interactive shell in the develop envionment +## Run interactive shell inside developer container develop: build.develop ./scripts/develop.sh .PHONY: run -## Build develop docker image and run a make command in the develop envionment (e.g. `make run fmt` will execute `make fmt` within the docker container) +## Run make target inside developer container (e.g. `make run fmt`) run: build.develop ./scripts/develop.sh make $(RUN_ARGS) .PHONY: docker-build -## Build the docker image +## Build the Docker image docker-build: build .PHONY: docker-push -## Push the docker image +## Push the Docker image docker-push: docker push ${IMG} @@ -204,11 +204,11 @@ mmesh-codegen: check-doc-links: @python3 scripts/verify_doc_links.py && echo "$@: OK" +.DEFAULT_GOAL := help .PHONY: help ## Print Makefile documentation help: - @perl -0 -nle 'printf("%-25s - %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+):[^=]/gm' $(MAKEFILE_LIST) | sort -.DEFAULT_GOAL := help + @perl -0 -nle 'printf("\033[36m %-15s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort # Override targets if they are included in RUN_ARGs so it doesn't run them twice $(eval $(RUN_ARGS):;@:) From 92158d2f128c6df9876dd429c0f61fa2ad59f02b Mon Sep 17 00:00:00 2001 From: Christian Kadner Date: Mon, 14 Aug 2023 19:34:44 -0700 Subject: [PATCH 3/3] Harmonize Makefile target names - install opposite of uninstall - deploy opposite of undeploy Signed-off-by: Christian Kadner --- Makefile | 37 +++++++++++++++++-------------------- docs/developer.md | 2 +- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 7fb4a27c..279dd003 100644 --- a/Makefile +++ b/Makefile @@ -66,15 +66,15 @@ test: fvt: ginkgo -v -procs=2 --fail-fast fvt/predictor fvt/scaleToZero fvt/storage fvt/hpa --timeout=50m -.PHONY: fvt-protoc -## Regenerate the grpc go files from the proto files -fvt-protoc: +.PHONY: codegen-fvt +## Regenerate grpc code stubs for FVT +codegen-fvt: rm -rf fvt/generated protoc -I=fvt/proto --go_out=plugins=grpc:. --go_opt=module=github.com/kserve/modelmesh-serving $(shell find fvt/proto -iname "*.proto") .PHONY: fvt-with-deploy -## Alias for `oc-login, deploy-release-dev-mode, fvt` -fvt-with-deploy: oc-login deploy-release-dev-mode fvt +## Alias for `oc-login, deploy-release-fvt, fvt` +fvt-with-deploy: oc-login deploy-release-fvt fvt .PHONY: oc-login ## Login to OCP cluster @@ -102,7 +102,7 @@ uninstall: manifests kustomize build config/crd | kubectl delete -f - .PHONY: deploy -## Deploy controller in a Kubernetes cluster +## Deploy manifests to Kubernetes cluster deploy: manifests cd config/manager && kustomize edit set image controller=${IMG} kustomize build config/default | kubectl apply -f - @@ -112,13 +112,14 @@ deploy: manifests deploy-release: ./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config -.PHONY: deploy-release-dev-mode +.PHONY: deploy-release-dev ## Deploy release in dev mode (artifactory creds set via env var) -deploy-release-dev-mode: +deploy-release-dev: ./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging -.PHONY: deploy-release-dev-mode-fvt -deploy-release-dev-mode-fvt: +.PHONY: deploy-release-fvt +## Deploy release in dev mode for FVT tests +deploy-release-fvt: ifdef MODELMESH_SERVING_IMAGE $(eval extra_options += --modelmesh-serving-image ${MODELMESH_SERVING_IMAGE}) endif @@ -127,9 +128,9 @@ ifdef NAMESPACE_SCOPE_MODE endif ./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging --fvt ${extra_options} -.PHONY: delete +.PHONY: undeploy-release ## Undeploy the ModelMesh Serving installation -delete: oc-login +undeploy-release: ./scripts/delete.sh --namespace ${NAMESPACE} --local-config-path config .PHONY: manifests @@ -177,10 +178,6 @@ develop: build.develop run: build.develop ./scripts/develop.sh make $(RUN_ARGS) -.PHONY: docker-build -## Build the Docker image -docker-build: build - .PHONY: push ## Push the controller runtime image push: @@ -199,9 +196,9 @@ else CONTROLLER_GEN=$(shell which controller-gen) endif -.PHONY: mmesh-codegen -## Generate ModelMesh gRPC code stubs -mmesh-codegen: +.PHONY: codegen +## Generate gRPC code stubs (protoc) +codegen: protoc -I proto/ --go_out=plugins=grpc:generated/ $(PROTO_FILES) .PHONY: check-doc-links @@ -213,7 +210,7 @@ check-doc-links: .PHONY: help ## Print Makefile documentation help: - @perl -0 -nle 'printf("\033[36m %-15s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort + @perl -0 -nle 'printf("\033[36m %-20s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort # Override targets if they are included in RUN_ARGs so it doesn't run them twice $(eval $(RUN_ARGS):;@:) diff --git a/docs/developer.md b/docs/developer.md index 8f4623b2..0eaf3a81 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -67,7 +67,7 @@ If you have a custom controller image in your repository, set `MODELMESH_SERVING ```shell NAMESPACE=modelmesh-serving \ MODELMESH_SERVING_IMAGE=quay.io/$org/modelmesh-controller:custom \ -make deploy-release-dev-mode-fvt +make deploy-release-fvt ``` ## Building the developer image