-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathimport-ai-lab-samples
executable file
·76 lines (56 loc) · 2.6 KB
/
import-ai-lab-samples
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
# Flags scripts to use experiment branch for the samples
export SAMPLE_BRANCH=experiment
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$(realpath $SCRIPTDIR/..)
SKELETON_DIR=$ROOT_DIR/skeleton
TEMPLATE_DIR=$ROOT_DIR/templates
REPO="${SAMPLE_REPO:-https://github.com/redhat-ai-dev/ai-lab-samples}"
BRANCH="${SAMPLE_BRANCH:-main}"
DIRNAME=$(basename $REPO)
TEMPLATE_TECHDOC_TYPE=app
mkdir -p $SCRIPTDIR/samples
SAMPLE_DIR=$SCRIPTDIR/samples/$DIRNAME
if [ -d $SAMPLE_DIR ]; then
(cd $SAMPLE_DIR; git pull 2>&1 > /dev/null)
else
(cd $SCRIPTDIR/samples; git clone $REPO 2>&1 > /dev/null)
fi
(cd $SAMPLE_DIR; git checkout $BRANCH; git pull)
cd $SAMPLE_DIR
# get readme to source component doc
cp -r $SAMPLE_DIR/README.md $SKELETON_DIR/techdoc/docs/source-component.md
for f in */; do
if [ -d "$f" ]; then
# $f is a directory
SAMPLENAME=$(basename $f)
DEST=$TEMPLATE_DIR/$SAMPLENAME
rm -rf $DEST
mkdir -p $DEST
cp -r $SAMPLE_DIR/$SAMPLENAME $DEST/content
# add template card docs
cp -r $SKELETON_DIR/template-card-techdocs/$TEMPLATE_TECHDOC_TYPE/docs $DEST/docs
cp -r $SKELETON_DIR/template-card-techdocs/mkdocs.yml $DEST/mkdocs.yml
cp $ROOT_DIR/skeleton/template.yaml $DEST/template.yaml
source $SCRIPTDIR/envs/$SAMPLENAME
if [ -f $f/Containerfile ]; then
sed -i "s!sed.edit.DOCKERFILE!Containerfile!g" $DEST/template.yaml
sed -i "s!sed.edit.BUILDCONTEXT!.!g" $DEST/template.yaml
fi
sed -i "s!sed.edit.NAME!$APP_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.TITLE!$APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.DESCRIPTION!$APP_DESC!g" $DEST/template.yaml
sed -i "s!sed.edit.APPTAGS!$APP_TAGS!g" $DEST/template.yaml
sed -i "s!sed.edit.CATALOG_DESCRIPTION!Secure Supply Chain Example for $APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.APP_DISPLAY_NAME!$APP_DISPLAY_NAME!g" $DEST/docs/index.md
sed -i "s!sed.edit.TEMPLATE_SOURCE_URL!$TEMPLATE_SOURCE_URL!g" $DEST/docs/index.md
sed -i "s!sed.edit.LLM_MODEL_NAME!$LLM_MODEL_NAME!g" $DEST/docs/index.md
sed -i "s!sed.edit.LLM_MODEL_SRC!$LLM_MODEL_SRC!g" $DEST/docs/index.md
if [ $SUPPORT_VLLM == false ]; then
sed -i '/# SED_MODEL_SERVER_START/,/# SED_MODEL_SERVER_END/d' $DEST/template.yaml
fi
source $ROOT_DIR/properties
cat $DEST/template.yaml | envsubst > $DEST/new-template.yaml
mv $DEST/new-template.yaml $DEST/template.yaml
fi
done
rm -rf $SCRIPTDIR/samples