Skip to content

Commit ccb650b

Browse files
Merge branch 'FixInStyling' of github.com:chandanasirigineedi/model-registry into FixInStyling
2 parents 957296b + 1d1dd91 commit ccb650b

55 files changed

Lines changed: 1902 additions & 309 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-push-ui-images-standalone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
5454
- name: Extract metadata (tags, labels) for Docker
5555
id: meta
56-
uses: docker/metadata-action@v4
56+
uses: docker/metadata-action@v5
5757
with:
5858
images: "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO }}"
5959
tags: |

.github/workflows/check-openapi-spec-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
validate:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v4
1111
- name: Validate OpenAPI spec
1212
run: |
1313
make openapi/validate
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test Controller
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
paths-ignore:
7+
- "LICENSE*"
8+
- "**.gitignore"
9+
- "**.md"
10+
- "**.txt"
11+
- ".github/ISSUE_TEMPLATE/**"
12+
- ".github/dependabot.yml"
13+
- "docs/**"
14+
pull_request:
15+
paths:
16+
- "cmd/controller/**"
17+
- "internal/controller/**"
18+
- "internal/server/openapi/api_model_registry_service*"
19+
- "pkg/openapi/**"
20+
- "go.mod"
21+
22+
env:
23+
BRANCH: ${{ github.base_ref }}
24+
jobs:
25+
test:
26+
name: Run on Ubuntu
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Clone the code
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: '~1.22'
36+
37+
- name: Running Tests
38+
run: |
39+
go mod tidy
40+
make controller/test

Makefile

Lines changed: 137 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PROJECT_BIN := $(PROJECT_PATH)/bin
55
GO ?= "$(shell which go)"
66
UI_PATH := $(PROJECT_PATH)/clients/ui
77
CSI_PATH := $(PROJECT_PATH)/cmd/csi
8+
CONTROLLER_PATH := $(PROJECT_PATH)/cmd/controller
89

910
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1011
ENVTEST_K8S_VERSION = 1.29
@@ -47,6 +48,11 @@ ifeq ($(IMG_REPO),model-registry/storage-initializer)
4748
DOCKERFILE := $(CSI_PATH)/Dockerfile.csi
4849
endif
4950

51+
# The BUILD_PATH is still the root
52+
ifeq ($(IMG_REPO),model-registry/controller)
53+
DOCKERFILE := $(CONTROLLER_PATH)/Dockerfile.controller
54+
endif
55+
5056
model-registry: build
5157

5258
# clean the ml-metadata protos and trigger a fresh new build which downloads
@@ -133,7 +139,7 @@ clean-pkg-openapi:
133139
clean-internal-server-openapi:
134140
while IFS= read -r file; do rm -f "internal/server/openapi/$$file"; done < internal/server/openapi/.openapi-generator/FILES
135141

136-
.PHONY: clean
142+
.PHONY: clean
137143
clean: clean-pkg-openapi clean-internal-server-openapi clean/csi
138144
rm -Rf ./model-registry internal/ml_metadata/proto/*.go internal/converter/generated/*.go
139145

@@ -158,7 +164,7 @@ bin/envtest:
158164

159165
GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint
160166
bin/golangci-lint:
161-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.61.0
167+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v2.0.2
162168

163169
GOVERTER ?= ${PROJECT_BIN}/goverter
164170
bin/goverter:
@@ -232,12 +238,12 @@ gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter
232238
${GO} generate ./...
233239

234240
.PHONY: lint
235-
lint:
241+
lint: bin/golangci-lint
236242
${GOLANGCI_LINT} run main.go --timeout 3m
237243
${GOLANGCI_LINT} run cmd/... internal/... ./pkg/... --timeout 3m
238244

239245
.PHONY: lint/csi
240-
lint/csi:
246+
lint/csi: bin/golangci-lint
241247
${GOLANGCI_LINT} run ${CSI_PATH}/main.go
242248
${GOLANGCI_LINT} run internal/csi/...
243249

@@ -308,3 +314,130 @@ image/push:
308314
${DOCKER} push ${IMG}:$(IMG_VERSION)
309315

310316
all: model-registry
317+
318+
## ------------------------------- ##
319+
## ---- Controller Targets ---- ##
320+
## ------------------------------- ##
321+
322+
##@ Development
323+
324+
.PHONY: controller/manifests
325+
controller/manifests: bin/controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
326+
$(CONTROLLER_GEN) rbac:roleName=model-registry-manager-role crd webhook paths="{./cmd/controller/..., ./internal/controller/...}" output:crd:artifacts:config=manifests/options/controller/crd/bases output:rbac:dir=manifests/kustomize/options/controller/rbac
327+
328+
.PHONY: controller/generate
329+
controller/generate: bin/controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
330+
$(CONTROLLER_GEN) object:headerFile="./cmd/controller/hack/boilerplate.go.txt" paths="{./cmd/controller/..., ./internal/controller/...}"
331+
332+
.PHONY: controller/fmt
333+
controller/fmt: ## Run go fmt against code.
334+
go fmt ./cmd/controller/... ./internal/controller/...
335+
336+
.PHONY: controller/vet
337+
controller/vet: ## Run go vet against code.
338+
go vet ./cmd/controller/... ./internal/controller/...
339+
340+
.PHONY: controller/test
341+
controller/test: controller/manifests controller/generate controller/fmt controller/vet bin/envtest ## Run tests.
342+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(PROJECT_BIN) -p path)" go test $$(go list ./internal/controller/... | grep -v /e2e) -coverprofile cover.out
343+
344+
##@ Build
345+
346+
.PHONY: controller/build
347+
controller/build: controller/manifests controller/generate controller/fmt controller/vet ## Build manager binary.
348+
go build -o bin/manager cmd/controller/main.go
349+
350+
.PHONY: controller/run
351+
controller/run: controller/manifests controller/generate controller/fmt controller/vet ## Run a controller from your host.
352+
go run ./cmd/controller/main.go
353+
354+
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
355+
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
356+
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
357+
.PHONY: controller/docker-build
358+
controller/docker-build: ## Build docker image with the manager.
359+
$(DOCKER) build -t ${IMG} -f ./cmd/controller/Dockerfile.controller .
360+
361+
.PHONY: controller/docker-push
362+
controller/docker-push: ## Push docker image with the manager.
363+
$(DOCKER) push ${IMG}
364+
365+
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
366+
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
367+
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
368+
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
369+
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
370+
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
371+
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
372+
.PHONY: controller/docker-buildx
373+
controller/docker-buildx: ## Build and push docker image for the manager for cross-platform support
374+
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
375+
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' ./cmd/controller/Dockerfile.controller > Dockerfile.cross
376+
- $(DOCKER) buildx create --name controller-builder
377+
$(DOCKER) buildx use controller-builder
378+
- $(DOCKER) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
379+
- $(DOCKER) buildx rm controller-builder
380+
rm Dockerfile.cross
381+
382+
.PHONY: controller/build-installer
383+
controller/build-installer: controller/manifests controller/generate bin/kustomize ## Generate a consolidated YAML with CRDs and deployment.
384+
mkdir -p dist
385+
cd manifests/kustomize/options/controller/manager && $(KUSTOMIZE) edit set image controller=${IMG}
386+
$(KUSTOMIZE) build manifests/kustomize/options/controller/default > dist/install.yaml
387+
388+
##@ Deployment
389+
390+
ifndef ignore-not-found
391+
ignore-not-found = false
392+
endif
393+
394+
.PHONY: controller/install
395+
controller/install: controller/manifests bin/kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
396+
$(KUSTOMIZE) build manifests/kustomize/options/controller/crd | $(KUBECTL) apply -f -
397+
398+
.PHONY: controller/uninstall
399+
controller/uninstall: controller/manifests bin/kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
400+
$(KUSTOMIZE) build manifests/kustomize/options/controller/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
401+
402+
.PHONY: controller/deploy
403+
controller/deploy: controller/manifests bin/kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
404+
cd manifests/kustomize/options/controller/manager && $(KUSTOMIZE) edit set image ghcr.io/kubeflow/model-registry/controller=${IMG}:${IMG_VERSION}
405+
$(KUSTOMIZE) build manifests/kustomize/options/controller/overlays/base | $(KUBECTL) apply -f -
406+
407+
.PHONY: controller/undeploy
408+
controller/undeploy: bin/kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
409+
$(KUSTOMIZE) build manifests/kustomize/options/controller/overlays/base | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
410+
411+
##@ Tools
412+
413+
KUBECTL ?= kubectl
414+
CONTROLLER_GEN ?= $(PROJECT_BIN)/controller-gen
415+
KUSTOMIZE ?= $(PROJECT_BIN)/kustomize
416+
CONTROLLER_TOOLS_VERSION ?= v0.16.4
417+
KUSTOMIZE_VERSION ?= v5.5.0
418+
419+
.PHONY: bin/kustomize
420+
bin/kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
421+
$(KUSTOMIZE): $(PROJECT_BIN)
422+
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
423+
424+
.PHONY: bin/controller-gen
425+
bin/controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
426+
$(CONTROLLER_GEN): $(PROJECT_BIN)
427+
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
428+
429+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
430+
# $1 - target path with name of binary
431+
# $2 - package url which can be installed
432+
# $3 - specific version of package
433+
define go-install-tool
434+
@[ -f "$(1)-$(3)" ] || { \
435+
set -e; \
436+
package=$(2)@$(3) ;\
437+
echo "Downloading $${package}" ;\
438+
rm -f $(1) || true ;\
439+
GOBIN=$(PROJECT_BIN) go install $${package} ;\
440+
mv $(1) $(1)-$(3) ;\
441+
} ;\
442+
ln -sf $(1)-$(3) $(1)
443+
endef

api/openapi/model-registry.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ paths:
8282
$ref: "#/components/responses/BadRequest"
8383
"401":
8484
$ref: "#/components/responses/Unauthorized"
85+
"409":
86+
$ref: "#/components/responses/Conflict"
8587
"500":
8688
$ref: "#/components/responses/InternalServerError"
8789
"503":
@@ -471,6 +473,8 @@ paths:
471473
$ref: "#/components/responses/BadRequest"
472474
"401":
473475
$ref: "#/components/responses/Unauthorized"
476+
"409":
477+
$ref: "#/components/responses/Conflict"
474478
"500":
475479
$ref: "#/components/responses/InternalServerError"
476480
"503":
@@ -904,6 +908,8 @@ paths:
904908
$ref: "#/components/responses/Unauthorized"
905909
"404":
906910
$ref: "#/components/responses/NotFound"
911+
"409":
912+
$ref: "#/components/responses/Conflict"
907913
"500":
908914
$ref: "#/components/responses/InternalServerError"
909915
"503":
@@ -1093,6 +1099,8 @@ paths:
10931099
$ref: "#/components/responses/Unauthorized"
10941100
"404":
10951101
$ref: "#/components/responses/NotFound"
1102+
"409":
1103+
$ref: "#/components/responses/Conflict"
10961104
"500":
10971105
$ref: "#/components/responses/InternalServerError"
10981106
"503":

clients/python/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.nox/
66
/.python-version
77
__pycache__/
8+
venv/

clients/python/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Common S3 env vars will be automatically read, such ass the access_key_id, etc.
202202

203203
```python
204204
s3_upload_params = S3Params(
205-
bucket="my-bucket",
205+
bucket_name="my-bucket",
206206
s3_prefix="models/my_fraud_model",
207207
)
208208

@@ -333,4 +333,8 @@ To run the e2e tests you will need [kind](https://kind.sigs.k8s.io/) to be insta
333333
Check out our [recommendations on setting up your docker engine](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#docker-engine) on an ARM processor.
334334

335335

336+
### Troubleshooting
337+
338+
- On running `make test test-e2e` if you see a similar problem `unknown flag: --load`, install [buildx](https://formulae.brew.sh/formula/docker-buildx)
339+
336340
<!-- github-only -->

0 commit comments

Comments
 (0)