2023-11-14 01:20:34 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script sets up integration tests which run the full stack to verify
|
|
|
|
# inference locally
|
2023-12-23 00:33:27 +00:00
|
|
|
#
|
|
|
|
# To run the relevant tests use
|
|
|
|
# go test -tags=integration ./server
|
2023-11-14 01:20:34 +00:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
REPO=$(dirname $0)/../
|
|
|
|
export OLLAMA_MODELS=${REPO}/test_data/models
|
|
|
|
REGISTRY_SCHEME=https
|
|
|
|
REGISTRY=registry.ollama.ai
|
2023-12-13 22:29:09 +00:00
|
|
|
TEST_MODELS=("library/orca-mini:latest" "library/llava:7b")
|
2023-11-14 01:20:34 +00:00
|
|
|
ACCEPT_HEADER="Accept: application/vnd.docker.distribution.manifest.v2+json"
|
|
|
|
|
2023-12-13 22:29:09 +00:00
|
|
|
for model in ${TEST_MODELS[@]}; do
|
|
|
|
TEST_MODEL=$(echo ${model} | cut -f1 -d:)
|
|
|
|
TEST_MODEL_TAG=$(echo ${model} | cut -f2 -d:)
|
|
|
|
mkdir -p ${OLLAMA_MODELS}/manifests/${REGISTRY}/${TEST_MODEL}/
|
|
|
|
mkdir -p ${OLLAMA_MODELS}/blobs/
|
2023-11-14 01:20:34 +00:00
|
|
|
|
2023-12-13 22:29:09 +00:00
|
|
|
echo "Pulling manifest for ${TEST_MODEL}:${TEST_MODEL_TAG}"
|
|
|
|
curl -s --header "${ACCEPT_HEADER}" \
|
|
|
|
-o ${OLLAMA_MODELS}/manifests/${REGISTRY}/${TEST_MODEL}/${TEST_MODEL_TAG} \
|
2023-12-23 00:33:27 +00:00
|
|
|
${REGISTRY_SCHEME}://${REGISTRY}/v2/${TEST_MODEL}/manifests/${TEST_MODEL_TAG}
|
2023-11-14 01:20:34 +00:00
|
|
|
|
2023-12-13 22:29:09 +00:00
|
|
|
CFG_HASH=$(cat ${OLLAMA_MODELS}/manifests/${REGISTRY}/${TEST_MODEL}/${TEST_MODEL_TAG} | jq -r ".config.digest")
|
|
|
|
echo "Pulling config blob ${CFG_HASH}"
|
2023-11-14 01:20:34 +00:00
|
|
|
curl -L -C - --header "${ACCEPT_HEADER}" \
|
2023-12-23 00:33:27 +00:00
|
|
|
-o ${OLLAMA_MODELS}/blobs/${CFG_HASH} \
|
|
|
|
${REGISTRY_SCHEME}://${REGISTRY}/v2/${TEST_MODEL}/blobs/${CFG_HASH}
|
2023-12-13 22:29:09 +00:00
|
|
|
|
2023-12-23 00:33:27 +00:00
|
|
|
for LAYER in $(cat ${OLLAMA_MODELS}/manifests/${REGISTRY}/${TEST_MODEL}/${TEST_MODEL_TAG} | jq -r ".layers[].digest"); do
|
2023-12-13 22:29:09 +00:00
|
|
|
echo "Pulling blob ${LAYER}"
|
|
|
|
curl -L -C - --header "${ACCEPT_HEADER}" \
|
|
|
|
-o ${OLLAMA_MODELS}/blobs/${LAYER} \
|
|
|
|
${REGISTRY_SCHEME}://${REGISTRY}/v2/${TEST_MODEL}/blobs/${LAYER}
|
|
|
|
done
|
2023-11-29 19:00:37 +00:00
|
|
|
done
|