Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/serving-runtime…
Browse files Browse the repository at this point in the history
…-support
  • Loading branch information
disrupted committed Jun 26, 2024
2 parents 92a85d3 + 3999015 commit e551e42
Show file tree
Hide file tree
Showing 103 changed files with 2,864 additions and 19,154 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker-publish-releasing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
# Publish `master` as Docker `latest` image.
branches:
- master
- release-*

paths:
- releasing/VERSION
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/test-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Frontend Test

on:
pull_request:
paths:
- frontend/**

jobs:
frontend-format-linting-check:
name: Code format and lint
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 12

- name: Format code
run: |
npm install prettier@2.8.8 --prefix ./frontend
make prettier-check
- name: Lint code
run: |
cd frontend
npm run lint-check
frontend-unit-tests:
name: Frontend Unit Tests
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 12

- name: Fetch Kubeflow and install common code dependencies
run: |
COMMIT=$(cat frontend/COMMIT)
cd /tmp && git clone https://github.com/kubeflow/kubeflow.git
cd kubeflow
git checkout $COMMIT
cd components/crud-web-apps/common/frontend/kubeflow-common-lib
npm i
npm run build
npm link ./dist/kubeflow
- name: Install MWA dependencies
run: |
cd frontend
npm i
npm link kubeflow
- name: Run unit tests
run: |
cd frontend
npm run test:prod
52 changes: 27 additions & 25 deletions .github/workflows/web-app-docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Models web app Docker Publisher

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
- release-*

# Publish `v1.2.3` tags as releases.
tags:
Expand All @@ -14,7 +14,8 @@ on:
pull_request:

env:
IMAGE_NAME: models-web-app
IMG: kserve/models-web-app
ARCH: linux/ppc64le,linux/amd64,linux/arm64

jobs:
# Run tests.
Expand All @@ -27,12 +28,8 @@ jobs:

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
make docker-build
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
Expand All @@ -45,25 +42,30 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build image
run: |
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ppc64le,arm64

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Push image
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: export version variable
run: |
IMAGE_ID=kserve/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
[ "$TAG" == "master" ] && VERSION=latest
echo TAG=$TAG >> $GITHUB_ENV
- name: Build and push multi-arch docker image
run: |
make docker-build-push-multi-arch
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ FROM ubuntu AS fetch-kubeflow-kubeflow
RUN apt-get update && apt-get install git -y

WORKDIR /kf
COPY ./frontend/COMMIT ./
RUN git clone https://github.com/kubeflow/kubeflow.git && \
COMMIT=$(cat ./COMMIT) && \
cd kubeflow && \
git checkout d1da825
git checkout $COMMIT

# --- Build the backend kubeflow-wheel ---
FROM python:3.7-slim-buster AS backend-kubeflow-wheel
FROM python:3.12-slim AS backend-kubeflow-wheel

WORKDIR /src

Expand All @@ -18,7 +20,7 @@ COPY --from=fetch-kubeflow-kubeflow $BACKEND_LIB .
RUN python setup.py sdist bdist_wheel

# --- Build the frontend kubeflow library ---
FROM node:12-buster-slim AS frontend-kubeflow-lib
FROM node:16-buster-slim AS frontend-kubeflow-lib

WORKDIR /src

Expand All @@ -30,7 +32,7 @@ COPY --from=fetch-kubeflow-kubeflow $LIB/ ./
RUN npm run build

# --- Build the frontend ---
FROM node:12-buster-slim AS frontend
FROM node:16-buster-slim AS frontend

WORKDIR /src
COPY ./frontend/package*.json ./
Expand All @@ -42,7 +44,7 @@ COPY ./frontend/ .
RUN npm run build -- --output-path=./dist/default --configuration=production

# Web App
FROM python:3.7-slim-buster
FROM python:3.12-slim

WORKDIR /package
COPY --from=backend-kubeflow-wheel /src/dist .
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
IMG ?= kserve/models-web-app
TAG ?= $(shell git describe --tags --always --dirty)
ARCH ?= linux/amd64

# We want the git tag to be the last commit to this directory so we don't
# bump the image on unrelated changes.
GIT_TAG ?= $(shell git log -n 1 --pretty=format:"%h" ./)

docker-build:
docker build -t $(IMG):$(GIT_TAG) .
docker build -t ${IMG}:${TAG} .

docker-push:
docker push $(IMG):$(GIT_TAG)
docker push $(IMG):$(TAG)

.PHONY: docker-build-multi-arch
docker-build-multi-arch: ## Build multi-arch docker images with docker buildx
docker buildx build --platform ${ARCH} --tag ${IMG}:${TAG} .


.PHONY: docker-build-push-multi-arch
docker-build-push-multi-arch: ## Build multi-arch docker images with docker buildx and push to docker registry
docker buildx build --platform ${ARCH} --tag ${IMG}:${TAG} --push .

image: docker-build docker-push
8 changes: 6 additions & 2 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
approvers:
- kimwnasptd
- yuzisun
- rimolive
- juliusvonkohout
reviewers:
- elikatsis
- StefanoFioravanzo
- kimwnasptd
- yuzisun
- rimolive
- juliusvonkohout
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Models web app

This web app is responsible for allowing the user to manipulate the Model Servers in their Kubeflow cluster. To achieve this it provides a user friendly way to handle the lifecycle of `InferenceService` CRs.
This web app is responsible for allowing the user to manipulate the Model Servers (Endpoints) in their Kubeflow cluster. To achieve this it provides a user friendly way to handle the lifecycle of `InferenceService` CRs.

The web app currently works with `v1beta1` versions of `InferenceService` objects.

Expand Down Expand Up @@ -38,7 +38,7 @@ vim ${CONFIG}

# reapply the kustomization
# kustomize build config/overlays/kubeflow | kubectl apply -f -
kustomize build config/default | kubectl apply -f -
kustomize build config/base | kubectl apply -f -
```

## Configuration
Expand Down Expand Up @@ -74,8 +74,9 @@ Requirements:
### Frontend
```bash
# build the common library
COMMIT=$(cat ./frontend/COMMIT)
cd $KUBEFLOW_REPO/components/crud-web-apps/common/frontend/kubeflow-common-lib
git checkout e6fdf51
git checkout $COMMIT

npm i
npm run build
Expand Down
19 changes: 18 additions & 1 deletion backend/apps/common/routes/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def get_inference_service_logs(svc):
log.info(components)

# dictionary{component: [pod-names]}
component_pods_dict = utils.get_inference_service_pods(svc, components)
if svc["metadata"]["annotations"].get(
"serving.kubeflow.org/raw", "false") == "true":
component_pods_dict = utils.get_raw_inference_service_pods(
svc, components)
else:
component_pods_dict = utils.get_inference_service_pods(svc, components)

if len(component_pods_dict.keys()) == 0:
return {}
Expand Down Expand Up @@ -94,3 +99,15 @@ def get_knative_route(namespace, name):
name=name)

return api.success_response("knativeRoute", svc)


@bp.route("/api/namespaces/<namespace>/inferenceservices/<name>/events")
def get_inference_service_events(namespace, name):

field_selector = api.events_field_selector("InferenceService", name)

events = api.events.list_events(namespace, field_selector).items

return api.success_response(
"events", api.serialize(events),
)
32 changes: 32 additions & 0 deletions backend/apps/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,40 @@ def load_inference_service_template(**kwargs):
"""
return helpers.load_param_yaml(INFERENCESERVICE_TEMPLATE_YAML, **kwargs)

# helper functions for accessing the logs of an InferenceService in raw
# kubernetes mode


def get_raw_inference_service_pods(svc, components=[]):
"""
Return a dictionary with (endpoint, component) keys
i.e. ("default", "predictor") and a list of pod names as values
"""
namespace = svc["metadata"]["namespace"]
svc_name = svc["metadata"]["name"]
label_selector = "serving.kubeflow.org/inferenceservice={}".format(
svc_name)
pods = api.v1_core.list_namespaced_pod(
namespace, label_selector=label_selector).items
component_pods_dict = {}
for pod in pods:
component = pod.metadata.labels.get("component", "")
if component not in components:
continue

curr_pod_names = component_pods_dict.get(component, [])
curr_pod_names.append(pod.metadata.name)
component_pods_dict[component] = curr_pod_names

if len(component_pods_dict.keys()) == 0:
log.info("No pods are found for inference service: %s",
svc["metadata"]["name"])

return component_pods_dict

# helper functions for accessing the logs of an InferenceService


def get_inference_service_pods(svc, components=[]):
"""
Return the Pod names for the different isvc components.
Expand Down
2 changes: 1 addition & 1 deletion config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ commonLabels:
images:
- name: kserve/models-web-app
newName: kserve/models-web-app
newTag: v0.8.0
newTag: v0.13.0-rc.0
configMapGenerator:
- name: kserve-models-web-app-config
literals:
Expand Down
Loading

0 comments on commit e551e42

Please sign in to comment.