Skip to main content

Venra provides a simple, high-level api for vespa.ai.

Project description

venra

Project Status: WIP Tests Release PyPI version

Venra provides a simple, high-level api for vespa.ai.

Venra targets subsets of Vespa's query, document, and system apis. It aims to encapsulate the complexity of dealing with the Vespa http interfaces, response behaviors, and json responses for common client tasks.

Venra is well suited for web backends, command line tools, and enrichment programs which need to retrieve, process, and update documents.

import venra

qdata = {}
qdata["yql"] = "select * from sources awesome_docs;"
response = venra.query.search(qdata)

docs = venra.query.extract_docs(response)
for r, doc in enumerate(docs):
    print(f"rank: {r} >> {doc.some_id} title: {doc.title}")

Note: This library is under active development and the api is currently unstable.

Installation

$ pip install venra

Usage

Basic Query:

import venra

# Build query
qdata = {}
qdata["yql"] = "select * from sources baz;"

# Run query
response = venra.query.search(qdata)

# Extract results via helpers
metrics = venra.query.extract_metrics(response)
docs = venra.query.extract_docs(response)

User Query and Grouping:

from pprint import pprint

from venra import config as vconfig
from venra import query as vquery


# Configure
user_query = "machine learning"
vconfig.vespa_host_app = "http://localhost:8080"

# Build query including a grouping
qdata = {}
qdata["yql"] = "select post_id, post_date from sources baz where userQuery()"
qdata["yql"] += f" | all(group(time.date(post_date)) order(-max(post_date)) max(32) each(output(count())) as(day_counts) );"
qdata["hits"] = 10
qdata["timeout"] = "3300ms"
qdata["model.queryString"] = user_query
qdata["model.type"] = "weakAnd"
qdata["presentation.summary"] = "full"
qdata["presentation.timing"] = "true"

# Run query
response = vquery.search(qdata)

# Extract results via helpers
metrics = vquery.extract_metrics(response)
groups = vquery.extract_groups(response)
myfacet = vquery.extract_group_pairs(groups, "day_counts", "count()")
docs = vquery.extract_docs(response)

# Query results ready for use in app
pprint(metrics)
pprint(myfacet)
pprint(docs)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

venra-0.1.7.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

venra-0.1.7-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file venra-0.1.7.tar.gz.

File metadata

  • Download URL: venra-0.1.7.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for venra-0.1.7.tar.gz
Algorithm Hash digest
SHA256 63f76192b4f5299647f636c55f03d7d2a2a6db6a1f3a491b6aff2b60a5c63972
MD5 057c1b40a77ed9b3db8cc34632e3d19d
BLAKE2b-256 5bfaf501a1b188c728b726fdef458e8fd5dfb7121c99efcdb5b8cf680a5e3bb4

See more details on using hashes here.

File details

Details for the file venra-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: venra-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for venra-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a269d0cbee1b930a2e5f003e2330279e2ea2e0cc665ca65b2e8baa21f6d27242
MD5 3b57da0db2b38767deab6b1c5aa9744c
BLAKE2b-256 fb8c62c70b0b0d1cda831e61192725e19576d3340690531d4bd3c6e26e58ae8c

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