Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Use buf to generate python stubs (#346)
Browse files Browse the repository at this point in the history
* Buf python migration

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Generate pyi files

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Add venv to .gitgnore

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Use buf to generate python stubs

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Use buf docker image to generate stubs

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Add stubs produced by call to `buf generate` using buf's docker image

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Add pyi files

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Use buf locally

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Verify that generated protos by using buf

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Copy generated code to a separate artifact

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Move back to go_generate.yml@master

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
  • Loading branch information
eapolinario and eapolinario committed Nov 29, 2022
1 parent 0d0c0ed commit f4ede35
Show file tree
Hide file tree
Showing 171 changed files with 8,320 additions and 24,163 deletions.
52 changes: 39 additions & 13 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ jobs:
- name: Proto-Datacatalog-Go
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/datacatalog -l go --go_source_relative --validate_out

# Python is going to be generated using buf
# Python
- name: Proto-Service-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/service -l python
- name: Proto-Admin-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/admin -l python
- name: Proto-Core-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/core -l python
- name: Proto-Event-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/event -l python
- name: Proto-Plugins-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/plugins -l python
- name: Proto-Datacatalog-Python
run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/datacatalog -l python
# - name: Proto-Service-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/service -l python
# - name: Proto-Admin-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/admin -l python
# - name: Proto-Core-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/core -l python
# - name: Proto-Event-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/event -l python
# - name: Proto-Plugins-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/plugins -l python
# - name: Proto-Datacatalog-Python
# run: python3 /usr/local/bin/entrypoint.py -i ./protos -d protos/flyteidl/datacatalog -l python

# Cpp
- name: Proto-Service-Cpp
Expand Down Expand Up @@ -98,10 +99,31 @@ jobs:
name: generated
path: ./gen

generate-protos-buf:
name: Generate python protos using buf
runs-on: ubuntu-latest
needs: [ generate-protos ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- uses: bufbuild/buf-setup-action@v1
- name: "Clean Generated"
run: rm -rf ./gen
- name: "Run buf generate"
run: buf generate
- uses: actions/upload-artifact@master
with:
name: generated-buf
path: ./gen

generate-admin-swagger-code:
runs-on: ubuntu-latest
name: Generate Admin Swagger Code
needs: [ generate-protos ]
needs:
- generate-protos
- generate-protos-buf
container:
image: lyft/protocgenerator:8167e11d3b3439373c2f033080a4b550078884a2
options: --cpus 1
Expand All @@ -116,6 +138,10 @@ jobs:
with:
name: generated
path: ./gen
- uses: actions/download-artifact@master
with:
name: generated-buf
path: ./gen
- run: ls gen/pb-go/flyteidl/service/
- run: cp -R gen/pb-go/flyteidl/service/ ../
- run: ls ../service/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ docs/build/
tmp/
.python-version
__pycache__/

venv/
10 changes: 10 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
managed:
enabled: true
plugins:
- remote: buf.build/grpc/plugins/python:v1.49.1-1
out: gen/pb_python
- remote: buf.build/protocolbuffers/plugins/python:v21.7.0-1
out: gen/pb_python
- remote: buf.build/protocolbuffers/plugins/pyi:v21.9.0-1
out: gen/pb_python
Empty file removed gen/__init__.py
Empty file.
Empty file removed gen/pb_python/__init__.py
Empty file.
Empty file removed gen/pb_python/flyteidl/__init__.py
Empty file.
Empty file.
67 changes: 11 additions & 56 deletions gen/pb_python/flyteidl/admin/cluster_assignment_pb2.py

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

11 changes: 11 additions & 0 deletions gen/pb_python/flyteidl/admin/cluster_assignment_pb2.pyi

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.

0 comments on commit f4ede35

Please sign in to comment.