pydantic-rpc 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/PKG-INFO +5 -4
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/README.md +1 -1
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/README.md +152 -144
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/agent_aio_grpc.py +7 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/agent_connecpy.py +53 -46
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2.py +9 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2.pyi +2 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2_grpc.py +26 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2.py +13 -6
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2.pyi +4 -4
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2_grpc.py +26 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_connecpy_client.py +2 -1
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2.py +9 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2.pyi +2 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2_grpc.py +26 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_sonora_client.py +8 -8
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_using_exsiting_pb2_modules.py +23 -22
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2.py +9 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2.pyi +4 -4
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2_grpc.py +30 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2.py +9 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2.pyi +2 -2
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/pyproject.toml +6 -5
- pydantic_rpc-0.4.1/src/pydantic_rpc/__init__.py +17 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/src/pydantic_rpc/core.py +1 -1
- pydantic_rpc-0.4.1/uv.lock +1586 -0
- pydantic_rpc-0.4.0/requirements-dev.lock +0 -223
- pydantic_rpc-0.4.0/requirements.lock +0 -97
- pydantic_rpc-0.4.0/src/pydantic_rpc/__init__.py +0 -8
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/.gitignore +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/.python-version +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/LICENSE +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/asyncio_greeting.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/foobar.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/foobar_client.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/google/protobuf/duration.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/google/protobuf/timestamp.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_client.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_connecpy.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_asgi.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_connecpy.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_wsgi.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent.proto +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_connecpy.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2_grpc.py +0 -0
- {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/src/pydantic_rpc/py.typed +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-rpc
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: A Python library for building gRPC/ConnectRPC services with Pydantic models.
|
|
5
5
|
Author: Yasushi Itoh
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Requires-Python: >=3.11
|
|
7
|
-
Requires-Dist: connecpy>=1.2.
|
|
8
|
+
Requires-Dist: connecpy>=1.2.1
|
|
8
9
|
Requires-Dist: grpcio-health-checking>=1.56.2
|
|
9
10
|
Requires-Dist: grpcio-reflection>=1.56.2
|
|
10
11
|
Requires-Dist: grpcio-tools>=1.56.2
|
|
@@ -229,7 +230,7 @@ app.mount(Greeter())
|
|
|
229
230
|
PydanticRPC also partially supports Connect-RPC via connecpy. Check out “greeting_connecpy.py” for an example:
|
|
230
231
|
|
|
231
232
|
```bash
|
|
232
|
-
|
|
233
|
+
uv run greeting_connecpy.py
|
|
233
234
|
```
|
|
234
235
|
|
|
235
236
|
This will launch a Connecpy-based ASGI application that uses the same Pydantic models to serve Connect-RPC requests.
|
|
@@ -215,7 +215,7 @@ app.mount(Greeter())
|
|
|
215
215
|
PydanticRPC also partially supports Connect-RPC via connecpy. Check out “greeting_connecpy.py” for an example:
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
|
|
218
|
+
uv run greeting_connecpy.py
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
This will launch a Connecpy-based ASGI application that uses the same Pydantic models to serve Connect-RPC requests.
|
|
@@ -1,144 +1,152 @@
|
|
|
1
|
-
# 📚 Examples
|
|
2
|
-
|
|
3
|
-
## 📝 Prerequisites
|
|
4
|
-
|
|
5
|
-
Ensure you have [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
# 📚 Examples
|
|
2
|
+
|
|
3
|
+
## 📝 Prerequisites
|
|
4
|
+
|
|
5
|
+
Ensure you have [UV](https://docs.astral.sh/uv/) installed on your system. If not, you can install it using the following command:
|
|
6
|
+
|
|
7
|
+
### Linux/macOS
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Windows
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 🔧 Setup
|
|
20
|
+
|
|
21
|
+
1. **Clone the Repository:**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/i2y/pydantic-rpc.git
|
|
25
|
+
cd pydantic-rpc/examples
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **Install Dependencies with Rye:**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv sync
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🖥️ gRPC Server Example
|
|
35
|
+
|
|
36
|
+
### 🔧 Server (`greeting.py`)
|
|
37
|
+
|
|
38
|
+
A simple gRPC server.
|
|
39
|
+
|
|
40
|
+
**Usage:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv run greeting.py
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 🔗 Client (`greeter_client.py`)
|
|
47
|
+
|
|
48
|
+
A gRPC client to interact with the server.
|
|
49
|
+
|
|
50
|
+
**Usage:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv run greeter_client.py
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ⚡ Asyncio gRPC Server Example
|
|
57
|
+
|
|
58
|
+
### 🔧 Asyncio Server (`asyncio_greeting.py`)
|
|
59
|
+
|
|
60
|
+
An asyncio gRPC server using `AsyncIOServer`.
|
|
61
|
+
|
|
62
|
+
**Usage:**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv run asyncio_greeting.py
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 🌐 ASGI Integration (gRPC-Web)
|
|
69
|
+
|
|
70
|
+
### 🌐 ASGI Application (`greeting_asgi.py`)
|
|
71
|
+
|
|
72
|
+
Integrate **PydanticRPC** (gRPC-Web) with an ASGI-compatible framework.
|
|
73
|
+
|
|
74
|
+
**Usage:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv run hypercorn -bind :3000 greeting_asgi:app
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 🔗 Client (`greeter_sonora_client.py`)
|
|
81
|
+
A gRPC-Web client to interact with the server.
|
|
82
|
+
|
|
83
|
+
**Usage:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
uv run greeter_sonora_client.py
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## 🌐 WSGI Integration
|
|
91
|
+
|
|
92
|
+
### 🌐 WSGI Application (`greeting_wsgi.py`)
|
|
93
|
+
|
|
94
|
+
Integrate **PydanticRPC** (gRPC-Web) with a WSGI-compatible framework.
|
|
95
|
+
|
|
96
|
+
**Usage:**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
uv run greeting_wsgi.py
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 🔗 Client (`greeter_sonora_client.py`)
|
|
103
|
+
A gRPC-Web client to interact with the server.
|
|
104
|
+
|
|
105
|
+
**Usage:**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
uv run greeter_sonora_client.py
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## 🛡️ Custom Interceptor and Running Multiple Services Exxample
|
|
113
|
+
|
|
114
|
+
### 🔧 Server (`foobar.py`)
|
|
115
|
+
A simple gRPC server with custom interceptor and running multiple services.
|
|
116
|
+
|
|
117
|
+
**Usage:**
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
uv run foobar.py
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 🔗 Client (`foobar_client.py`)
|
|
124
|
+
A gRPC client to interact with the server.
|
|
125
|
+
|
|
126
|
+
**Usage:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
uv run foobar_client.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🤝 Connecpy (Connect-RPC) Example
|
|
133
|
+
|
|
134
|
+
### 🔧 Server (`greeting_connecpy.py`)
|
|
135
|
+
|
|
136
|
+
A Connect-RPC ASGI application using PydanticRPC + connecpy.
|
|
137
|
+
|
|
138
|
+
**Usage:**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run hypercorn --bind :3000 greeting_connecpy:app
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 🔗 Client (`greeter_client_connecpy.py`)
|
|
145
|
+
|
|
146
|
+
A Connect-RPC client to interact with the server.
|
|
147
|
+
|
|
148
|
+
**Usage:**
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
uv run greeter_client_connecpy.py
|
|
152
|
+
```
|
|
@@ -35,6 +35,13 @@ class StreamingResult(Message):
|
|
|
35
35
|
|
|
36
36
|
class OlympicsAgent:
|
|
37
37
|
def __init__(self):
|
|
38
|
+
# # if pydantic_ai >= 0.0.21
|
|
39
|
+
# ollama_model = OpenAIModel(
|
|
40
|
+
# model_name="llama3.2",
|
|
41
|
+
# base_url="http://localhost:11434/v1",
|
|
42
|
+
# api_key="",
|
|
43
|
+
# )
|
|
44
|
+
# self._agent = Agent(ollama_model)
|
|
38
45
|
self._agent = Agent("ollama:llama3.2")
|
|
39
46
|
|
|
40
47
|
async def ask(self, req: OlympicsQuery) -> CityLocation:
|
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
|
|
3
|
-
from typing import Annotated
|
|
4
|
-
|
|
5
|
-
from hypercorn.asyncio import serve
|
|
6
|
-
from hypercorn.config import Config
|
|
7
|
-
from pydantic import Field
|
|
8
|
-
from pydantic_ai import Agent
|
|
9
|
-
from pydantic_rpc import ConnecpyASGIApp, Message
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class CityLocation(Message):
|
|
13
|
-
city: Annotated[str, Field(description="The city where the Olympics were held")]
|
|
14
|
-
country: Annotated[
|
|
15
|
-
str, Field(description="The country where the Olympics were held")
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class Olympics(Message):
|
|
20
|
-
year: Annotated[
|
|
21
|
-
int, Field(description="The year of the Olympics", ge=1896, multiple_of=4)
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
def prompt(self):
|
|
25
|
-
return f"Where were the Olympics held in {self.year}?"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class OlympicsLocationAgent:
|
|
29
|
-
def __init__(self):
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
from hypercorn.asyncio import serve
|
|
6
|
+
from hypercorn.config import Config
|
|
7
|
+
from pydantic import Field
|
|
8
|
+
from pydantic_ai import Agent
|
|
9
|
+
from pydantic_rpc import ConnecpyASGIApp, Message
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CityLocation(Message):
|
|
13
|
+
city: Annotated[str, Field(description="The city where the Olympics were held")]
|
|
14
|
+
country: Annotated[
|
|
15
|
+
str, Field(description="The country where the Olympics were held")
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Olympics(Message):
|
|
20
|
+
year: Annotated[
|
|
21
|
+
int, Field(description="The year of the Olympics", ge=1896, multiple_of=4)
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
def prompt(self):
|
|
25
|
+
return f"Where were the Olympics held in {self.year}?"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class OlympicsLocationAgent:
|
|
29
|
+
def __init__(self):
|
|
30
|
+
# # if pydantic_ai >= 0.0.21
|
|
31
|
+
# ollama_model = OpenAIModel(
|
|
32
|
+
# model_name="llama3.2",
|
|
33
|
+
# base_url="http://localhost:11434/v1",
|
|
34
|
+
# api_key="",
|
|
35
|
+
# )
|
|
36
|
+
# self._agent = Agent(ollama_model, result_type=CityLocation)
|
|
37
|
+
self._agent = Agent("ollama:llama3.2", result_type=CityLocation)
|
|
38
|
+
|
|
39
|
+
async def ask(self, req: Olympics) -> CityLocation:
|
|
40
|
+
result = await self._agent.run(req.prompt())
|
|
41
|
+
return result.data
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
async def main():
|
|
45
|
+
app = ConnecpyASGIApp()
|
|
46
|
+
app.mount(OlympicsLocationAgent())
|
|
47
|
+
config = Config()
|
|
48
|
+
config.bind = ["0.0.0.0:3000"]
|
|
49
|
+
await serve(app, config)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
asyncio.run(main())
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
3
4
|
# source: barservice.proto
|
|
5
|
+
# Protobuf Python Version: 5.29.0
|
|
4
6
|
"""Generated protocol buffer code."""
|
|
5
7
|
|
|
6
8
|
from google.protobuf import descriptor as _descriptor
|
|
7
9
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
10
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
8
11
|
from google.protobuf import symbol_database as _symbol_database
|
|
9
12
|
from google.protobuf.internal import builder as _builder
|
|
13
|
+
|
|
14
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
15
|
+
_runtime_version.Domain.PUBLIC, 5, 29, 0, "", "barservice.proto"
|
|
16
|
+
)
|
|
10
17
|
# @@protoc_insertion_point(imports)
|
|
11
18
|
|
|
12
19
|
_sym_db = _symbol_database.Default()
|
|
@@ -19,8 +26,8 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
|
|
|
19
26
|
_globals = globals()
|
|
20
27
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
21
28
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "barservice_pb2", _globals)
|
|
22
|
-
if _descriptor._USE_C_DESCRIPTORS
|
|
23
|
-
DESCRIPTOR.
|
|
29
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
30
|
+
DESCRIPTOR._loaded_options = None
|
|
24
31
|
_globals["_BARRESPONSE"]._serialized_start = 28
|
|
25
32
|
_globals["_BARRESPONSE"]._serialized_end = 56
|
|
26
33
|
_globals["_BARREQUEST"]._serialized_start = 58
|
|
@@ -6,13 +6,13 @@ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Op
|
|
|
6
6
|
DESCRIPTOR: _descriptor.FileDescriptor
|
|
7
7
|
|
|
8
8
|
class BarResponse(_message.Message):
|
|
9
|
-
__slots__ =
|
|
9
|
+
__slots__ = ("names",)
|
|
10
10
|
NAMES_FIELD_NUMBER: _ClassVar[int]
|
|
11
11
|
names: _containers.RepeatedScalarFieldContainer[str]
|
|
12
12
|
def __init__(self, names: _Optional[_Iterable[str]] = ...) -> None: ...
|
|
13
13
|
|
|
14
14
|
class BarRequest(_message.Message):
|
|
15
|
-
__slots__ =
|
|
15
|
+
__slots__ = ("names",)
|
|
16
16
|
NAMES_FIELD_NUMBER: _ClassVar[int]
|
|
17
17
|
names: _containers.RepeatedScalarFieldContainer[str]
|
|
18
18
|
def __init__(self, names: _Optional[_Iterable[str]] = ...) -> None: ...
|
|
@@ -2,9 +2,32 @@
|
|
|
2
2
|
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
3
|
|
|
4
4
|
import grpc
|
|
5
|
+
import warnings
|
|
5
6
|
|
|
6
7
|
import barservice_pb2 as barservice__pb2
|
|
7
8
|
|
|
9
|
+
GRPC_GENERATED_VERSION = "1.70.0"
|
|
10
|
+
GRPC_VERSION = grpc.__version__
|
|
11
|
+
_version_not_supported = False
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from grpc._utilities import first_version_is_lower
|
|
15
|
+
|
|
16
|
+
_version_not_supported = first_version_is_lower(
|
|
17
|
+
GRPC_VERSION, GRPC_GENERATED_VERSION
|
|
18
|
+
)
|
|
19
|
+
except ImportError:
|
|
20
|
+
_version_not_supported = True
|
|
21
|
+
|
|
22
|
+
if _version_not_supported:
|
|
23
|
+
raise RuntimeError(
|
|
24
|
+
f"The grpc package installed is at version {GRPC_VERSION},"
|
|
25
|
+
+ f" but the generated code in barservice_pb2_grpc.py depends on"
|
|
26
|
+
+ f" grpcio>={GRPC_GENERATED_VERSION}."
|
|
27
|
+
+ f" Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}"
|
|
28
|
+
+ f" or downgrade your generated code using grpcio-tools<={GRPC_VERSION}."
|
|
29
|
+
)
|
|
30
|
+
|
|
8
31
|
|
|
9
32
|
class BarServiceStub(object):
|
|
10
33
|
"""Missing associated documentation comment in .proto file."""
|
|
@@ -19,6 +42,7 @@ class BarServiceStub(object):
|
|
|
19
42
|
"/bar.v1.BarService/Bar",
|
|
20
43
|
request_serializer=barservice__pb2.BarRequest.SerializeToString,
|
|
21
44
|
response_deserializer=barservice__pb2.BarResponse.FromString,
|
|
45
|
+
_registered_method=True,
|
|
22
46
|
)
|
|
23
47
|
|
|
24
48
|
|
|
@@ -44,6 +68,7 @@ def add_BarServiceServicer_to_server(servicer, server):
|
|
|
44
68
|
"bar.v1.BarService", rpc_method_handlers
|
|
45
69
|
)
|
|
46
70
|
server.add_generic_rpc_handlers((generic_handler,))
|
|
71
|
+
server.add_registered_method_handlers("bar.v1.BarService", rpc_method_handlers)
|
|
47
72
|
|
|
48
73
|
|
|
49
74
|
# This class is part of an EXPERIMENTAL API.
|
|
@@ -77,4 +102,5 @@ class BarService(object):
|
|
|
77
102
|
wait_for_ready,
|
|
78
103
|
timeout,
|
|
79
104
|
metadata,
|
|
105
|
+
_registered_method=True,
|
|
80
106
|
)
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
3
4
|
# source: fooservice.proto
|
|
5
|
+
# Protobuf Python Version: 5.29.0
|
|
4
6
|
"""Generated protocol buffer code."""
|
|
5
7
|
|
|
6
8
|
from google.protobuf import descriptor as _descriptor
|
|
7
9
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
10
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
8
11
|
from google.protobuf import symbol_database as _symbol_database
|
|
9
12
|
from google.protobuf.internal import builder as _builder
|
|
13
|
+
|
|
14
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
15
|
+
_runtime_version.Domain.PUBLIC, 5, 29, 0, "", "fooservice.proto"
|
|
16
|
+
)
|
|
10
17
|
# @@protoc_insertion_point(imports)
|
|
11
18
|
|
|
12
19
|
_sym_db = _symbol_database.Default()
|
|
@@ -19,12 +26,12 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
|
|
|
19
26
|
_globals = globals()
|
|
20
27
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
21
28
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "fooservice_pb2", _globals)
|
|
22
|
-
if _descriptor._USE_C_DESCRIPTORS
|
|
23
|
-
DESCRIPTOR.
|
|
24
|
-
_FOORESPONSE_DENTRY.
|
|
25
|
-
_FOORESPONSE_DENTRY._serialized_options = b"8\001"
|
|
26
|
-
_FOOREQUEST_DENTRY.
|
|
27
|
-
_FOOREQUEST_DENTRY._serialized_options = b"8\001"
|
|
29
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
30
|
+
DESCRIPTOR._loaded_options = None
|
|
31
|
+
_globals["_FOORESPONSE_DENTRY"]._loaded_options = None
|
|
32
|
+
_globals["_FOORESPONSE_DENTRY"]._serialized_options = b"8\001"
|
|
33
|
+
_globals["_FOOREQUEST_DENTRY"]._loaded_options = None
|
|
34
|
+
_globals["_FOOREQUEST_DENTRY"]._serialized_options = b"8\001"
|
|
28
35
|
_globals["_FOORESPONSE"]._serialized_start = 28
|
|
29
36
|
_globals["_FOORESPONSE"]._serialized_end = 149
|
|
30
37
|
_globals["_FOORESPONSE_DENTRY"]._serialized_start = 109
|
|
@@ -6,9 +6,9 @@ from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Opti
|
|
|
6
6
|
DESCRIPTOR: _descriptor.FileDescriptor
|
|
7
7
|
|
|
8
8
|
class FooResponse(_message.Message):
|
|
9
|
-
__slots__ =
|
|
9
|
+
__slots__ = ("name", "age", "d")
|
|
10
10
|
class DEntry(_message.Message):
|
|
11
|
-
__slots__ =
|
|
11
|
+
__slots__ = ("key", "value")
|
|
12
12
|
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
13
13
|
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
14
14
|
key: str
|
|
@@ -31,9 +31,9 @@ class FooResponse(_message.Message):
|
|
|
31
31
|
) -> None: ...
|
|
32
32
|
|
|
33
33
|
class FooRequest(_message.Message):
|
|
34
|
-
__slots__ =
|
|
34
|
+
__slots__ = ("name", "age", "d")
|
|
35
35
|
class DEntry(_message.Message):
|
|
36
|
-
__slots__ =
|
|
36
|
+
__slots__ = ("key", "value")
|
|
37
37
|
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
38
38
|
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
39
39
|
key: str
|
|
@@ -2,9 +2,32 @@
|
|
|
2
2
|
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
3
|
|
|
4
4
|
import grpc
|
|
5
|
+
import warnings
|
|
5
6
|
|
|
6
7
|
import fooservice_pb2 as fooservice__pb2
|
|
7
8
|
|
|
9
|
+
GRPC_GENERATED_VERSION = "1.70.0"
|
|
10
|
+
GRPC_VERSION = grpc.__version__
|
|
11
|
+
_version_not_supported = False
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from grpc._utilities import first_version_is_lower
|
|
15
|
+
|
|
16
|
+
_version_not_supported = first_version_is_lower(
|
|
17
|
+
GRPC_VERSION, GRPC_GENERATED_VERSION
|
|
18
|
+
)
|
|
19
|
+
except ImportError:
|
|
20
|
+
_version_not_supported = True
|
|
21
|
+
|
|
22
|
+
if _version_not_supported:
|
|
23
|
+
raise RuntimeError(
|
|
24
|
+
f"The grpc package installed is at version {GRPC_VERSION},"
|
|
25
|
+
+ f" but the generated code in fooservice_pb2_grpc.py depends on"
|
|
26
|
+
+ f" grpcio>={GRPC_GENERATED_VERSION}."
|
|
27
|
+
+ f" Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}"
|
|
28
|
+
+ f" or downgrade your generated code using grpcio-tools<={GRPC_VERSION}."
|
|
29
|
+
)
|
|
30
|
+
|
|
8
31
|
|
|
9
32
|
class FooServiceStub(object):
|
|
10
33
|
"""Missing associated documentation comment in .proto file."""
|
|
@@ -19,6 +42,7 @@ class FooServiceStub(object):
|
|
|
19
42
|
"/foo.v1.FooService/Foo",
|
|
20
43
|
request_serializer=fooservice__pb2.FooRequest.SerializeToString,
|
|
21
44
|
response_deserializer=fooservice__pb2.FooResponse.FromString,
|
|
45
|
+
_registered_method=True,
|
|
22
46
|
)
|
|
23
47
|
|
|
24
48
|
|
|
@@ -44,6 +68,7 @@ def add_FooServiceServicer_to_server(servicer, server):
|
|
|
44
68
|
"foo.v1.FooService", rpc_method_handlers
|
|
45
69
|
)
|
|
46
70
|
server.add_generic_rpc_handlers((generic_handler,))
|
|
71
|
+
server.add_registered_method_handlers("foo.v1.FooService", rpc_method_handlers)
|
|
47
72
|
|
|
48
73
|
|
|
49
74
|
# This class is part of an EXPERIMENTAL API.
|
|
@@ -77,4 +102,5 @@ class FooService(object):
|
|
|
77
102
|
wait_for_ready,
|
|
78
103
|
timeout,
|
|
79
104
|
metadata,
|
|
105
|
+
_registered_method=True,
|
|
80
106
|
)
|