Skip to content

Commit

Permalink
build: Add granularity in types generation (#1749)
Browse files Browse the repository at this point in the history
* build: Add Python version to matrix for all jobs

These 2 were missing this supported version. It would've caught me
using `TypeAlias` on 3.9 earlier.

* build: Add granularity in types generation

This makes it easier to know which types generation is failing. It's a
follow-on from #1729.
  • Loading branch information
Jesse Claven authored May 8, 2024
1 parent c5b4d5f commit 410cf6f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ on:
jobs:
generate:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.9", "3.10"]
target: ["dataplane", "model-repository"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,15 +28,15 @@ jobs:
virtualenvs-create: false
- name: Install dependencies
run: poetry install --sync --only dev
- name: Generate
run: make generate
- name: Generate ${{ matrix.target }}
run: make generate-${{ matrix.target }}
- name: Check for changes
run: git --no-pager diff --exit-code .
run: make lint-no-changes

lint:
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.9", "3.10"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ lock:
poetry lock --no-update -C $$_runtime; \
done

_generate: # "private" target to call `fmt` after `generate`
poetry run bash ./hack/generate-types.sh
_generate_model_repository: # "private" target to call `fmt` after `generate`
poetry run bash ./hack/generate-types.sh model_repository

generate: | _generate fmt
_generate_dataplane: # "private" target to call `fmt` after `generate`
poetry run bash ./hack/generate-types.sh dataplane

generate-model-repository: | _generate_model_repository fmt

generate-dataplane: | _generate_dataplane fmt

generate: | _generate_model_repository _generate_dataplane fmt

run:
mlserver start \
Expand Down Expand Up @@ -78,13 +85,14 @@ lint:
mypy ./benchmarking
mypy ./docs/examples

# Check if something has changed after generation
lint-generate: generate
lint-no-changes:
git \
--no-pager diff \
--exit-code \
.

lint-generate: generate lint-no-changes

licenses:
tox --recreate -e licenses
cut -d, -f1,3 ./licenses/license_info.csv \
Expand Down
9 changes: 4 additions & 5 deletions hack/generate-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -Eeuo pipefail

ROOT_FOLDER="$(dirname "${0}")/.."

TARGET="$1"

_generatePB() {
local apiName=$1

Expand Down Expand Up @@ -33,8 +35,5 @@ _generatePydantic() {
--target-python-version 3.6
}

_generatePB dataplane
_generatePydantic dataplane

_generatePB model_repository
_generatePydantic model_repository
_generatePB "$TARGET"
_generatePydantic "$TARGET"

0 comments on commit 410cf6f

Please sign in to comment.