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.
Files changed (51) hide show
  1. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/PKG-INFO +5 -4
  2. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/README.md +1 -1
  3. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/README.md +152 -144
  4. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/agent_aio_grpc.py +7 -0
  5. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/agent_connecpy.py +53 -46
  6. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2.py +9 -2
  7. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2.pyi +2 -2
  8. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice_pb2_grpc.py +26 -0
  9. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2.py +13 -6
  10. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2.pyi +4 -4
  11. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice_pb2_grpc.py +26 -0
  12. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_connecpy_client.py +2 -1
  13. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2.py +9 -2
  14. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2.pyi +2 -2
  15. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_pb2_grpc.py +26 -0
  16. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_sonora_client.py +8 -8
  17. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_using_exsiting_pb2_modules.py +23 -22
  18. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2.py +9 -2
  19. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2.pyi +4 -4
  20. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent_pb2_grpc.py +30 -0
  21. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2.py +9 -2
  22. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2.pyi +2 -2
  23. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/pyproject.toml +6 -5
  24. pydantic_rpc-0.4.1/src/pydantic_rpc/__init__.py +17 -0
  25. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/src/pydantic_rpc/core.py +1 -1
  26. pydantic_rpc-0.4.1/uv.lock +1586 -0
  27. pydantic_rpc-0.4.0/requirements-dev.lock +0 -223
  28. pydantic_rpc-0.4.0/requirements.lock +0 -97
  29. pydantic_rpc-0.4.0/src/pydantic_rpc/__init__.py +0 -8
  30. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/.gitignore +0 -0
  31. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/.python-version +0 -0
  32. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/LICENSE +0 -0
  33. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/asyncio_greeting.py +0 -0
  34. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/barservice.proto +0 -0
  35. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/foobar.py +0 -0
  36. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/foobar_client.py +0 -0
  37. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/fooservice.proto +0 -0
  38. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/google/protobuf/duration.proto +0 -0
  39. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/google/protobuf/timestamp.proto +0 -0
  40. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter.proto +0 -0
  41. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_client.py +0 -0
  42. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeter_connecpy.py +0 -0
  43. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting.py +0 -0
  44. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_asgi.py +0 -0
  45. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_connecpy.py +0 -0
  46. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/greeting_wsgi.py +0 -0
  47. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicsagent.proto +0 -0
  48. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent.proto +0 -0
  49. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_connecpy.py +0 -0
  50. {pydantic_rpc-0.4.0 → pydantic_rpc-0.4.1}/examples/olympicslocationagent_pb2_grpc.py +0 -0
  51. {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.3
1
+ Metadata-Version: 2.4
2
2
  Name: pydantic-rpc
3
- Version: 0.4.0
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.0
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
- rye run python greeting_connecpy.py
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
- rye run python greeting_connecpy.py
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 [Rye](https://rye-up.com/) installed on your system. If not, you can install it using the following command:
6
-
7
- ```bash
8
- curl -sSL https://rye-up.com/install.sh | bash
9
- ```
10
-
11
- ## 🔧 Setup
12
-
13
- 1. **Clone the Repository:**
14
-
15
- ```bash
16
- git clone https://github.com/i2y/pydantic-rpc.git
17
- cd pydantic-rpc/examples
18
- ```
19
-
20
- 2. **Install Dependencies with Rye:**
21
-
22
- ```bash
23
- rye sync
24
- ```
25
-
26
- ## 🖥️ gRPC Server Example
27
-
28
- ### 🔧 Server (`greeting.py`)
29
-
30
- A simple gRPC server.
31
-
32
- **Usage:**
33
-
34
- ```bash
35
- rye run python greeting.py
36
- ```
37
-
38
- ### 🔗 Client (`greeter_client.py`)
39
-
40
- A gRPC client to interact with the server.
41
-
42
- **Usage:**
43
-
44
- ```bash
45
- rye run python greeter_client.py
46
- ```
47
-
48
- ## Asyncio gRPC Server Example
49
-
50
- ### 🔧 Asyncio Server (`asyncio_greeting.py`)
51
-
52
- An asyncio gRPC server using `AsyncIOServer`.
53
-
54
- **Usage:**
55
-
56
- ```bash
57
- rye run python asyncio_greeting.py
58
- ```
59
-
60
- ## 🌐 ASGI Integration (gRPC-Web)
61
-
62
- ### 🌐 ASGI Application (`greeting_asgi.py`)
63
-
64
- Integrate **PydanticRPC** (gRPC-Web) with an ASGI-compatible framework.
65
-
66
- **Usage:**
67
-
68
- ```bash
69
- rye run hypercorn -bind :3000 greeting_asgi:app
70
- ```
71
-
72
- ### 🔗 Client (`greeter_sonora_client.py`)
73
- A gRPC-Web client to interact with the server.
74
-
75
- **Usage:**
76
-
77
- ```bash
78
- rye run python greeter_sonora_client.py
79
- ```
80
-
81
-
82
- ## 🌐 WSGI Integration
83
-
84
- ### 🌐 WSGI Application (`greeting_wsgi.py`)
85
-
86
- Integrate **PydanticRPC** (gRPC-Web) with a WSGI-compatible framework.
87
-
88
- **Usage:**
89
-
90
- ```bash
91
- rye run python greeting_wsgi.py
92
- ```
93
-
94
- ### 🔗 Client (`greeter_sonora_client.py`)
95
- A gRPC-Web client to interact with the server.
96
-
97
- **Usage:**
98
-
99
- ```bash
100
- rye run python greeter_sonora_client.py
101
- ```
102
-
103
-
104
- ## 🛡️ Custom Interceptor and Running Multiple Services Exxample
105
-
106
- ### 🔧 Server (`foobar.py`)
107
- A simple gRPC server with custom interceptor and running multiple services.
108
-
109
- **Usage:**
110
-
111
- ```bash
112
- rye run python foobar.py
113
- ```
114
-
115
- ### 🔗 Client (`foobar_client.py`)
116
- A gRPC client to interact with the server.
117
-
118
- **Usage:**
119
-
120
- ```bash
121
- rye run python foobar_client.py
122
- ```
123
-
124
- ## 🤝 Connecpy (Connect-RPC) Example
125
-
126
- ### 🔧 Server (`greeting_connecpy.py`)
127
-
128
- A Connect-RPC ASGI application using PydanticRPC + connecpy.
129
-
130
- **Usage:**
131
-
132
- ```bash
133
- rye run hypercorn --bind :3000 greeting_connecpy:app
134
- ```
135
-
136
- ### 🔗 Client (`greeter_client_connecpy.py`)
137
-
138
- A Connect-RPC client to interact with the server.
139
-
140
- **Usage:**
141
-
142
- ```bash
143
- rye run python greeter_client_connecpy.py
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
- self._agent = Agent("ollama:llama3.2", result_type=CityLocation)
31
-
32
- async def ask(self, req: Olympics) -> CityLocation:
33
- result = await self._agent.run(req.prompt())
34
- return result.data
35
-
36
-
37
- async def main():
38
- app = ConnecpyASGIApp()
39
- app.mount(OlympicsLocationAgent())
40
- config = Config()
41
- config.bind = ["0.0.0.0:3000"]
42
- await serve(app, config)
43
-
44
-
45
- if __name__ == "__main__":
46
- asyncio.run(main())
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 == False:
23
- DESCRIPTOR._options = None
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__ = ["names"]
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__ = ["names"]
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 == False:
23
- DESCRIPTOR._options = None
24
- _FOORESPONSE_DENTRY._options = None
25
- _FOORESPONSE_DENTRY._serialized_options = b"8\001"
26
- _FOOREQUEST_DENTRY._options = None
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__ = ["name", "age", "d"]
9
+ __slots__ = ("name", "age", "d")
10
10
  class DEntry(_message.Message):
11
- __slots__ = ["key", "value"]
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__ = ["name", "age", "d"]
34
+ __slots__ = ("name", "age", "d")
35
35
  class DEntry(_message.Message):
36
- __slots__ = ["key", "value"]
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
  )