Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ jobs:
with:
python-version: '3.9'


- name: Verify
run: make verify

- name: Run Tests
run: |
make test-python report=xml

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Pass the GITHUB_TOKEN
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ __debug_bin
# Python cache files
__pycache__/
*.egg-info/
bin

.coverage
bin
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SHELL = /usr/bin/env bash -o pipefail
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

PY_DIR := $(PROJECT_DIR)/python
VENV_DIR := $(PROJECT_DIR)/.venv

##@ General

Expand All @@ -38,7 +39,6 @@ PY_DIR := $(PROJECT_DIR)/python
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)


#UV := $(shell which uv)

.PHONY: uv
Expand All @@ -52,14 +52,28 @@ uv: ## Install UV
ruff: ## Install Ruff
@uvx ruff --help &> /dev/null || uv tool install ruff


.PHONY: verify
verify: uv ruff ## install all required tools
verify: uv uv-venv ruff ## install all required tools
@cd $(PY_DIR) && uv lock --check
@cd $(PY_DIR) && uvx ruff check --show-fixes

.PHONY: test-python
test-python: ## Run Python unit test.
uv install --dev
PYTHONPATH=$(PROJECT_DIR) pytest ./python/kubeflow
.PHONY: uv-venv
uv-venv:
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Creating uv virtual environment in $(VENV_DIR)..."; \
uv venv; \
else \
echo "uv virtual environment already exists in $(VENV_DIR)."; \
fi

# make test-unit will produce html coverage by default. Run with `make test-unit report=xml` to produce xml report.
.PHONY: test-python
test-python: uv-venv
@uv pip install "./python[test]"
@uv run coverage run --source=kubeflow.trainer.api.trainer_client,kubeflow.trainer.utils.utils -m pytest ./python/kubeflow/trainer/api/trainer_client_test.py
@uv run coverage report -m kubeflow/trainer/api/trainer_client.py kubeflow/trainer/utils/utils.py
ifeq ($(report),xml)
@uv run coverage xml
else
@uv run coverage html
endif
Loading