-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abstracting model downloads and file-normalization to models dir
Signed-off-by: greg pereira <[email protected]>
- Loading branch information
1 parent
2fd9933
commit 1c0bc90
Showing
14 changed files
with
213 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ jobs: | |
|
||
- name: Download model | ||
working-directory: ./model_servers/${{ matrix.image_name }}/ | ||
run: make ${{ matrix.model }} | ||
run: make trigger-download-model-${{ matrix.model }} | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
|
@@ -71,8 +71,6 @@ jobs: | |
- name: Run tests | ||
working-directory: ./model_servers/${{ matrix.image_name }}/ | ||
run: make test | ||
env: | ||
IMAGE_NAME: ${{ matrix.image_name }} | ||
|
||
- name: Login to Container Registry | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
REGISTRY ?= quay.io | ||
REGISTRY_ORG ?= ai-lab | ||
COMPONENT_NAME ?= model_servers | ||
|
||
BIND_MOUNT_OPTIONS := ro | ||
OS := $(shell uname -s) | ||
ifeq ($(OS),Linux) | ||
BIND_MOUNT_OPTIONS := Z,ro | ||
endif | ||
|
||
.PHONY: build | ||
build: | ||
podman build --squash-all -t $(IMAGE) . -f base/Containerfile | ||
|
||
.PHONY: install | ||
install: | ||
pip install -r tests/requirements.txt | ||
|
||
.PHONY: run-test | ||
run-test: | ||
REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) MODEL_NAME=$(MODEL_NAME) pytest --log-cli-level NOTSET | ||
|
||
.PHONY: test | ||
test: | ||
@if [ ! -f "../../models/$(MODEL_NAME)" ]; then \ | ||
echo "Model file -- $(MODEL_NAME) -- not present in the models directory."; \ | ||
exit 1; \ | ||
else \ | ||
if [ ! -f "./$(MODEL_NAME)" ]; then \ | ||
ln -s ../../models/$(MODEL_NAME) ./$(MODEL_NAME); \ | ||
fi; \ | ||
$(MAKE) REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) MODEL_NAME=$(MODEL_NAME) -k run-test clean; \ | ||
fi; | ||
|
||
.PHONY: clean | ||
clean: | ||
- rm ./$(MODEL_NAME) &> /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,41 @@ | ||
PORT := 8001 | ||
APP := whispercpp | ||
IMAGE := quay.io/ai-lab/model_servers/$(APP):latest | ||
CUDA_IMAGE := quay.io/ai-lab/model_servers/$(APP)_cuda:latest | ||
VULKAN_IMAGE :=quay.io/ai-lab/model_servers/$(APP)_vulkan:latest | ||
|
||
# ----- MODEL OPTIONS ----- | ||
|
||
WHISPER_SMALL_MODEL_NAME := ggml-small.bin | ||
WHISPER_SMALL_MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin | ||
MODELS_PATH := /app/models | ||
|
||
WHISPER_BASE_MODEL_NAME := ggml-base.en.bin | ||
WHISPER_BASE_MODEL_URL := https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin | ||
REGISTRY ?= quay.io | ||
PORT ?= 8001 | ||
|
||
SELECTED_MODEL_NAME := $(or $(SELECTED_MODEL),$(WHISPER_SMALL_MODEL_NAME)) | ||
SELECTED_MODEL_URL := $(or $(SELECTED_MODEL_LINK),$(WHISPER_SMALL_MODEL_URL)) | ||
IMAGE_NAME ?= $(BASE_IMAGE_NAME)/$(APP):latest | ||
IMAGE ?= $(REGISTRY)/$(IMAGE_NAME) | ||
|
||
# --- END MODEL OPTIONS --- | ||
MODEL_NAME ?= ggml-small.bin | ||
|
||
MODELS_PATH := /app/models | ||
include ../common/Makefile.common | ||
|
||
BIND_MOUNT_OPTIONS := ro | ||
OS := $(shell uname -s) | ||
ifeq ($(OS),Linux) | ||
BIND_MOUNT_OPTIONS := Z,ro | ||
endif | ||
# CUDA_IMAGE_NAME := $(REGISTRY)/$(BASE_IMAGE_NAME)/$(APP)_cuda:latest | ||
# VULKAN_IMAGE := $(REGISTRY)/$(BASE_IMAGE_NAME)/$(APP)_vulkan:latest | ||
|
||
.PHONY: all | ||
all: build whisper-small run | ||
all: build trigger-download-model-whisper-small run | ||
|
||
.PHONY: build | ||
build: | ||
podman build -t $(IMAGE) . -f Containerfile | ||
########################## TRIGGER DOWNLOAD MAKE TARGETS ########################## | ||
### NOTE: you should not add these trigger make targets for new models. | ||
# Adding new models should implemented in the [models directory](../../models). | ||
# These are just provided here for bootstrapping and testing different model types. | ||
|
||
.PHONY: whisper-small | ||
whisper-small: | ||
.PHONY: trigger-download-model-whisper-small # small .bin model type testing | ||
trigger-download-model-whisper-small: | ||
cd ../../models && \ | ||
curl -s -S -L -f $(WHISPER_SMALL_MODEL_URL) -z $(WHISPER_SMALL_MODEL_NAME) -o $(WHISPER_SMALL_MODEL_NAME).tmp && mv -f $(WHISPER_SMALL_MODEL_NAME).tmp $(WHISPER_SMALL_MODEL_NAME) 2>/dev/null || rm -f $(WHISPER_SMALL_MODEL_NAME).tmp $(WHISPER_SMALL_MODEL_NAME) | ||
|
||
.PHONY: install | ||
install: | ||
pip install -r tests/requirements.txt | ||
make -f Makefile download-model-whisper-small | ||
|
||
.PHONY: download-model-whisper-base | ||
download-model-whisper-base: | ||
.PHONY: trigger-download-model-whisper-base # default model | ||
trigger-download-model-whisper-base: | ||
cd ../../models && \ | ||
curl -s -S -L -f $(WHISPER_BASE_MODEL_URL) -z $(WHISPER_BASE_MODEL_NAME) -o $(WHISPER_BASE_MODEL_NAME).tmp && mv -f $(WHISPER_BASE_MODEL_NAME).tmp $(WHISPER_BASE_MODEL_NAME) 2>/dev/null || rm -f $(WHISPER_BASE_MODEL_NAME).tmp $(WHISPER_BASE_MODEL_NAME) | ||
make -f Makefile download-model-whisper-base | ||
|
||
############################ END DOWNLOAD MAKE TARGETS ############################ | ||
|
||
.PHONY: run | ||
run: | ||
cd ../../models && \ | ||
podman run -d --rm -it -p $(PORT):$(PORT) -v ./$(SELECTED_MODEL_NAME):$(MODELS_PATH)/$(SELECTED_MODEL_NAME):$(BIND_MOUNT_OPTIONS) -e HOST=0.0.0.0 -e MODEL_PATH=$(MODELS_PATH)/$(SELECTED_MODEL_NAME) -e PORT=$(PORT) $(IMAGE) | ||
podman run -d -it -p $(PORT):$(PORT) -v ./$(MODEL_NAME):$(MODELS_PATH)/$(MODEL_NAME):$(BIND_MOUNT_OPTIONS) -e HOST=0.0.0.0 -e MODEL_PATH=$(MODELS_PATH)/$(MODEL_NAME) -e PORT=$(PORT) --network=host $(IMAGE) | ||
|
||
.PHONY: test | ||
test: | ||
curl -H "Cache-Control: no-cache" -s -S -L -f $(SELECTED_MODEL_URL) -z ./model.gguf -o ./model.gguf.tmp && mv -f ./model.gguf.tmp ./model.gguf 2>/dev/null || rm -f ./model.gguf.tmp ./model.gguf | ||
pytest --log-cli-level NOTSET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.