Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 3 additions & 6 deletions .github/workflows/python-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Lint
working-directory: client/python
run: |
make lint
make client-lint

- name: Generated Client Tests
working-directory: client/python
run: |
make test-client
make client-unit-test

- name: Image build
run: |
Expand All @@ -76,6 +74,5 @@ jobs:
-Dquarkus.container-image.build=true

- name: Integration Tests
working-directory: client/python
run: |
make test-integration
make client-integration-test
80 changes: 79 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ CONTAINER_TOOL ?= docker
MINIKUBE_PROFILE ?= minikube
DEPENDENCIES ?= ct helm helm-docs java21 git
OPTIONAL_DEPENDENCIES := jq kubectl minikube
VENV_DIR := .venv
PYTHON_CLIENT_DIR := client/python
ACTIVATE_AND_CD = source $(VENV_DIR)/bin/activate && cd $(PYTHON_CLIENT_DIR)

## Version information
BUILD_VERSION := $(shell cat version.txt)
GIT_COMMIT := $(shell git rev-parse HEAD)
POETRY_VERSION := $(shell cat client/python/pyproject.toml | grep requires-poetry | sed 's/requires-poetry *= *"\(.*\)"/\1/')

##@ General

Expand All @@ -41,6 +45,7 @@ help: ## Display this help
version: ## Display version information
@echo "Build version: ${BUILD_VERSION}"
@echo "Git commit: ${GIT_COMMIT}"
@echo "Poetry version: ${POETRY_VERSION}"

##@ Polaris Build

Expand Down Expand Up @@ -99,6 +104,79 @@ spotless-apply: check-dependencies ## Apply code formatting using Spotless Gradl
@./gradlew spotlessApply
@echo "--- Spotless formatting applied ---"

##@ Polaris Client

# Target to create the virtual environment directory
$(VENV_DIR):
@echo "Setting up Python virtual environment at $(VENV_DIR)..."
@python3 -m venv $(VENV_DIR)
@echo "Virtual environment created."

.PHONY: client-install-dependencies
client-install-dependencies: $(VENV_DIR)
@echo "Installing Poetry and project dependencies into $(VENV_DIR)..."
@$(VENV_DIR)/bin/pip install --upgrade pip
@if [ ! -f "$(VENV_DIR)/bin/poetry" ]; then \
$(VENV_DIR)/bin/pip install --upgrade "poetry$(POETRY_VERSION)"; \
fi
@$(ACTIVATE_AND_CD) && poetry install --all-extras
@echo "Poetry and dependencies installed."

.PHONY: client-setup-env
client-setup-env: $(VENV_DIR) client-install-dependencies

.PHONY: client-lint
client-lint: client-setup-env ## Run linting checks for Polaris client
@echo "--- Running client linting checks ---"
@$(ACTIVATE_AND_CD) && poetry run pre-commit run --files integration_tests/* python/cli/*
@echo "--- Client linting checks complete ---"

.PHONY: client-regenerate
client-regenerate: client-setup-env ## Regenerate the client code
@echo "--- Regenerating client code ---"
@client/templates/regenerate.sh
@echo "--- Client code regeneration complete ---"

.PHONY: client-unit-test
client-unit-test: client-setup-env ## Run client unit tests
@echo "--- Running client unit tests ---"
@$(ACTIVATE_AND_CD) && SCRIPT_DIR="non-existing-mock-directory" poetry run pytest test/
@echo "--- Client unit tests complete ---"

.PHONY: client-integration-test
client-integration-test: client-setup-env ## Run client integration tests
@echo "--- Starting client integration tests ---"
@echo "Ensuring Docker Compose services are stopped and removed..."
@$(CONTAINER_TOOL) compose -f $(PYTHON_CLIENT_DIR)/docker-compose.yml kill || true # `|| true` prevents make from failing if containers don't exist
@$(CONTAINER_TOOL) compose -f $(PYTHON_CLIENT_DIR)/docker-compose.yml rm -f || true # `|| true` prevents make from failing if containers don't exist
@echo "Bringing up Docker Compose services in detached mode..."
@$(CONTAINER_TOOL) compose -f $(PYTHON_CLIENT_DIR)/docker-compose.yml up -d
@echo "Waiting for Polaris HTTP health check to pass..."
@until curl -s -f http://localhost:8182/q/health > /dev/null; do \
echo "Still waiting for HTTP 200 from /q/health (sleeping 2s)..."; \
sleep 2; \
done
@echo "Polaris is healthy. Starting integration tests..."
@$(ACTIVATE_AND_CD) && poetry run pytest integration_tests/
@echo "--- Client integration tests complete ---"
@echo "Tearing down Docker Compose services..."
@$(CONTAINER_TOOL) compose -f $(PYTHON_CLIENT_DIR)/docker-compose.yml down || true # Ensure teardown even if tests fail

.PHONY: client-cleanup
client-cleanup: ## Cleanup virtual environment and Python cache files
@echo "--- Cleaning up virtual environment and Python cache files ---"
@echo "Attempting to remove virtual environment directory: $(VENV_DIR)..."
@if [ -n "$(VENV_DIR)" ] && [ -d "$(VENV_DIR)" ]; then \
rm -rf "$(VENV_DIR)"; \
echo "Virtual environment removed."; \
else \
echo "Virtual environment directory '$(VENV_DIR)' not found or VENV_DIR is empty. No action taken."; \
fi
@echo "Cleaning up Python cache files..."
@find $(PYTHON_CLIENT_DIR) -type f -name "*.pyc" -delete
@find $(PYTHON_CLIENT_DIR) -type d -name "__pycache__" -delete
@echo "--- Virtual environment and Python cache cleanup complete ---"

##@ Helm

helm-doc-generate: DEPENDENCIES := helm-docs
Expand Down Expand Up @@ -178,7 +256,7 @@ minikube-cleanup: check-dependencies ## Cleanup the Minikube cluster
##@ Pre-commit

.PHONY: pre-commit
pre-commit: spotless-apply helm-doc-generate ## Run tasks for pre-commit
pre-commit: spotless-apply helm-doc-generate client-lint ## Run tasks for pre-commit

##@ Dependencies

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ To streamline the developer experience, especially for common setup and build ta
- Managing development clusters: e.g., `make minikube-start-cluster, make minikube-cleanup`
- Automating Helm tasks: e.g., `make helm-doc-generate, make helm-unittest`
- Handling dependencies: e.g., `make install-dependencies-brew`
- Managing client operations: e.g., `make client-lint, make client-regenerate`

To see available commands:
```bash
Expand Down
107 changes: 0 additions & 107 deletions client/python/Makefile

This file was deleted.

15 changes: 8 additions & 7 deletions client/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ The Apache Polaris Python package provides a client for interacting with the Apa
### Prerequisites
- Python 3.9 or later
- poetry >= 2.1
- Docker

### Installation
First we need to generate the OpenAPI client code from the OpenAPI specification.
```
make regenerate-client
First we need to generate the OpenAPI client code from the OpenAPI specification by running the following command **from the project root directory**:
```bash
make client-regenerate
```

### Auto-formatting and Linting
```
make lint
```bash
make client-lint
```

### Running Integration Tests
```
make test-integration
```bash
make client-integration-test
```