From 8f59a96882b905e2edca5d00e72213862072a93b Mon Sep 17 00:00:00 2001 From: Jesse Claven Date: Wed, 12 Jun 2024 17:17:26 +0100 Subject: [PATCH] build: Install dependencies only in Tox environments (#1785) --- .github/workflows/tests.yml | 36 ++++++++++++---------------------- Makefile | 8 ++++++++ poetry.lock | 14 ++++++------- pyproject.toml | 3 +++ runtimes/alibi-detect/tox.ini | 2 +- runtimes/alibi-explain/tox.ini | 2 +- runtimes/catboost/tox.ini | 4 ++-- runtimes/huggingface/tox.ini | 2 +- runtimes/lightgbm/tox.ini | 2 +- runtimes/mlflow/tox.ini | 2 +- runtimes/mllib/tox.ini | 2 +- runtimes/sklearn/tox.ini | 2 +- runtimes/xgboost/tox.ini | 2 +- tox.runtime.ini | 11 +++++++++++ 14 files changed, 51 insertions(+), 41 deletions(-) create mode 100644 tox.runtime.ini diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aec13497e..edaa6555b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,7 @@ jobs: - name: Lint run: make lint - mlserver: + test-mlserver: strategy: fail-fast: false matrix: @@ -95,20 +95,16 @@ jobs: uses: snok/install-poetry@v1 with: virtualenvs-create: false - - name: Install Dependencies - run: | - if [[ ${{ runner.os == 'macOS' }} ]]; then - source ./hack/activate-libomp-macos.sh - fi - poetry install --sync --only dev + - name: Install dependencies + run: poetry install --only test - name: Test run: | if [[ ${{ runner.os == 'macOS' }} ]]; then source ./hack/activate-libomp-macos.sh fi - tox -e mlserver + poetry run tox -e mlserver - runtimes: + test-runtimes: strategy: fail-fast: false matrix: @@ -152,21 +148,17 @@ jobs: uses: snok/install-poetry@v1 with: virtualenvs-create: false - - name: Install Dependencies - run: | - if [[ ${{ runner.os == 'macOS' }} ]]; then - source ./hack/activate-libomp-macos.sh - fi - poetry install --sync --only dev + - name: Install dependencies + run: poetry install --only test - name: Test run: | if [[ ${{ runner.os == 'macOS' }} ]]; then source ./hack/activate-libomp-macos.sh fi - tox -c ./runtimes/${{ matrix.tox-environment }} + poetry run tox -c ./runtimes/${{ matrix.tox-environment }} # Ensure that having all the runtimes installed together works - all-runtimes: + test-all-runtimes: if: github.event_name == 'push' strategy: fail-fast: false @@ -209,15 +201,11 @@ jobs: uses: snok/install-poetry@v1 with: virtualenvs-create: false - - name: Install Dependencies - run: | - if [[ ${{ runner.os == 'macOS' }} ]]; then - source ./hack/activate-libomp-macos.sh - fi - poetry install --sync --only dev + - name: Install dependencies + run: poetry install --only test - name: Test run: | if [[ ${{ runner.os == 'macOS' }} ]]; then source ./hack/activate-libomp-macos.sh fi - tox -e all-runtimes + poetry run tox -e all-runtimes diff --git a/Makefile b/Makefile index fa47da669..45d3a53e8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,14 @@ IMAGE_NAME := seldonio/mlserver .PHONY: install-dev _generate generate run build \ push-test push test lint fmt version clean licenses +.PHONY: bootstrap-test +bootstrap-test: + for _runtime in ./runtimes/*; \ + do \ + echo "Copying Tox configuration to $$_runtime..."; \ + cp tox.runtime.ini $$_runtime/tox.ini; \ + done + install-dev: poetry install --sync --with all-runtimes --with all-runtimes-dev diff --git a/poetry.lock b/poetry.lock index 61d5846c2..0b0516753 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2655,13 +2655,13 @@ files = [ [[package]] name = "jinja2" -version = "3.1.3" +version = "3.1.4" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, - {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, + {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, + {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, ] [package.dependencies] @@ -7404,13 +7404,13 @@ testing = ["build[virtualenv] (>=1.0.3)", "covdefaults (>=2.3)", "detect-test-po [[package]] name = "tqdm" -version = "4.66.2" +version = "4.66.3" description = "Fast, Extensible Progress Meter" optional = false python-versions = ">=3.7" files = [ - {file = "tqdm-4.66.2-py3-none-any.whl", hash = "sha256:1ee4f8a893eb9bef51c6e35730cebf234d5d0b6bd112b0271e10ed7c24a02bd9"}, - {file = "tqdm-4.66.2.tar.gz", hash = "sha256:6cd52cdf0fef0e0f543299cfc96fec90d7b8a7e88745f411ec33eb44d5ed3531"}, + {file = "tqdm-4.66.3-py3-none-any.whl", hash = "sha256:4f41d54107ff9a223dca80b53efe4fb654c67efaba7f47bada3ee9d50e05bd53"}, + {file = "tqdm-4.66.3.tar.gz", hash = "sha256:23097a41eba115ba99ecae40d06444c15d1c0c698d527a01c6c8bd1c5d0647e5"}, ] [package.dependencies] @@ -8422,4 +8422,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.12" -content-hash = "76bae1ad422aba591bf2ed9b9fdf04f5d38ef1f7d494908f6276fbb92c712c52" +content-hash = "a0089ebf9891465b56ad5451a053712de395f94f34aa4e900eead50923c9c4ab" diff --git a/pyproject.toml b/pyproject.toml index 0cf549d9c..c59a247c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,9 @@ opentelemetry-instrumentation-grpc = ">=0.43b0" opentelemetry-exporter-otlp-proto-grpc = "^1.22.0" pytest-lazy-fixture = "^0.6.3" +[tool.poetry.group.test.dependencies] +tox = "4.14.2" + [tool.poetry.group.dev.dependencies] datamodel-code-generator = "0.25.5" grpcio-tools = "1.48.2" diff --git a/runtimes/alibi-detect/tox.ini b/runtimes/alibi-detect/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/alibi-detect/tox.ini +++ b/runtimes/alibi-detect/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/alibi-explain/tox.ini b/runtimes/alibi-explain/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/alibi-explain/tox.ini +++ b/runtimes/alibi-explain/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/catboost/tox.ini b/runtimes/catboost/tox.ini index 21f3266d4..bc9e828df 100644 --- a/runtimes/catboost/tox.ini +++ b/runtimes/catboost/tox.ini @@ -4,8 +4,8 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = - python -m pytest {posargs} \ + python -m pytest {posargs} -n auto \ {toxinidir}/tests diff --git a/runtimes/huggingface/tox.ini b/runtimes/huggingface/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/huggingface/tox.ini +++ b/runtimes/huggingface/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/lightgbm/tox.ini b/runtimes/lightgbm/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/lightgbm/tox.ini +++ b/runtimes/lightgbm/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/mlflow/tox.ini b/runtimes/mlflow/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/mlflow/tox.ini +++ b/runtimes/mlflow/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/mllib/tox.ini b/runtimes/mllib/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/mllib/tox.ini +++ b/runtimes/mllib/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/sklearn/tox.ini b/runtimes/sklearn/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/sklearn/tox.ini +++ b/runtimes/sklearn/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/runtimes/xgboost/tox.ini b/runtimes/xgboost/tox.ini index 026940b6f..bc9e828df 100644 --- a/runtimes/xgboost/tox.ini +++ b/runtimes/xgboost/tox.ini @@ -4,7 +4,7 @@ isolated_build = true [testenv] allowlist_externals = poetry commands_pre = - poetry install --sync --no-root + poetry install --sync --no-root poetry install -C {toxinidir}/../../ commands = python -m pytest {posargs} -n auto \ diff --git a/tox.runtime.ini b/tox.runtime.ini new file mode 100644 index 000000000..bc9e828df --- /dev/null +++ b/tox.runtime.ini @@ -0,0 +1,11 @@ +[tox] +isolated_build = true + +[testenv] +allowlist_externals = poetry +commands_pre = + poetry install --sync --no-root + poetry install -C {toxinidir}/../../ +commands = + python -m pytest {posargs} -n auto \ + {toxinidir}/tests