a client library for Vald (https://github.com/vdaas/vald).
Project description
vald-client-python
A Python gRPC client library for Vald.
Install
Using pip,
pip install vald-client-python
Usage
To use v1 APIs,
import grpc
from vald.v1.vald import insert_pb2_grpc
from vald.v1.vald import search_pb2_grpc
from vald.v1.vald import update_pb2_grpc
from vald.v1.vald import remove_pb2_grpc
from vald.v1.payload import payload_pb2
## create a channel by passing "{host}:{port}"
channel = grpc.insecure_channel("gateway.vald.vdaas.org:80")
## create stubs for calling RPCs
istub = insert_pb2_grpc.InsertStub(channel)
sstub = search_pb2_grpc.SearchStub(channel)
ustub = update_pb2_grpc.UpdateStub(channel)
rstub = remove_pb2_grpc.RemoveStub(channel)
## call RPCs: Insert
vec = payload_pb2.Object.Vector(id='vector_id_1', vector=[0.1, 0.2, 0.3])
icfg = payload_pb2.Insert.Config(skip_strict_exist_check=True)
istub.Insert(payload_pb2.Insert.Request(vector=vec, config=icfg))
## call RPCs: Search
### num: number of results
### timeout: 3 seconds
scfg = payload_pb2.Search.Config(num=10, radius=-1.0, epsilon=0.01, timeout=3000000000)
res = sstub.Search(payload_pb2.Search.Request(vector=[0.1, 0.2, 0.3], config=scfg))
## call RPCs: Update
uvec = payload_pb2.Object.Vector(id='vector_id_1', vector=[0.1, 0.2, 0.3])
ucfg = payload_pb2.Update.Config(skip_strict_exist_check=True)
ustub.Update(payload_pb2.Update.Request(vector=uvec, config=ucfg))
## call RPCs: Remove
rcfg = payload_pb2.Remove.Config(skip_strict_exist_check=True)
rid = payload_pb2.Object.ID(id='vector_id_1')
rstub.Remove(payload_pb2.Remove.Request(id=rid, config=rcfg))
## close channel
channel.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vald-client-python-1.7.10.tar.gz
(34.7 kB
view hashes)
Built Distribution
Close
Hashes for vald-client-python-1.7.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05f52a014e25bc09ee66c825a38e781bd1c80c07a56bc036c6816cd0625b67d |
|
MD5 | 14f032435e54c270c0737e8590b8c7d5 |
|
BLAKE2b-256 | 82c43affe5975677d0d8d547b6fda4d649d6afe09c0f331dedd3ca53fb5cd959 |
Close
Hashes for vald_client_python-1.7.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90b933f019c8fbca171eacaacabafb3f66126ac85505e82828ecaf8a08e3ae9e |
|
MD5 | b08223e5074b66d4da72441ad3d2be7e |
|
BLAKE2b-256 | 1474dac53a46d3877e1ceee9e00a7c172b58cb38e081c597ad25d24812ab5f8d |