Skip to content

Commit 38b0254

Browse files
committed
Add model registry sync script
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
1 parent d5356a2 commit 38b0254

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ This repo periodically syncs all official Kubeflow components from their respect
5959
| KServe Models Web App | contrib/kserve/models-web-app | [v0.10.0](https://github.com/kserve/models-web-app/tree/v0.10.0/config) |
6060
| Kubeflow Pipelines | apps/pipeline/upstream | [2.0.5](https://github.com/kubeflow/pipelines/tree/2.0.5/manifests/kustomize) |
6161
| Kubeflow Tekton Pipelines | apps/kfp-tekton/upstream | [2.0.5](https://github.com/kubeflow/kfp-tekton/tree/2.0.5/manifests/kustomize) |
62+
| Kubeflow Model Registry | apps/model-registry/upstream | [main](https://github.com/kubeflow/model-registry/tree/main/manifests/kustomize) |
6263

6364
The following is also a matrix with versions from common components that are
6465
used from the different projects of Kubeflow:

hack/sync-model-registry-manifests.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
3+
# This script aims at helping create a PR to update the manifests of the
4+
# kubeflow/model-registry repo.
5+
# This script:
6+
# 1. Checks out a new branch
7+
# 2. Copies files to the correct places
8+
# 3. Commits the changes
9+
#
10+
# Afterwards the developers can submit the PR to the kubeflow/manifests
11+
# repo, based on that local branch
12+
13+
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
14+
set -euo pipefail
15+
IFS=$'\n\t'
16+
17+
DEV_MODE=${DEV_MODE:=false}
18+
SRC_DIR=${SRC_DIR:=/tmp/kubeflow-model-registry}
19+
BRANCH=${BRANCH:=sync-kubeflow-model-registry-manifests-${COMMIT?}}
20+
21+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
22+
MANIFESTS_DIR=$(dirname $SCRIPT_DIR)
23+
24+
if [ "$DEV_MODE" != "false" ]; then
25+
echo "WARNING: Dev mode enabled..."
26+
fi
27+
28+
echo "Creating branch: ${BRANCH}"
29+
30+
# DEV: Comment out this if you are testing locally
31+
if [ -n "$(git status --porcelain)" ]; then
32+
# Uncommitted changes
33+
echo "WARNING: You have uncommitted changes, exiting..."
34+
exit 1
35+
fi
36+
37+
if [ `git branch --list $BRANCH` ]
38+
then
39+
echo "WARNING: Branch $BRANCH already exists. Exiting..."
40+
exit 1
41+
fi
42+
43+
# DEV: If you are testing locally set DEV_MODE=true to skip this step
44+
if [ "$DEV_MODE" = "false" ]; then
45+
git checkout -b $BRANCH
46+
fi
47+
48+
echo "Checking out in $SRC_DIR to $COMMIT..."
49+
cd $SRC_DIR
50+
if [ -n "$(git status --porcelain)" ]; then
51+
# Uncommitted changes
52+
echo "WARNING: You have uncommitted changes, exiting..."
53+
exit 1
54+
fi
55+
git checkout $COMMIT
56+
57+
echo "Copying model-registry manifests..."
58+
DST_DIR=$MANIFESTS_DIR/apps/model-registry/upstream
59+
rm -rf $DST_DIR
60+
mkdir -p $DST_DIR
61+
cp $SRC_DIR/manifests/kustomize/* $DST_DIR -r
62+
63+
echo "Successfully copied all manifests."
64+
65+
echo "Updating README..."
66+
SRC_TXT="\[.*\](https://github.com/kubeflow/model-registry/tree/.*/manifests/kustomize)"
67+
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/model-registry/tree/$COMMIT/manifests/kustomize)"
68+
69+
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
70+
71+
# DEV: If you are testing locally set DEV_MODE=true to skip this step
72+
if [ "$DEV_MODE" = "false" ]; then
73+
echo "Committing the changes..."
74+
cd $MANIFESTS_DIR
75+
git add apps
76+
git add README.md
77+
git commit -s -m "Update kubeflow/model-registry manifests from ${COMMIT}"
78+
fi

0 commit comments

Comments
 (0)