Python client for Vektonn

Overview

Python client for Vektonn

CI version Supported Python Versions license

Installation

Install the latest version:

$ pip install vektonn

Install specific version:

$ pip install vektonn==1.2.3

Upgrade to the latest version:

$ pip install --upgrade vektonn

Usage

Having Vektonn running on localhost:8081 and configured for QuickStart examples one can access it with synchronous Python client:

from vektonn import Vektonn

vektonn_client = Vektonn('http://localhost:8081')

or asynchronous one:

from vektonn import VektonnAsync

vektonn_client_async = VektonnAsync('http://localhost:8081')

To upload data to Vektonn use upload() method:

from vektonn.dtos import AttributeDto, AttributeValueDto, InputDataPointDto, VectorDto

vektonn_client.upload(
    data_source_name='QuickStart.Source',
    data_source_version='1.0',
    input_data_points=[
        InputDataPointDto(
            attributes=[
                AttributeDto(key='id', value=AttributeValueDto(int64=1)),
                AttributeDto(key='payload', value=AttributeValueDto(string='sample data point')),
            ],
            vector=VectorDto(is_sparse=False, coordinates=[3.14, 2.71]))
    ])

To query Vektonn for k nearest data points to the given query_vector use search() method:

from vektonn.dtos import VectorDto, SearchQueryDto

k = 10
query_vector = VectorDto(is_sparse=False, coordinates=[1.2, 3.4])

search_results = vektonn_client.search(
    index_name='QuickStart.Index',
    index_version='1.0',
    search_query=SearchQueryDto(k=k, query_vectors=[query_vector]))

print(f'For query vector {query_vector.coordinates} {k} nearest data points are:')
for fdp in search_results[0].nearest_data_points:
    attrs = {x.key : x.value for x in fdp.attributes}
    distance, vector, dp_id, payload = fdp.distance, fdp.vector, attrs['id'].int64, attrs['payload'].string
    print(f' - "{payload}" with id = {dp_id}, vector = {vector.coordinates}, distance = {distance}')
You might also like...
Python Client for Instagram API

This project is not actively maintained. Proceed at your own risk! python-instagram A Python 2/3 client for the Instagram REST and Search APIs Install

The official Python client library for the Kite Connect trading APIs

The Kite Connect API Python client - v3 The official Python client for communicating with the Kite Connect API. Kite Connect is a set of REST-like API

A Python Client for News API

newsapi-python A Python client for the News API. License Provided under MIT License by Matt Lisivick. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRAN

SmartFile API Client (Python).
SmartFile API Client (Python).

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software. Summary This library includes two API cli

Python client for the Socrata Open Data API

sodapy sodapy is a python client for the Socrata Open Data API. Installation You can install with pip install sodapy. If you want to install from sour

Python client for the Echo Nest API
Python client for the Echo Nest API

Pyechonest Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web. Pyechonest is an

A Python Tumblr API v2 Client

PyTumblr Installation Install via pip: $ pip install pytumblr Install from source: $ git clone https://github.com/tumblr/pytumblr.git $ cd pytumblr $

A super awesome Twitter API client for Python.

birdy birdy is a super awesome Twitter API client for Python in just a little under 400 LOC. TL;DR Features Future proof dynamic API with full REST an

Unirest in Python: Simplified, lightweight HTTP client library.

Unirest for Python Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain

Comments
  • Optimize DTOs json serialization

    Optimize DTOs json serialization

    test_perf_serialize run shows that VektonnBaseModel.json() is a huge bottleneck:

    ----------------------------- Captured stdout call -----------------------------
             28285893 function calls in 25.275 seconds
    
       Ordered by: internal time
    
       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       118351   15.430    0.000   21.607    0.000 dtos.py:17(json)
       118351    3.108    0.000    3.522    0.000 test_dtos_perf.py:55(to_idp_fast)
     12781908    2.509    0.000    2.509    0.000 {built-in method _abc._abc_instancecheck}
     12781908    2.122    0.000    4.630    0.000 abc.py:96(__instancecheck__)
       118351    0.691    0.000    0.691    0.000 {orjson.dumps}
       118351    0.414    0.000    0.414    0.000 {method 'tolist' of 'numpy.ndarray' objects}
       118351    0.189    0.000    0.552    0.000 typing.py:802(__getitem__)
       118351    0.130    0.000    0.317    0.000 typing.py:255(inner)
       236702    0.113    0.000    0.1[65](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:65)    0.000 <frozen importlib._bootstrap>:389(parent)
       118351    0.076    0.000    0.815    0.000 utils.py:13(orjson_dumps)
       23[67](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:67)02    0.075    0.000    0.104    0.000 typing.py:329(__hash__)
            1    0.071    0.071    3.605    3.605 test_dtos_perf.py:42(construct)
            1    0.063    0.063   21.671   21.671 test_dtos_perf.py:37(serialize)
       118351    0.059    0.000    0.083    0.000 typing.py:720(__hash__)
       355053    0.052    0.000    0.052    0.000 {built-in method builtins.hash}
       236[70](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:70)2    0.051    0.000    0.051    0.000 {method 'rpartition' of 'str' objects}
       11[83](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:83)51    0.047    0.000    0.047    0.000 {method 'decode' of 'bytes' objects}
       236702    0.027    0.000    0.027    0.000 {built-in method builtins.isinstance}
       118351    0.019    0.000    0.019    0.000 {built-in method builtins.len}
       118351    0.016    0.000    0.016    0.000 typing.py:1149(cast)
       118351    0.012    0.000    0.012    0.000 {method 'append' of 'list' objects}
            1    0.000    0.000    0.000    0.000 cProfile.py:133(__exit__)
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
    
    help wanted 
    opened by AndrewKostousov 2
Releases(v0.7.1)
  • v0.7.1(Feb 25, 2022)

    • Speed up VektonnBaseModel.json() for Vector model (see #3)

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.7.0...v0.7.1

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Feb 25, 2022)

    • Allow to specify request timeouts
    • Introduce retrieveVectors parameter to speed things up when there is no need in nearest vectors themselves

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jan 19, 2022)

    What's Changed

    • Remove 'Dto' suffix form DTOs' names by @streamoverflow in https://github.com/vektonn/vektonn-client-python/pull/2

    New Contributors

    • @streamoverflow made their first contribution in https://github.com/vektonn/vektonn-client-python/pull/2

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.5.4...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.4(Nov 23, 2021)

  • v0.5.3(Nov 23, 2021)

  • v0.5.2(Nov 23, 2021)

  • v0.5.1(Nov 23, 2021)

    • Support attribute values with floating-point numeric data type

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.5.0...v0.5.1

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Nov 23, 2021)

Owner
Vektonn
An open source vector search solution
Vektonn
Drcom-pt-client - Drcom Pt version client with refresh timer

drcom-pt-client Drcom Pt version client with refresh timer Dr.com Pt版本客户端 可用于网页认

null 4 Nov 16, 2022
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

MonkeyLearn 157 Nov 22, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

??️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
🐍 The official Python client library for Google's discovery based APIs.

Google API Client This is the Python client library for Google's discovery based APIs. To get started, please see the docs folder. These client librar

Google APIs 6.2k Jan 8, 2023
Python client for Arista eAPI

Arista eAPI Python Library The Python library for Arista's eAPI command API implementation provides a client API work using eAPI and communicating wit

Arista Networks EOS+ 124 Nov 23, 2022
Python API Client for Close

Close API A convenient Python wrapper for the Close API. API docs: http://developer.close.com Support: [email protected] Installation pip install clos

Close 56 Nov 30, 2022
Python client for CoinPayments API

pyCoinPayments - Python API client for CoinPayments Updates This library has now been converted to work with python3 This is an unofficial client for

James 27 Sep 21, 2022
DEPRECATED - Official Python Client for the Discogs API

⚠️ DEPRECATED This repository is no longer maintained. You can still use a REST client like Requests or other third-party Python library to access the

Discogs 483 Dec 31, 2022
The Foursquare API client for Python

foursquare Python client for the foursquare API. Philosophy: Map foursquare's endpoints one-to-one Clean, simple, Pythonic calls Only handle raw data,

Mike Lewis 400 Dec 19, 2022
python3.5+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python

A python wrapper around HubSpot's APIs, for python 3.5+. Built initially around hapipy, but heavily modified. Check out the documentation here! (thank

Jacobi Petrucciani 140 Dec 21, 2022