Skip to content

Commit

Permalink
add smoketest for caikit+tgis
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrifiro committed Oct 20, 2023
1 parent b69f9f4 commit 537e3b9
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/models/
/.venv/
/flan-t5-small
30 changes: 30 additions & 0 deletions test/caikit_config/caikit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
runtime:
library: caikit_nlp
local_models_dir: /mnt/models
lazy_load_local_models: true

model_management:
finders:
default:
type: MULTI
config:
finder_priority:
- tgis-auto
# - local
tgis-auto:
type: TGIS-AUTO
config:
test_connections: true
initializers:
default:
type: LOCAL
config:
backend_priority:
- type: TGIS
config:
connection:
hostname: tgis:8033
test_connections: true

log:
formatter: pretty
21 changes: 21 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
caikit:
# image: quay.io/opendatahub/caikit:latest
build: ..
volumes:
- ./caikit_config:/caikit/config
- ./models/flan-t5-small-caikit/:/mnt/models/
ports:
- 8085:8085
tgis:
image: quay.io/opendatahub/text-generation-inference:stable
command: [
"text-generation-launcher", # NOTE:--num-shard defaults to 1
"--model-name=/mnt/models/artifacts/",
"--max-batch-size=256",
"--max-concurrent-requests=64",
]
volumes:
- ./models/flan-t5-small-caikit/:/mnt/models
environment:
- "TRANSFORMERS_CACHE=/tmp/transformers_cache"
50 changes: 50 additions & 0 deletions test/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -euo pipefail

function command_required() {
local cmd
cmd=$1
if ! command -v $cmd &>/dev/null; then
echo "This requires $cmd" 2>&1
exit 1
fi
}

command_required python3
command_required docker-compose
command_required git-lfs

if [[ ! -d .venv ]]; then
python -m venv .venv || (echo "Failed to create venv. Quitting." >&2 && exit 1)
fi
source .venv/bin/activate || (echo "Could not source venv. Quitting" >&2 && exit 1)

pip install git+https://github.com/caikit/caikit-nlp
if [[ ! -d flan-t5-small ]]; then
git clone https://huggingface.co/google/flan-t5-small
fi

mkdir -p models/
../utils/convert.py --model-path flan-t5-small --model-save-path models/flan-t5-small-caikit/

echo "Saved caikit model to ./models/"

docker-compose up -d

max_retries=10
until grpcurl -plaintext \
-d '{"text": "At what temperature celsius does Nitrogen boil?"}' \
-H "mm-model-id: flan-t5-small-caikit" \
127.0.0.1:8085 \
caikit.runtime.Nlp.NlpService/TextGenerationTaskPredict; do
sleep 3
max_retries=$((max_retries - 1))
if [[ $max_retries -le 0 ]]; then
echo "Failed to query grpc service" >&2
docker-compose down
exit 1
fi
done

docker-compose down
echo "👍 Test successful!"

0 comments on commit 537e3b9

Please sign in to comment.