pydantic-rpc 0.13.0__py3-none-any.whl → 0.14.0__py3-none-any.whl
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/core.py
CHANGED
|
@@ -11,7 +11,7 @@ import signal
|
|
|
11
11
|
import sys
|
|
12
12
|
import time
|
|
13
13
|
import types
|
|
14
|
-
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable
|
|
14
|
+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
|
|
15
15
|
from concurrent import futures
|
|
16
16
|
from connectrpc.code import Code as Errors
|
|
17
17
|
# Protobuf Python modules for Timestamp, Duration (requires protobuf / grpcio)
|
|
@@ -2611,11 +2611,20 @@ class Server:
|
|
|
2611
2611
|
port: int = 50051,
|
|
2612
2612
|
package_name: str = "",
|
|
2613
2613
|
max_workers: int = 8,
|
|
2614
|
-
*interceptors: Any,
|
|
2615
2614
|
tls: Optional["GrpcTLSConfig"] = None,
|
|
2615
|
+
interceptors: Optional[Sequence[grpc.ServerInterceptor]] = None,
|
|
2616
|
+
handlers: Optional[Sequence[grpc.GenericRpcHandler]] = None,
|
|
2617
|
+
options: Optional[Sequence[Tuple[str, Any]]] = None,
|
|
2618
|
+
maximum_concurrent_rpcs: Optional[int] = None,
|
|
2619
|
+
compression: Optional[grpc.Compression] = None,
|
|
2616
2620
|
) -> None:
|
|
2617
2621
|
self._server: grpc.Server = grpc.server(
|
|
2618
|
-
futures.ThreadPoolExecutor(max_workers),
|
|
2622
|
+
futures.ThreadPoolExecutor(max_workers),
|
|
2623
|
+
handlers=handlers,
|
|
2624
|
+
interceptors=interceptors,
|
|
2625
|
+
options=options,
|
|
2626
|
+
maximum_concurrent_rpcs=maximum_concurrent_rpcs,
|
|
2627
|
+
compression=compression,
|
|
2619
2628
|
)
|
|
2620
2629
|
self._service_names: list[str] = []
|
|
2621
2630
|
self._package_name: str = package_name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pydantic-rpc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: A Python library for building gRPC/ConnectRPC services with Pydantic models.
|
|
5
5
|
Author: Yasushi Itoh
|
|
6
6
|
Requires-Dist: annotated-types==0.7.0
|
|
@@ -125,7 +125,7 @@ app = ASGIApp(service=OlympicsLocationAgent())
|
|
|
125
125
|
- 🔎 **Server Reflection:** Built-in support for gRPC server reflection.
|
|
126
126
|
- ⚡ **Asynchronous Support:** Easily create asynchronous gRPC services with `AsyncIOServer`.
|
|
127
127
|
- **For Connect-RPC:**
|
|
128
|
-
- 🌐 **Full Protocol Support:** Native Connect-RPC support via `
|
|
128
|
+
- 🌐 **Full Protocol Support:** Native Connect-RPC support via `connect-python`
|
|
129
129
|
- 🔄 **All Streaming Patterns:** Unary, server streaming, client streaming, and bidirectional streaming
|
|
130
130
|
- 🌐 **WSGI/ASGI Applications:** Run as standard WSGI or ASGI applications for easy deployment
|
|
131
131
|
- 🛠️ **Pre-generated Protobuf Files and Code:** Pre-generate proto files and corresponding code via the CLI. By setting the environment variable (PYDANTIC_RPC_SKIP_GENERATION), you can skip runtime generation.
|
|
@@ -304,21 +304,21 @@ app.mount(Greeter())
|
|
|
304
304
|
|
|
305
305
|
### 🏆 Connect-RPC with Streaming Example
|
|
306
306
|
|
|
307
|
-
PydanticRPC provides native Connect-RPC support via
|
|
307
|
+
PydanticRPC provides native Connect-RPC support via connect-python, including full streaming capabilities and PEP 8 naming conventions. Check out our ASGI examples:
|
|
308
308
|
|
|
309
309
|
```bash
|
|
310
310
|
# Run with uvicorn
|
|
311
311
|
uv run uvicorn greeting_asgi:app --port 3000
|
|
312
312
|
|
|
313
313
|
# Or run streaming example
|
|
314
|
-
uv run python examples/
|
|
314
|
+
uv run python examples/streaming_connect_python.py
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
-
This will launch a
|
|
317
|
+
This will launch a connect-python-based ASGI application that uses the same Pydantic models to serve Connect-RPC requests.
|
|
318
318
|
|
|
319
|
-
#### Streaming Support with
|
|
319
|
+
#### Streaming Support with connect-python
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
connect-python provides full support for streaming RPCs with automatic PEP 8 naming (snake_case):
|
|
322
322
|
|
|
323
323
|
```python
|
|
324
324
|
from typing import AsyncIterator
|
|
@@ -359,14 +359,7 @@ app.mount(StreamingService())
|
|
|
359
359
|
```
|
|
360
360
|
|
|
361
361
|
> [!NOTE]
|
|
362
|
-
> Please install `protoc-gen-
|
|
363
|
-
>
|
|
364
|
-
> 1. Install Go.
|
|
365
|
-
> - Please follow the instruction described in https://go.dev/doc/install.
|
|
366
|
-
> 2. Install `protoc-gen-connecpy`:
|
|
367
|
-
> ```bash
|
|
368
|
-
> go install github.com/i2y/connecpy/v2/protoc-gen-connecpy@latest
|
|
369
|
-
> ```
|
|
362
|
+
> Please install `protoc-gen-connect-python` to run the connect-python example.
|
|
370
363
|
|
|
371
364
|
## ♻️ Skipping Protobuf Generation
|
|
372
365
|
By default, PydanticRPC generates .proto files and code at runtime. If you wish to skip the code-generation step (for example, in production environment), set the environment variable below:
|
|
@@ -375,9 +368,9 @@ By default, PydanticRPC generates .proto files and code at runtime. If you wish
|
|
|
375
368
|
export PYDANTIC_RPC_SKIP_GENERATION=true
|
|
376
369
|
```
|
|
377
370
|
|
|
378
|
-
When this variable is set to "true", PydanticRPC will load existing pre-generated modules rather than generating
|
|
371
|
+
When this variable is set to "true", PydanticRPC will load existing pre-generated modules rather than generating theƒm on the fly.
|
|
379
372
|
|
|
380
|
-
## 🪧 Setting Protobuf and
|
|
373
|
+
## 🪧 Setting Protobuf and Connect RPC/gRPC generation directory
|
|
381
374
|
By default your files will be generated in the current working directory where you ran the code from, but you can set a custom specific directory by setting the environment variable below:
|
|
382
375
|
|
|
383
376
|
```bash
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
pydantic_rpc/__init__.py,sha256=c5e0b5d4ed6de3e3c7c1ada5389e704ce149ea56ca0930392db6abdf222b4e86,871
|
|
2
|
-
pydantic_rpc/core.py,sha256=
|
|
2
|
+
pydantic_rpc/core.py,sha256=422cbccacdf857e0c1d29e04784562de1bc47764d0f464b1086cceb7a3719c70,115689
|
|
3
3
|
pydantic_rpc/decorators.py,sha256=94d87825e034b6303df46dd74e6c8c7ed5c88133aa504d61249a83dbf82f1de3,6219
|
|
4
4
|
pydantic_rpc/mcp/__init__.py,sha256=f05ad62cc38db5c5972e16870c484523c58c5ac650d8454706f1ce4539cc7a52,123
|
|
5
5
|
pydantic_rpc/mcp/converter.py,sha256=b60dcaf82e6bff6be4b2ab8b1e9f2d16e09cb98d8f00182a4f6f73d1a78848a4,4158
|
|
@@ -7,6 +7,6 @@ pydantic_rpc/mcp/exporter.py,sha256=20833662f9a973ed9e1a705b9b59aaa2533de6c514eb
|
|
|
7
7
|
pydantic_rpc/options.py,sha256=6094036184a500b92715fd91d31ecc501460a56de47dcf6024c6335ae8e5d6e3,4561
|
|
8
8
|
pydantic_rpc/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
9
9
|
pydantic_rpc/tls.py,sha256=0eb290cc09c8ebedc71e7a97c01736d9675a314f70ebd80a2ce73e3f1689d359,3567
|
|
10
|
-
pydantic_rpc-0.
|
|
11
|
-
pydantic_rpc-0.
|
|
12
|
-
pydantic_rpc-0.
|
|
10
|
+
pydantic_rpc-0.14.0.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
|
|
11
|
+
pydantic_rpc-0.14.0.dist-info/METADATA,sha256=d2ea2414284c138bb9eb0f47fb63ff282bd4aa4e915c1ad9cc08d1840fa57ea1,35957
|
|
12
|
+
pydantic_rpc-0.14.0.dist-info/RECORD,,
|
|
File without changes
|