ray-project / rayfed

A multiple parties joint, distributed execution engine based on Ray, to help build your own federated learning frameworks in minutes.
https://rayfed.readthedocs.io
Apache License 2.0
92 stars 21 forks source link

Pass grpc metadata #99

Closed jovany-wang closed 1 year ago

jovany-wang commented 1 year ago

The python grpc code:

import grpc
from your_grpc_module import your_pb2, your_pb2_grpc

# Create gRPC channel
channel = grpc.insecure_channel('localhost:50051')
stub = your_pb2_grpc.YourServiceStub(channel)

# Define the metadata
metadata = [
    ('header-key1', 'header-value1'),
    ('header-key2', 'header-value2'),
]

# RPC call within metadata
response = stub.YourRpcMethod(your_pb2.YourRequest(), metadata=metadata)