Skip to content

Commit 3f1c3e5

Browse files
authored
feat: update protobuf version (#172)
Changes: 1. Update github actions base image to 22.04 since github is retiring 20.04. 2. Fix docker container build and test. 3. Update grpc tools to support protobuf 4.X.X. 4. Remove pb2 files from git tracking. 5. Bump DGP version to 2.0.0.
1 parent 2bcb53d commit 3f1c3e5

Some content is hidden

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

63 files changed

+297
-8224
lines changed

.github/workflows/build-docker.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ name: build-docker
33
on:
44
push:
55
branches:
6-
- 'master'
6+
- "master"
77
tags:
8-
- '*'
8+
- "*"
99

1010
env:
1111
REGISTRY: ghcr.io
1212
IMAGE_NAME: ${{ github.repository }}
1313

1414
jobs:
1515
build-and-push-image:
16-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-22.04
1717
permissions:
1818
contents: read
1919
packages: write

.github/workflows/coverage.yml

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ name: coverage
22
on:
33
pull_request:
44
branches:
5-
- 'master'
5+
- "master"
66
push:
77
branches:
8-
- 'master'
8+
- "master"
99
jobs:
1010
code-coverage:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-22.04
1212
env:
1313
ENVIRONMENT: TEST_RUNNER
14-
OS: ubuntu-20.04
15-
PYTHON: '3.9'
14+
OS: ubuntu-22.04
15+
PYTHON: "3.9"
1616
COVERAGE_TOTAL: 49 # Coverage threshold percentage
1717
steps:
1818
- name: Checkout (admin token)
1919
if: ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
2020
uses: actions/checkout@master
2121
with:
22-
token: '${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
22+
token: "${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}"
2323
fetch-depth: "2" # Original commit + code cov badge commit
2424
- name: Checkout (normal flow)
2525
if: ${{github.event_name == 'pull_request'}}
@@ -34,17 +34,16 @@ jobs:
3434
id: coverage-installer
3535
run: |
3636
python -m pip install --upgrade pip
37-
pip install cython==0.29.21 numpy==1.23.2
3837
sudo apt-get install jq
39-
pip install -r requirements.txt
40-
pip install -r requirements-dev.txt
4138
pip install coverage-badge
39+
make develop
4240
- name: Run tests and calculate coverage
4341
id: test-runner
4442
run: |
4543
coverage run -m pytest
4644
coverage-badge -f -o docs/coverage.svg
47-
COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
45+
coverage json
46+
COVERAGE_SCORE=$(jq '.totals.percent_covered' coverage.json)
4847
echo "::set-output name=coverageScore::$COVERAGE_SCORE"
4948
- name: Verify Changed files
5049
uses: tj-actions/verify-changed-files@v6

.github/workflows/doc-gen.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ name: doc-gen
22
on:
33
push:
44
branches:
5-
- 'master'
5+
- "master"
66
pull_request:
77
branches:
8-
- 'master'
8+
- "master"
99

1010
jobs:
1111
run:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
env:
14-
OS: ubuntu-20.04
15-
PYTHON: '3.9'
14+
OS: ubuntu-22.04
15+
PYTHON: "3.9"
1616
steps:
1717
- uses: actions/checkout@master
1818
with:
@@ -26,7 +26,6 @@ jobs:
2626
- name: Setup requirements and run sphinx
2727
run: |
2828
python -m pip install --upgrade pip
29-
pip install cython==0.29.21 numpy==1.23.2
3029
pip install -r requirements.txt
3130
pip install -r requirements-dev.txt
3231
pip install -r docs/requirements-doc.txt
@@ -39,4 +38,4 @@ jobs:
3938
with:
4039
branch: gh-pages
4140
folder: ./docs/build/html
42-
commit-message: 'docs: update build documentation'
41+
commit-message: "docs: update build documentation"

.github/workflows/pre-merge.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
pre-merge-tests:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
env:
1414
ENVIRONMENT: TEST_RUNNER
1515
steps:
@@ -28,7 +28,6 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install cython==0.29.21 numpy==1.23.2
3231
pip install -r requirements.txt
3332
pip install -r requirements-dev.txt
3433
- name: Lint all files with pre-commit

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,13 @@ Pipfile
111111
Pipfile.lock
112112

113113
\.vscode/
114+
*.ply
115+
116+
*.pyi
117+
*_pb2.py
118+
*_pb2_grpc.py
119+
120+
# Test data
121+
tests/data/dgp/autolabel_root/
122+
tests/data/dgp/test_scene/scene_01/autolabels/
123+
tests/data/dgp/test_scene/scene_02/autolabels/

.pre-commit-config.yaml

+16-9
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ repos:
6161
hooks:
6262
- id: yapf
6363
# pre-commit requires that we split args at whitespce boundaries.
64-
args: [
65-
--style, .style.yapf,
66-
-i,
67-
-e, '*pb2.py',
68-
-e, '*pb2_grpc.py',
69-
-e, '*eggs*.py',
70-
-e, '*env*',
71-
-e, 'build/*'
72-
]
64+
args:
65+
[
66+
--style,
67+
.style.yapf,
68+
-i,
69+
-e,
70+
"*pb2.py",
71+
-e,
72+
"*pb2_grpc.py",
73+
-e,
74+
"*eggs*.py",
75+
-e,
76+
"*env*",
77+
-e,
78+
"build/*",
79+
]
7380
exclude: '\w*pb2.py'
7481
additional_dependencies: [toml]

Dockerfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM nvidia/cuda:11.2.2-devel-ubuntu20.04
1+
FROM nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
22

33
ARG python=3.9
4-
ENV PYTORCH_VERSION=1.8.1+cu111
5-
ENV TORCHVISION_VERSION=0.9.1+cu111
4+
ENV PYTORCH_VERSION=1.13.1+cu116
5+
ENV TORCHVISION_VERSION=0.14.1+cu116
66

77
ENV LC_ALL=C.UTF-8
88
ENV LANG=C.UTF-8
@@ -42,11 +42,13 @@ RUN pip install --no-cache-dir \
4242
torchvision==${TORCHVISION_VERSION} \
4343
-f https://download.pytorch.org/whl/${PYTORCH_VERSION/*+/}/torch_stable.html
4444

45+
4546
# Install python dependencies
4647
ARG WORKSPACE=/home/dgp
4748
WORKDIR ${WORKSPACE}
4849
COPY requirements.txt requirements-dev.txt /tmp/
49-
RUN pip install --no-cache-dir cython==0.29.30 numpy==1.20.3
50+
# Install torch-compatible NumPy.
51+
RUN pip install numpy==1.26.4
5052
RUN pip install --no-cache-dir -r /tmp/requirements.txt
5153
RUN pip install --no-cache-dir -r /tmp/requirements-dev.txt
5254

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
include README.md
2+
include requirements.txt
3+
include requirements-dev.txt
24
include docs/*
35
recursive-exclude * *.proto

Makefile

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2019-2021 Toyota Research Institute. All rights reserved.
2-
PYTHON ?= python3
2+
PYTHON_EXEC ?= python3
33
PACKAGE_NAME ?= dgp
44
WORKSPACE ?= /home/$(PACKAGE_NAME)
55
DOCKER_IMAGE_NAME ?= $(PACKAGE_NAME)
@@ -36,41 +36,42 @@ DOCKER_USER_OPTS ?= $(DOCKER_COMMON_OPTS) \
3636
UNITTEST ?= pytest
3737
UNITTEST_OPTS ?= -v
3838

39+
.PHONY: clean build develop
40+
3941
all: clean test
4042

41-
build-proto:
43+
44+
build:
4245
PYTHONPATH=$(PWD):$(PYTHONPATH) \
43-
$(PYTHON) setup.py build_py
46+
DGP_DEV_VERSION=$(DEV_VERSION) $(PYTHON_EXEC) setup.py bdist_wheel
4447

4548
clean:
46-
$(PYTHON) setup.py clean && \
4749
rm -rf build dist && \
4850
find . -name "*.pyc" | xargs rm -f && \
4951
find . -name "__pycache__" | xargs rm -rf
5052
find . -name "*egg-info" | xargs rm -rf && \
5153
find dgp/proto -name "*_grpc.py" | xargs rm -rf
5254
find dgp/proto -name "*_pb2.py" | xargs rm -rf
5355
find dgp/contribs/pd -name "*_pb2.py" | xargs rm -rf
56+
find . -name "*eggs" | xargs rm -rf &
57+
$(PYTHON_EXEC) setup.py clean
5458

5559
develop:
56-
pip install cython==0.29.30 numpy==1.20.3 grpcio==1.41.0 grpcio-tools==1.41.0
57-
pip install --editable .
60+
DGP_DEV_VERSION=$(DEV_VERSION) $(PYTHON_EXEC) -m pip install --editable ".[dev]"
5861

5962
docker-build:
6063
docker build \
6164
--build-arg WORKSPACE=$(WORKSPACE) \
6265
-t $(DOCKER_IMAGE) .
6366

64-
docker-exec:
67+
docker-exec: docker-build
6568
docker exec -it $(DOCKER_IMAGE_NAME) $(COMMAND)
6669

67-
docker-run-tests: build-proto
68-
docker run \
69-
--name $(DOCKER_IMAGE_NAME)-tests \
70-
$(DOCKER_ROOT_OPTS) $(DOCKER_IMAGE) \
71-
$(UNITTEST) $(UNITTTEST_OPTS) $(WORKSPACE)/tests
70+
docker-run-tests: docker-build
71+
docker run --name $(DOCKER_IMAGE_NAME)-tests $(DOCKER_ROOT_OPTS) $(DOCKER_IMAGE) make test
72+
7273

73-
docker-start-interactive:
74+
docker-start-interactive: docker-build
7475
docker run \
7576
$(DOCKER_USER_OPTS) \
7677
$(DOCKER_IMAGE) \
@@ -83,9 +84,9 @@ setup-linters:
8384
pre-commit install
8485
pre-commit install --hook-type commit-msg
8586

86-
test: build-proto
87+
test: develop
8788
PYTHONPATH=$(PWD):$(PYTHONPATH) \
88-
$(UNITTEST) $(UNITTEST_OPTS) $(PWD)/tests/
89+
$(UNITTEST) $(UNITTEST_OPTS) $(PWD)/tests/ -vv
8990

9091
unlink-githooks:
9192
unlink .git/hooks/pre-push && unlink .git/hooks/pre-commit

README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,34 @@ You can build the base docker image and run the tests within
6262
[docker container](docs/GETTING_STARTED.md#markdown-header-develop-within-docker)
6363
via:
6464

65-
```sh
65+
```shell
6666
make docker-build
6767
make docker-run-tests
6868
```
6969

70+
Build the Python wheel.
71+
72+
```shell
73+
make build
74+
```
75+
76+
For setup local developement.
77+
78+
```shell
79+
make develop
80+
```
81+
82+
Runing the test using local development environment.
83+
84+
```shell
85+
make test
86+
```
87+
88+
## Versioning
89+
90+
This repository adheres to [PEP 440](https://peps.python.org/pep-0440/) for
91+
versioning.
92+
7093
## Contributing
7194

7295
We appreciate all contributions to DGP! To learn more about making a

build_proto.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import subprocess
3+
from pathlib import Path
4+
5+
_ROOT_DIRPATH = Path(__file__).parent.absolute()
6+
7+
8+
def build_proto(proto_version: str):
9+
assert proto_version in {"proto3", "proto4"}, "Unsupported proto version."
10+
from grpc_tools import command
11+
command.build_package_protos(_ROOT_DIRPATH)
12+
13+
14+
if __name__ == "__main__":
15+
proto_version = os.getenv("PROTO_VERSION", "proto3")
16+
build_proto(proto_version)

0 commit comments

Comments
 (0)