Skip to content

Commit

Permalink
Python SDK: Support multiple pydantic versions (treeverse#7672)
Browse files Browse the repository at this point in the history
* Python SDK: Support multiple pydantic versions

* Fix templates

* Update clients/python/scripts/pydantic.sh

Co-authored-by: Ariel Shaqed (Scolnicov) <ariels@treeverse.io>

* Add unit test flavor with pydantic V1

* Fix script

* Fix workflow

---------

Co-authored-by: Ariel Shaqed (Scolnicov) <ariels@treeverse.io>
  • Loading branch information
2 people authored and Victor Chen committed May 27, 2024
1 parent 12f32e4 commit 88168c1
Show file tree
Hide file tree
Showing 127 changed files with 569 additions and 140 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/python-wrapper-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
unit-tests:
needs: paths-filter
if: ${{ needs.paths-filter.outputs.client-change == 'true' }}
strategy:
fail-fast: false
matrix:
pydantic_v1: [ true, false ]
name: Unit Test Python SDK Wrapper
runs-on: ubuntu-22.04
steps:
Expand All @@ -43,6 +47,11 @@ jobs:
with:
python-version: 3.9

# When installed it will skip the installation of pydantic in the next step which will install the latest > 2
- name: Install pydantic V1
if: matrix.pydantic_v1
run: pip install pydantic==1.10.6

- name: Install dependencies
working-directory: ./clients/python-wrapper
run: pip install -r requirements.txt pylint pytest pytest-md pytest-emoji
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ OPENAPI_LEGACY_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v5.3.0
OPENAPI_LEGACY_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_LEGACY_GENERATOR_IMAGE)
OPENAPI_GENERATOR_IMAGE=treeverse/openapi-generator-cli:v7.0.0.1
OPENAPI_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)
PY_OPENAPI_GENERATOR=$(DOCKER) run -e PYTHON_POST_PROCESS_FILE="/mnt/clients/python/scripts/pydantic.sh" --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)

GOLANGCI_LINT_VERSION=v1.53.3
BUF_CLI_VERSION=v1.28.1
Expand Down Expand Up @@ -128,8 +129,9 @@ sdk-python-legacy: api/swagger.yml ## Generate SDK for Python client - openapi
sdk-python: api/swagger.yml ## Generate SDK for Python client - openapi generator version 7.0.0
# remove the build folder as it also holds lakefs_sdk folder which keeps because we skip it during find
rm -rf clients/python/build; cd clients/python && \
find . -depth -name lakefs_sdk -prune -o ! \( -name Gemfile -or -name Gemfile.lock -or -name _config.yml -or -name .openapi-generator-ignore -or -name templates -or -name setup.mustache -or -name client.mustache -or -name python-codegen-config.yaml \) -delete
$(OPENAPI_GENERATOR) generate \
find . -depth -name lakefs_sdk -prune -o ! \( -name Gemfile -or -name Gemfile.lock -or -name _config.yml -or -name .openapi-generator-ignore -or -name templates -or -name setup.mustache -or -name client.mustache -or -name requirements.mustache -or -name scripts -or -name pydantic.sh -or -name python-codegen-config.yaml \) -delete
$(PY_OPENAPI_GENERATOR) generate \
--enable-post-process-file \
-i /mnt/$< \
-g python \
-t /mnt/clients/python/templates \
Expand Down
1 change: 0 additions & 1 deletion clients/python-wrapper/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
aenum~=3.1.15
lakefs-sdk>=1.16.0
pydantic >= 1.10.5, < 2
python-dateutil~=2.8.2
PyYAML~=6.0.1
six~=1.16.0
Expand Down
1 change: 0 additions & 1 deletion clients/python-wrapper/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

PYTHON_REQUIRES = ">=3.9"
REQUIRES = [
"pydantic >= 1.10.5, < 2",
"setuptools == 68.2.2",
"lakefs-sdk ~= 1.0",
"pyyaml ~= 6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions clients/python-wrapper/tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ From the clients/python-wrapper directory:
```sh
python3 -m venv <your_venv_path>
source <your_venv_path>/bin/activate
pip install -r requirements pylint
pip install -r requirements
```

## Run Tests

```sh
pylint tests
pytest tests
```
6 changes: 5 additions & 1 deletion clients/python-wrapper/tests/integration/test_branch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import pytest
from pydantic import ValidationError

try:
from pydantic.v1 import ValidationError
except ImportError:
from pydantic import ValidationError

import lakefs
from lakefs.exceptions import NotFoundException, TransactionException
Expand Down
10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/actions_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/auth_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/branches_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/commits_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion clients/python/lakefs_sdk/api/config_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/experimental_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/external_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion clients/python/lakefs_sdk/api/health_check_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/import_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/internal_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/metadata_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/objects_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/refs_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/repositories_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/staging_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_sdk/api/tags_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion clients/python/lakefs_sdk/api_response.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88168c1

Please sign in to comment.