Skip to content

Commit d1edacc

Browse files
committed
feat(python): improve automation for python sdk generation, added CI for release, rename package for kestrapy
1 parent 014ec1f commit d1edacc

397 files changed

Lines changed: 18612 additions & 41566 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python-sdk.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Python SDK release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
workflow_dispatch:
13+
inputs:
14+
skip-test:
15+
description: 'Skip test'
16+
required: false
17+
type: string
18+
default: "false"
19+
20+
jobs:
21+
pip:
22+
name: Publish to Pip
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: ./python-sdk
27+
steps:
28+
- uses: actions/checkout@v3
29+
working-directory: python-sdk
30+
- name: Set up Python 3.9
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: "3.9.23"
34+
35+
- name: Install pypa/build
36+
working-directory: python
37+
run: python -m pip install build --user
38+
39+
- name: Install deps
40+
working-directory: python
41+
run: pip install .[test]
42+
43+
- name: Run unit tests
44+
working-directory: python
45+
run: pytest
46+
47+
- name: Build a binary wheel and a source tarball
48+
if: startsWith(github.ref, 'refs/tags/v')
49+
working-directory: python
50+
env:
51+
VERSION: ${{ github.ref_name }}
52+
run: python -m build --sdist --wheel --outdir dist/ .
53+
54+
- name: Publish distribution to PyPI
55+
if: startsWith(github.ref, 'refs/tags/v')
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
password: ${{ secrets.PYPI_API_TOKEN }}
59+
verbose: true
60+
packages-dir: python/dist

README_PYTHON_SDK.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
1. Update the `kestra-ee.yml` if necessary with latest openspec api changes.
66

7-
- As of 13/06/25, `the kestra-ee.yml` has been generated and used without modifications.
8-
- Micronaut OpenAPI version `6.16.2` was used, as of 13/06.25, this has not been committed into the core yet (only modified locally).
7+
- As of 29/07/25, `the kestra-ee.yml` has been generated and used without modifications.
8+
- Micronaut OpenAPI version `6.17.3`
99
2. Generate the SDK using the script `generate-sdks.sh` that uses the openapi-generator-cli docker image.
1010

11-
3. Then multiples files changes are needed to be done manually in the generated SDK:
11+
3.THESE CHANGES ARE DONE AT GENERATION, BUT IF THERE IS AN ERROR, DOUBLE CHECK
12+
Then multiples files changes are needed to be done manually in the generated SDK:
1213
- In the pyproject.toml file, set the following values (you need to replace the current one):
1314
```toml
1415
license = "Apache-2.0"
@@ -19,6 +20,16 @@
1920
from kestra_api_client.models.list[label] import List[Label]
2021
```
2122

23+
- In the `__init__.py` add the following import, its the custom kestra client that gather all API clients:
24+
```python
25+
from kestra_api_client.kestra_client import KestraClient as KestraClient
26+
```
27+
- In the `task.py`, delete the following part, from the type validator:
28+
```python
29+
if not re.match(r"\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*(\.\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*)*", value):
30+
raise ValueError(r"must validate the regular expression /\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*(\.\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*)*/")
31+
```
32+
2233
## Step to use
2334

2435
The openapi generator will generate 1 Api per controller, so we create a custom Kestra Client that need to be instantiated once for every API.

configurations/python-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ globalProperties:
77
modelTests: false
88

99
additionalProperties:
10-
packageName: kestra_api_client
11-
projectName: kestra_api
10+
packageName: kestrapy
11+
projectName: kestrapy
1212
disallowAdditionalPropertiesIfNotPresent: false

generate-sdks.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \
2424
-c /local/configurations/python-config.yml \
2525
--skip-validate-spec \
2626
--additional-properties=packageVersion=$VERSION
27+
sed -i 's/^license = .*/license = "Apache-2.0"/' python-sdk/pyproject.toml
28+
sed -i 's/^requires-python = .*/requires-python = ">=3.9"/' python-sdk/pyproject.toml
29+
sed -i '/from kestra_api_client\.models\.list\[label\] import List\[Label\]/d' python-sdk/kestra_api_client/api/executions_api.py
30+
grep -vF '{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}' python-sdk/kestra_api_client/models/task.py > temp_file && mv temp_file python-sdk/kestra_api_client/models/task.py
31+
echo "from kestra_api_client.kestra_client import KestraClient as KestraClient" >> python-sdk/kestra_api_client/__init__.py
2732
fi
2833

2934
# Generate Javascript SDK

0 commit comments

Comments
 (0)