Skip to content

Commit

Permalink
feat: inference API cleanup (kaito-project#233)
Browse files Browse the repository at this point in the history
This PR does some cleanup on the inference API. Introduces:
1. ModelConfig Dataclass
2. Allow additional user args
3. GenerateKwargs Model
4. More descriptive comments/metadata for model fields
5. Rename inference-api.py -> inference_api.py - needed for naming
convention/importability
6. Introduce tests for inference_api.py

This PR requires bumping up images and having Kaito use updated image
tag (in this case 0.0.2).
  • Loading branch information
ishaansehgal99 authored Feb 21, 2024
1 parent 7f50583 commit 68c972d
Show file tree
Hide file tree
Showing 23 changed files with 497 additions and 214 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
run: |
make unit-test
- name: Run inference api unit tests
run: |
make inference-api-e2e
- name: Upload Codecov report
uses: codecov/codecov-action@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ unit-test: ## Run unit tests.
go test -v $(shell go list ./pkg/... ./api/... | grep -v /vendor) -race -coverprofile=coverage.txt -covermode=atomic
go tool cover -func=coverage.txt

inference-api-e2e:
pip install -r presets/inference/text-generation/requirements.txt
pytest -o log_cli=true -o log_cli_level=INFO .

$(E2E_TEST):
(cd test/e2e && go test -c . -o $(E2E_TEST))

Expand Down
2 changes: 1 addition & 1 deletion docker/presets/tfs-onnx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN echo $VERSION > /workspace/tfs/version.txt
COPY kaito/presets/inference/${MODEL_TYPE}/requirements.txt /workspace/tfs/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

COPY kaito/presets/inference/${MODEL_TYPE}/inference-api.py /workspace/tfs/inference-api.py
COPY kaito/presets/inference/${MODEL_TYPE}/inference_api.py /workspace/tfs/inference_api.py

# Convert to ONNX Runtime
# RUN python convert_to_onnx.py ${MODEL_NAME}
Expand Down
4 changes: 2 additions & 2 deletions docker/presets/tfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.10-slim

ARG WEIGHTS_PATH
ARG MODEL_TYPE
Expand All @@ -16,7 +16,7 @@ RUN echo $VERSION > /workspace/tfs/version.txt
COPY kaito/presets/inference/${MODEL_TYPE}/requirements.txt /workspace/tfs/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

COPY kaito/presets/inference/${MODEL_TYPE}/inference-api.py /workspace/tfs/inference-api.py
COPY kaito/presets/inference/${MODEL_TYPE}/inference_api.py /workspace/tfs/inference_api.py

# Copy the entire model weights to the weights directory
COPY ${WEIGHTS_PATH} /workspace/tfs/weights
182 changes: 0 additions & 182 deletions presets/inference/text-generation/inference-api.py

This file was deleted.

Loading

0 comments on commit 68c972d

Please sign in to comment.