Skip to content

Commit 7ad9e5c

Browse files
[Fix] Reproduce generation of existing gRPC stubs (#94)
1 parent 201085a commit 7ad9e5c

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

.vscode/tasks.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,15 @@
316316
"group": "none",
317317
"isBackground": false,
318318
"problemMatcher": []
319+
},
320+
{
321+
"label": "(Re-) generate gRPC stubs",
322+
"detail": "Re-generates the gRPC stubs located in sdv/proto folder",
323+
"type": "shell",
324+
"command": "./generate-grpc-stubs.sh",
325+
"group": "none",
326+
"isBackground": false,
327+
"problemMatcher": []
319328
}
320329
],
321330
"inputs": [

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ https://www.eclipse.org/projects/handbook/#resources-commit
4949
* When you make changes to existing protocol buffer files, regenerate the python descriptors with the following command:
5050

5151
```bash
52-
python3 -m grpc_tools.protoc -I sdv/proto --grpc_python_out=./sdv/proto --python_out=./sdv/proto --mypy_out=./sdv/proto sdv/proto/*/*/*.proto
52+
./generate-grpc-stubs.sh
5353
```
54-
Afterwards adjust relative imports as needed.
54+
or use the corresponding VSCode task.
5555
* Make sure you include test cases and new examples for non-trivial features.
5656
* Make sure test cases provide sufficient code coverage (see GitHub actions for minimal accepted coverage).
5757
* Install and run [pre-commit](https://pre-commit.com/) to automatically check for style guide issues.

generate-grpc-stubs.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/zsh
2+
# Copyright (c) 2023 Robert Bosch GmbH and Microsoft Corporation
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Apache License, Version 2.0 which is available at
6+
# https://www.apache.org/licenses/LICENSE-2.0.
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
#
14+
# SPDX-License-Identifier: Apache-2.0
15+
16+
echo "#######################################################"
17+
echo "### Generating gRPC stubs from proto files ###"
18+
echo "#######################################################"
19+
20+
ROOT_DIR=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" )
21+
22+
python3 -m grpc_tools.protoc -I ./sdv/proto --grpc_python_out=./sdv/proto --python_out=./sdv/proto --mypy_out=./sdv/proto ./sdv/proto/**/*.proto
23+
mv -f ./sdv/proto/**/*.py ./sdv/proto
24+
mv -f ./sdv/proto/**/*.pyi ./sdv/proto
25+
sed -i -e 's/from sdv\..* import/from sdv.proto import/g' -e 's/import sdv\..*\./import sdv.proto./g' ./sdv/proto/*.py*

sdv/proto/sdv/databroker/v1/broker.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ syntax = "proto3";
1616

1717
package sdv.databroker.v1;
1818

19-
import "types.proto";
19+
import "sdv/databroker/v1/types.proto";
2020

2121
service Broker {
2222
// Request a set of datapoints (values)

sdv/proto/sdv/databroker/v1/collector.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
syntax = "proto3";
1616

17-
import "types.proto";
17+
import "sdv/databroker/v1/types.proto";
1818

1919
package sdv.databroker.v1;
2020

0 commit comments

Comments
 (0)