8000 Update protoc commands to match documentation. (#1188) · johnmanong/python-docs-samples@c010b7f · GitHub
[go: up one dir, main page]

Skip to content

Commit c010b7f

Browse files
kryzthovJon Wayne Parrott
authored andcommitted
Update protoc commands to match documentation. (GoogleCloudPlatform#1188)
- Use long flags for better readability. - Change API descriptor file from `out.pb` to `api_descriptor.pb`. - Use same protoc command everywhere for consistency and simplicity.
1 parent 580a3ce commit c010b7f

File tree

7 files changed

+67
-180
lines changed

7 files changed

+67
-180
lines changed

endpoints/bookstore-grpc/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ code in the sample distribution. To modify the sample or create your own gRPC
4646
API definition, you'll need to update the generated code. To do this, once the
4747
gRPC libraries and tools are installed, run:
4848

49-
python -m grpc.tools.protoc --python_out=generated_pb2 \
50-
--grpc_python_out=generated_pb2 --proto_path=. bookstore.proto
49+
python -m grpc.tools.protoc \
50+
--include_imports \
51+
--include_source_info \
52+
--proto_path=. \
53+
--python_out=generated_pb2 \
54+
--grpc_python_out=generated_pb2 \
55+
--descriptor_set_out=api_descriptor.pb \
56+
bookstore.proto
5157

5258
## Running the server with gRPC <-> HTTP/JSON Transcoding
5359

endpoints/getting-started-grpc/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,22 @@ Cloud account and [SDK](https://cloud.google.com/sdk/) configured.
2828
just wish to regenerate these files, run:
2929

3030
```bash
31-
python -m grpc_tools.protoc -I protos --python_out=. --grpc_python_out=. protos/helloworld.proto
32-
```
33-
34-
1. Generate the `out.pb` from the proto file:
35-
36-
```bash
37-
python -m grpc_tools.protoc --include_imports --include_source_info -I protos protos/helloworld.proto --descriptor_set_out out.pb
31+
python -m grpc.tools.protoc \
32+
--include_imports \
33+
--include_source_info \
34+
--proto_path=protos \
35+
--python_out=. \
36+
--grpc_python_out=. \
37+
--descriptor_set_out=api_descriptor.pb \
38+
helloworld.proto
3839
```
3940

4041
1. Edit, `api_config.yaml`. Replace `MY_PROJECT_ID` with your project id.
4142

4243
1. Deploy your service config to Service Management:
4344

4445
```bash
45-
gcloud endpoints services deploy out.pb api_config.yaml
46+
gcloud endpoints services deploy api_descriptor.pb api_config.yaml
4647
# The Config ID should be printed out, looks like: 2017-02-01r0, remember this
4748
4849
# Set your project ID as a variable to make commands easier:
@@ -97,20 +98,20 @@ Cloud account and [SDK](https://cloud.google.com/sdk/) configured.
9798
9899
```bash
99100
/usr/share/google/dockercfg_update.sh
100-
docker run -d --name=grpc-hello gcr.io/${GCLOUD_PROJECT}/python-grpc-hello:1.0
101+
docker run --detach --name=grpc-hello gcr.io/${GCLOUD_PROJECT}/python-grpc-hello:1.0
101102
```
102103
103104
1. Run the Endpoints proxy:
104105
105106
```bash
106107
docker run --detach --name=esp \
107-
-p 80:9000 \
108+
--publish=80:9000 \
108109
--link=grpc-hello:grpc-hello \
109110
gcr.io/endpoints-release/endpoints-runtime:1 \
110-
-s ${SERVICE_NAME} \
111-
-v ${SERVICE_CONFIG_ID} \
112-
-P 9000 \
113-
-a grpc://grpc-hello:50051
111+
--service=${SERVICE_NAME} \
112+
--version=${SERVICE_CONFIG_ID} \
113+
--http2_port=9000 \
114+
--backend=grpc://grpc-hello:50051
114115
```
115116
116117
1. Back on your local machine, get the external IP of your GCE instance:

endpoints/getting-started-grpc/container-engine.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ spec:
4141
- name: esp
4242
image: gcr.io/endpoints-release/endpoints-runtime:1
4343
args: [
44-
"-P", "9000",
45-
"-a", "grpc://127.0.0.1:50051",
46-
"-s", "SERVICE_NAME",
47-
"-v", "SERVICE_CONFIG_ID",
44+
"--http2_port=9000",
45+
"--backend=grpc://127.0.0.1:50051",
46+
"--service=SERVICE_NAME",
47+
"--version=SERVICE_CONFIG_ID",
4848
]
4949
ports:
5050
- containerPort: 9000

endpoints/getting-started-grpc/helloworld_pb2.py

Lines changed: 32 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

endpoints/getting-started-grpc/helloworld_pb2_grpc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
3-
from grpc.framework.common import cardinality
4-
from grpc.framework.interfaces.face import utilities as face_utilities
53

64
import helloworld_pb2 as helloworld__pb2
75

endpoints/getting-started/container-engine.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ spec:
4242
- name: esp
4343
image: gcr.io/endpoints-release/endpoints-runtime:1
4444
args: [
45-
"-p", "8081",
46-
"-a", "127.0.0.1:8080",
47-
"-s", "SERVICE_NAME",
48-
"-v", "SERVICE_CONFIG_ID",
45+
"--http_port=8081",
46+
"--backend=127.0.0.1:8080",
47+
"--service=SERVICE_NAME",
48+
"--version=SERVICE_CONFIG_ID",
4949
]
5050
# [END esp]
5151
ports:

endpoints/kubernetes/grpc-bookstore.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ spec:
4242
- name: esp
4343
image: gcr.io/endpoints-release/endpoints-runtime:1
4444
args: [
45-
"-P", "9000",
46-
"-s", "SERVICE_NAME",
47-
"-v", "SERVICE_CONFIG_ID",
48-
"-a", "grpc://127.0.0.1:8000"
45+
"--http2_port=9000",
46+
"--service=SERVICE_NAME",
47+
"--version=SERVICE_CONFIG_ID",
48+
"--backend=grpc://127.0.0.1:8000"
4949
]
5050
ports:
5151
- containerPort: 9000

0 commit comments

Comments
 (0)
0