From ae18ea872df89c14d4b4ba1ab42c99f2635f7f41 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:43:21 -0400 Subject: [PATCH 01/18] use python 3.12 to avoid 3.11 cve, use arg for python version --- services/finetuning/Dockerfile | 9 +++++---- services/inference/Dockerfile | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/services/finetuning/Dockerfile b/services/finetuning/Dockerfile index 64406230..fa03920f 100644 --- a/services/finetuning/Dockerfile +++ b/services/finetuning/Dockerfile @@ -1,11 +1,12 @@ # based on https://github.com/opendatahub-io/caikit-tgis-serving/blob/main/Dockerfile FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS builder +ARG PYTHON_VERSION=3.12 RUN microdnf -y update && \ microdnf -y install \ - git shadow-utils python3.11-pip python-wheel && \ - pip3.11 install --no-cache-dir --upgrade pip wheel && \ + git shadow-utils python${PYTHON_VERSION}-pip python$(PYTHON_VERSION)-wheel && \ + pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ microdnf clean all ENV POETRY_VIRTUALENVS_IN_PROJECT=1 @@ -15,12 +16,12 @@ COPY tsfmfinetuning/* /finetuning/tsfmfinetuning/ COPY pyproject.toml /finetuning/ COPY poetry.lock /finetuning/ WORKDIR /finetuning -RUN pip3.11 install poetry && poetry install +RUN pip${PYTHON_VERSION} install poetry && poetry install FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS deploy RUN microdnf -y update && \ microdnf -y install \ - shadow-utils python3.11 && \ + shadow-utils python${PYTHON_VERSION} && \ microdnf clean all WORKDIR /finetuning diff --git a/services/inference/Dockerfile b/services/inference/Dockerfile index a09a6564..21048755 100644 --- a/services/inference/Dockerfile +++ b/services/inference/Dockerfile @@ -1,11 +1,12 @@ # based on https://github.com/opendatahub-io/caikit-tgis-serving/blob/main/Dockerfile FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS builder +ARG PYTHON_VERSION=3.12 RUN microdnf -y update && \ microdnf -y install \ - git shadow-utils python3.11-pip python-wheel && \ - pip3.11 install --no-cache-dir --upgrade pip wheel && \ + git shadow-utils python${PYTHON_VERSION}-pip python$(PYTHON_VERSION)-wheel && \ + pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ microdnf clean all ENV POETRY_VIRTUALENVS_IN_PROJECT=1 @@ -15,12 +16,12 @@ COPY tsfminference/* /inference/tsfminference/ COPY pyproject.toml /inference/ COPY poetry.lock /inference/ WORKDIR /inference -RUN pip3.11 install poetry && poetry install +RUN pip${PYTHON_VERSION} install poetry && poetry install FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS deploy RUN microdnf -y update && \ microdnf -y install \ - shadow-utils python3.11 && \ + shadow-utils python${PYTHON_VERSION} && \ microdnf clean all WORKDIR /inference From 7fb24dd2fa840663d47934334d5a2bc114e3eb78 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:43:50 -0400 Subject: [PATCH 02/18] run image test for inference too --- .github/workflows/inference-services-test.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/inference-services-test.yml b/.github/workflows/inference-services-test.yml index dbdc1e96..10bcbc6f 100644 --- a/.github/workflows/inference-services-test.yml +++ b/.github/workflows/inference-services-test.yml @@ -36,9 +36,12 @@ jobs: - name: Test local server tsfminference service with pytest run: | source .venv/bin/activate - cd services/inference + cd services/tsfminference make boilerplate - make start_service_local - sleep 20 pytest tests - make stop_service_local || true + - name: Test image server tsfminference service with pytest + run: | + source .venv/bin/activate + cd services/tsfminference + make image + make test_image From a9938e72888951ce7a3ab0cc28c4d11c59d0ce4f Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:53:52 -0400 Subject: [PATCH 03/18] :typo: --- .github/workflows/inference-services-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/inference-services-test.yml b/.github/workflows/inference-services-test.yml index 10bcbc6f..954c26cf 100644 --- a/.github/workflows/inference-services-test.yml +++ b/.github/workflows/inference-services-test.yml @@ -36,12 +36,12 @@ jobs: - name: Test local server tsfminference service with pytest run: | source .venv/bin/activate - cd services/tsfminference + cd services/inference make boilerplate pytest tests - name: Test image server tsfminference service with pytest run: | source .venv/bin/activate - cd services/tsfminference + cd services/inference make image make test_image From 10965292baccbd0d2054cc25ad715801328aaae3 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:07:07 -0400 Subject: [PATCH 04/18] ty to use make targets instead --- .github/workflows/finetuning-service-test.yml | 6 ++---- .github/workflows/inference-services-test.yml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/finetuning-service-test.yml b/.github/workflows/finetuning-service-test.yml index 899807ed..cec99cc5 100644 --- a/.github/workflows/finetuning-service-test.yml +++ b/.github/workflows/finetuning-service-test.yml @@ -37,12 +37,10 @@ jobs: run: | source .venv/bin/activate cd services/finetuning - make boilerplate - pytest tests + make test_service_local - name: Test image server tsfmfinetuning service with pytest run: | source .venv/bin/activate cd services/finetuning - make image - make test_image + make test_service_image \ No newline at end of file diff --git a/.github/workflows/inference-services-test.yml b/.github/workflows/inference-services-test.yml index 954c26cf..2825f795 100644 --- a/.github/workflows/inference-services-test.yml +++ b/.github/workflows/inference-services-test.yml @@ -37,11 +37,9 @@ jobs: run: | source .venv/bin/activate cd services/inference - make boilerplate - pytest tests + make test_service_local - name: Test image server tsfminference service with pytest run: | source .venv/bin/activate cd services/inference - make image - make test_image + make test_service_image From 58907ab4645cd7d0cfb405fcecfc1e71d9161da0 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:04:01 -0400 Subject: [PATCH 05/18] formatting, sleep only 5 after container start --- services/inference/Makefile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/services/inference/Makefile b/services/inference/Makefile index c8d64c2f..1a87b321 100644 --- a/services/inference/Makefile +++ b/services/inference/Makefile @@ -23,15 +23,7 @@ image: boilerplate start_service_image: image $(CONTAINER_BUILDER) run -p 8000:8000 -d --rm --name tsfmserver tsfminference - sleep 10 - -start_service_image_no_hf: image - $(CONTAINER_BUILDER) run -p 8000:8000 \ - -e "TSFM_ALLOW_LOAD_FROM_HF_HUB=0" \ - -e "TSFM_MODEL_DIR=/" \ - -v ./ibm:/ibm \ - --rm --name tsfmserver tsfminference - sleep 10 + sleep 5 stop_service_image: $(CONTAINER_BUILDER) stop tsfmserver From 32dffe90aab200974cbf4e4ed65bf33f888e2115 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:04:20 -0400 Subject: [PATCH 06/18] simplify build, didn't really need a builder --- services/inference/Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/services/inference/Dockerfile b/services/inference/Dockerfile index 21048755..843b17f2 100644 --- a/services/inference/Dockerfile +++ b/services/inference/Dockerfile @@ -1,11 +1,15 @@ # based on https://github.com/opendatahub-io/caikit-tgis-serving/blob/main/Dockerfile -FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS builder +FROM registry.access.redhat.com/ubi9/ubi-minimal:latest ARG PYTHON_VERSION=3.12 RUN microdnf -y update && \ microdnf -y install \ - git shadow-utils python${PYTHON_VERSION}-pip python$(PYTHON_VERSION)-wheel && \ + git \ + shadow-utils \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-pip \ + python$(PYTHON_VERSION)-wheel && \ pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ microdnf clean all @@ -18,15 +22,6 @@ COPY poetry.lock /inference/ WORKDIR /inference RUN pip${PYTHON_VERSION} install poetry && poetry install -FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS deploy -RUN microdnf -y update && \ - microdnf -y install \ - shadow-utils python${PYTHON_VERSION} && \ - microdnf clean all - -WORKDIR /inference - -COPY --from=builder /inference /inference ENV VIRTUAL_ENV=/inference/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" From c0f569c7ab802ba0780c291b04a7e1b54fc07b6d Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:14:18 -0400 Subject: [PATCH 07/18] :typo: --- .github/workflows/inference-services-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/inference-services-test.yml b/.github/workflows/inference-services-test.yml index 2825f795..aa132bb9 100644 --- a/.github/workflows/inference-services-test.yml +++ b/.github/workflows/inference-services-test.yml @@ -37,9 +37,9 @@ jobs: run: | source .venv/bin/activate cd services/inference - make test_service_local + make test_local - name: Test image server tsfminference service with pytest run: | source .venv/bin/activate cd services/inference - make test_service_image + make test_image From c21c2aa8fbe1f0bc0f695fd5ebdc70b83dfaf21f Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:02:51 -0400 Subject: [PATCH 08/18] finetuning tests are simplified for now --- .github/workflows/finetuning-service-test.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/finetuning-service-test.yml b/.github/workflows/finetuning-service-test.yml index cec99cc5..3af8aa74 100644 --- a/.github/workflows/finetuning-service-test.yml +++ b/.github/workflows/finetuning-service-test.yml @@ -33,14 +33,13 @@ jobs: cd services/finetuning poetry self add "poetry-dynamic-versioning[plugin]" poetry install -n --with dev - - name: Test local server tsfmfinetuning service with pytest + # for not we're not really using the image + # for much, we just want to make sure + # that it continues to build until we + # do so + - name: Test image build run: | source .venv/bin/activate cd services/finetuning - make test_service_local - - name: Test image server tsfmfinetuning service with pytest - run: | - source .venv/bin/activate - cd services/finetuning - make test_service_image + make image \ No newline at end of file From 83aecda1bfa580f9b59288746346dc2e0c58ca66 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:04:01 -0400 Subject: [PATCH 09/18] no builder, no CMD for now --- services/finetuning/Dockerfile | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/services/finetuning/Dockerfile b/services/finetuning/Dockerfile index fa03920f..71d4fec5 100644 --- a/services/finetuning/Dockerfile +++ b/services/finetuning/Dockerfile @@ -1,11 +1,15 @@ # based on https://github.com/opendatahub-io/caikit-tgis-serving/blob/main/Dockerfile -FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS builder +FROM registry.access.redhat.com/ubi9/ubi-minimal:latest ARG PYTHON_VERSION=3.12 RUN microdnf -y update && \ microdnf -y install \ - git shadow-utils python${PYTHON_VERSION}-pip python$(PYTHON_VERSION)-wheel && \ + git \ + shadow-utils \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-pip \ + python$(PYTHON_VERSION)-wheel && \ pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ microdnf clean all @@ -18,15 +22,6 @@ COPY poetry.lock /finetuning/ WORKDIR /finetuning RUN pip${PYTHON_VERSION} install poetry && poetry install -FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS deploy -RUN microdnf -y update && \ - microdnf -y install \ - shadow-utils python${PYTHON_VERSION} && \ - microdnf clean all - -WORKDIR /finetuning - -COPY --from=builder /finetuning /finetuning ENV VIRTUAL_ENV=/finetuning/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" @@ -39,4 +34,5 @@ RUN groupadd --system tsfmfinetuning --gid 1001 && \ USER tsfmfinetuning -CMD ["python","-m","gunicorn","-w","4","-k","uvicorn.workers.UvicornWorker","--bind","0.0.0.0:8000","tsfmfinetuning.main:app"] \ No newline at end of file +# currently finetuning is not a service hosting platform +# CMD ["python","-m","gunicorn","-w","4","-k","uvicorn.workers.UvicornWorker","--bind","0.0.0.0:8000","tsfmfinetuning.main:app"] From 2e578f14da60876341154f308f3edbe8d97a0f04 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:04:18 -0400 Subject: [PATCH 10/18] remove service targets --- services/finetuning/Makefile | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/services/finetuning/Makefile b/services/finetuning/Makefile index c9cefa12..320c2c1c 100644 --- a/services/finetuning/Makefile +++ b/services/finetuning/Makefile @@ -8,32 +8,11 @@ boilerplate: cat $$f>>tsfmfinetuning/$$(basename $$f); \ done - -# starts the tsfmfinetuning service (used mainly for test cases) -start_service_local: - python -m tsfmfinetuning.ftservice & - sleep 10 -stop_service_local: - pkill -f 'python.*tsfmfinetuning.*' - sleep 10 - image: $(CONTAINER_BUILDER) build -t tsfmfinetuning -f Dockerfile . -start_service_image: image - $(CONTAINER_BUILDER) run -p 8000:8000 -d --rm --name tsfmserver tsfmfinetuning - sleep 10 -stop_service_image: - $(CONTAINER_BUILDER) stop tsfmserver - -test_local: start_service_local - pytest tests - $(MAKE) stop_service_local - -test_image: start_service_image +test_local: pytest tests install_dev: boilerplate pip install poetry && poetry install --with dev - - From 87ab4d6a48b018da425c647e55ad84e66ed0c27a Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:06:58 -0400 Subject: [PATCH 11/18] add local pytest --- .github/workflows/finetuning-service-test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/finetuning-service-test.yml b/.github/workflows/finetuning-service-test.yml index 3af8aa74..a97137ff 100644 --- a/.github/workflows/finetuning-service-test.yml +++ b/.github/workflows/finetuning-service-test.yml @@ -37,9 +37,14 @@ jobs: # for much, we just want to make sure # that it continues to build until we # do so - - name: Test image build + - name: image build run: | source .venv/bin/activate cd services/finetuning make image + - name: test local + run: | + source .venv/bin/activate + cd services/finetuning + make test_local \ No newline at end of file From 07bf02bd587395714a3690f2c713d8c402e0ea29 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:38:54 -0400 Subject: [PATCH 12/18] test_local depends on boilerplate --- services/finetuning/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/finetuning/Makefile b/services/finetuning/Makefile index 320c2c1c..970743b1 100644 --- a/services/finetuning/Makefile +++ b/services/finetuning/Makefile @@ -11,7 +11,7 @@ boilerplate: image: $(CONTAINER_BUILDER) build -t tsfmfinetuning -f Dockerfile . -test_local: +test_local boilerplate: pytest tests install_dev: boilerplate From 6341925193d27fa47bfc378910f789159a533a47 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:51:28 -0400 Subject: [PATCH 13/18] :typo: --- services/finetuning/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/finetuning/Makefile b/services/finetuning/Makefile index 970743b1..0688d4b2 100644 --- a/services/finetuning/Makefile +++ b/services/finetuning/Makefile @@ -11,7 +11,7 @@ boilerplate: image: $(CONTAINER_BUILDER) build -t tsfmfinetuning -f Dockerfile . -test_local boilerplate: +test_local: boilerplate pytest tests install_dev: boilerplate From 4de480d26bb74da839c2c2b56c26210d1e845fd8 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:53:48 -0400 Subject: [PATCH 14/18] remove python 3.9 --- services/inference/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/services/inference/Dockerfile b/services/inference/Dockerfile index 843b17f2..8dc86bfd 100644 --- a/services/inference/Dockerfile +++ b/services/inference/Dockerfile @@ -11,6 +11,7 @@ RUN microdnf -y update && \ python${PYTHON_VERSION}-pip \ python$(PYTHON_VERSION)-wheel && \ pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ + microdnf remove python3.9 python-unversioned-command python3-setuptools python3-wheel -y && \ microdnf clean all ENV POETRY_VIRTUALENVS_IN_PROJECT=1 From 64ddbbc45d6bcf4a8e31294c8097344fb7c7a150 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:55:02 -0400 Subject: [PATCH 15/18] remove python 3.9 --- services/finetuning/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/services/finetuning/Dockerfile b/services/finetuning/Dockerfile index 71d4fec5..6ac0585e 100644 --- a/services/finetuning/Dockerfile +++ b/services/finetuning/Dockerfile @@ -11,6 +11,7 @@ RUN microdnf -y update && \ python${PYTHON_VERSION}-pip \ python$(PYTHON_VERSION)-wheel && \ pip${PYTHON_VERSION} install --no-cache-dir --upgrade pip wheel && \ + microdnf remove python3.9 python-unversioned-command python3-setuptools python3-wheel -y && \ microdnf clean all ENV POETRY_VIRTUALENVS_IN_PROJECT=1 From c94b7240e9584097429463c4ebe18f378150cd51 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:33:57 -0400 Subject: [PATCH 16/18] fix test targets to use cloned models --- services/inference/Makefile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/services/inference/Makefile b/services/inference/Makefile index 1a87b321..8a857006 100644 --- a/services/inference/Makefile +++ b/services/inference/Makefile @@ -21,24 +21,38 @@ stop_service_local: image: boilerplate $(CONTAINER_BUILDER) build -t tsfminference -f Dockerfile . -start_service_image: image - $(CONTAINER_BUILDER) run -p 8000:8000 -d --rm --name tsfmserver tsfminference +start_service_image: clone_models image + $(CONTAINER_BUILDER) run -p 8000:8000 \ + -d --rm --name tsfmserver \ + -e TSFM_MODEL_DIR=/tsfm_models \ + -e TSFM_ALLOW_LOAD_FROM_HF_HUB=0 \ + -v mytest-tsfm:/tsfm_models \ + tsfminference sleep 5 stop_service_image: $(CONTAINER_BUILDER) stop tsfmserver -test_local: boilerplate start_service_local - pytest tests +test_local: clone_models boilerplate start_service_local + TSFM_ALLOW_LOAD_FROM_HF_HUB=0 TSFM_MODEL_DIR=./mytest-tsfm \ + pytest tests $(MAKE) stop_service_local + $(MAKE) delete_models test_image: start_service_image pytest tests $(MAKE) stop_service_image + $(MAKE) delete_models install_dev: boilerplate pip install poetry && poetry install --with dev +clone_models: + git lfs install || true + git clone https://huggingface.co/ibm/test-tsfm mytest-tsfm || true + +delete_models: + rm -rf mytest-tsfm || true From ce6fe273d71e744cfb1b565344bd4ce67ad55477 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:34:33 -0400 Subject: [PATCH 17/18] use TSFM_MODEL_DIR if set --- services/inference/tests/test_inference.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/inference/tests/test_inference.py b/services/inference/tests/test_inference.py index 3b9e9de5..010ac0bc 100644 --- a/services/inference/tests/test_inference.py +++ b/services/inference/tests/test_inference.py @@ -1,5 +1,7 @@ # Copyright contributors to the TSFM project # +import os +import tempfile from pathlib import Path from typing import Any, Dict @@ -98,7 +100,10 @@ def test_zero_shot_forecast_inference(ts_data): prediction_length = params["prediction_length"] context_length = params["context_length"] model_id = params["model_id"] - model_id_path = str(Path("/tmp/test-tsfm") / model_id) + model_dir = ( + Path(os.getenv("TSFM_MODEL_DIR")) if os.getenv("TSFM_MODEL_DIR") else Path(tempfile.gettempdir()) / "test-tsfm" + ) + model_id_path: Path = (model_dir / model_id).as_posix() id_columns = params["id_columns"] From 7a8addc7258944d71ab53e984547779db0d785f6 Mon Sep 17 00:00:00 2001 From: Stuart Siegel <12914116+ssiegel95@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:57:51 -0400 Subject: [PATCH 18/18] make github action and makfile driven tests consistent --- .github/workflows/inference-services-test.yml | 12 ++++------ services/inference/Makefile | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/inference-services-test.yml b/.github/workflows/inference-services-test.yml index 62cb6594..d4ac6561 100644 --- a/.github/workflows/inference-services-test.yml +++ b/.github/workflows/inference-services-test.yml @@ -33,17 +33,13 @@ jobs: cd services/inference poetry self add "poetry-dynamic-versioning[plugin]" poetry install -n --with dev - - name: Clone models directory - run: | - git lfs install - git clone https://huggingface.co/ibm/test-tsfm mytest-tsfm - - name: Test local server tsfminference service with pytest + - name: Test local server run: | source .venv/bin/activate cd services/inference - TSFM_ALLOW_LOAD_FROM_HF_HUB=0 TSFM_MODEL_DIR=mytest-tsfm make test_local - - name: Test image server tsfminference service with pytest + make test_local + - name: Test image run: | source .venv/bin/activate cd services/inference - TSFM_ALLOW_LOAD_FROM_HF_HUB=0 TSFM_MODEL_DIR=mytest-tsfm make test_image + make test_image \ No newline at end of file diff --git a/services/inference/Makefile b/services/inference/Makefile index 8a857006..914737ad 100644 --- a/services/inference/Makefile +++ b/services/inference/Makefile @@ -10,7 +10,7 @@ boilerplate: # starts the tsfminference service (used mainly for test cases) start_service_local: boilerplate - python -m gunicorn \ + TSFM_MODEL_DIR=./mytest-tsfm python -m gunicorn \ -w 1 \ -k uvicorn.workers.UvicornWorker \ --bind 127.0.0.1:8000 \ @@ -21,26 +21,28 @@ stop_service_local: image: boilerplate $(CONTAINER_BUILDER) build -t tsfminference -f Dockerfile . -start_service_image: clone_models image +start_service_image: image $(CONTAINER_BUILDER) run -p 8000:8000 \ - -d --rm --name tsfmserver \ - -e TSFM_MODEL_DIR=/tsfm_models \ - -e TSFM_ALLOW_LOAD_FROM_HF_HUB=0 \ - -v mytest-tsfm:/tsfm_models \ - tsfminference + -d \ + --rm \ + --name tsfmserver \ + -e TSFM_MODEL_DIR=/mytest-tsfm \ + -e TSFM_ALLOW_LOAD_FROM_HF_HUB=1 \ + -v ./mytest-tsfm:/mytest-tsfm \ + tsfminference sleep 5 stop_service_image: $(CONTAINER_BUILDER) stop tsfmserver test_local: clone_models boilerplate start_service_local - TSFM_ALLOW_LOAD_FROM_HF_HUB=0 TSFM_MODEL_DIR=./mytest-tsfm \ + TSFM_ALLOW_LOAD_FROM_HF_HUB=1 TSFM_MODEL_DIR=./mytest-tsfm \ pytest tests $(MAKE) stop_service_local $(MAKE) delete_models -test_image: start_service_image - pytest tests +test_image: clone_models start_service_image + TSFM_MODEL_DIR=./ pytest tests $(MAKE) stop_service_image $(MAKE) delete_models