Пример #1
0
def execute(operator, datas=[], urls=[]):
    try:
        with grpc.insecure_channel(operator.endpoint) as channel:
            stub = rpc_pb2_grpc.OperatorStub(channel)
            res = stub.Execute(pb.ExecuteRequest(urls=urls, datas=datas))
            return [list(x.element) for x in res.vectors], res.metadata
    except Exception as e:
        raise e
Пример #2
0
def health(operator):
    try:
        with grpc.insecure_channel(operator.endpoint) as channel:
            stub = rpc_pb2_grpc.OperatorStub(channel)
            res = stub.Healthy(pb.HealthyRequest())
            return res.healthy
    except Exception as e:
        raise e
Пример #3
0
def execute(operator, datas=[], urls=[]):
    try:
        options = [('grpc.max_send_message_length', 100 * 1024 * 1024),
                   ('grpc.max_receive_message_length', 100 * 1024 * 1024)]
        with grpc.insecure_channel(operator.endpoint, options=options) as channel:
            stub = rpc_pb2_grpc.OperatorStub(channel)
            res = stub.Execute(pb.ExecuteRequest(urls=urls, datas=datas))
            return [list(x.element) for x in res.vectors], res.metadata
    except Exception as e:
        raise e
Пример #4
0
def identity(endpoint):
    try:
        with grpc.insecure_channel(endpoint) as channel:
            stub = rpc_pb2_grpc.OperatorStub(channel)
            res = stub.Identity(pb.IdentityRequest())
            return {
                "name": res.name,
                "endpoint": res.endpoint,
                "type": res.type,
                "input": res.input,
                "output": res.output,
                "dimension": res.dimension,
                "metric_type": res.metricType
            }
    except Exception as e:
        raise e