Skip to main content

a client library for Vald (https://github.com/vdaas/vald).

Project description

vald-client-python

PyPI version

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.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vald_client_python-1.7.0-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file vald-client-python-1.7.0.tar.gz.

File metadata

  • Download URL: vald-client-python-1.7.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for vald-client-python-1.7.0.tar.gz
Algorithm Hash digest
SHA256 3979fcfbdecfe04a301f8462d190d9728e4e852f651cfdad962113fc5bbecf55
MD5 463a5eaed950cd16cd18447d68167f07
BLAKE2b-256 49c79f39b2e314dbffc52d2d6cbe8cab3ffe2c3d3e08cd0d140d8adfa57e7bd9

See more details on using hashes here.

File details

Details for the file vald_client_python-1.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vald_client_python-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72c6335b1f98189d38fa4485e05d578e4746f4796f6627da2af820b3f7ecad6f
MD5 32f241334c4c0103d33995c1930815d2
BLAKE2b-256 f01392ea2c7f91a0d35d6c9b0e3c2d20c641461ef0eca763882f8bb7b5a1fe2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page