Skip to content

Commit

Permalink
Make internal func names more explicit about http op vs vespa op
Browse files Browse the repository at this point in the history
  • Loading branch information
codycollier committed Jan 4, 2024
1 parent d8bb27b commit f3dabc4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions venra/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _api_err_check(response):
raise exceptions.VespaRequestError(err)


def _vespa_get(namespace, doctype, docid, fieldset="all"):
def _vespa_http_get(namespace, doctype, docid, fieldset="all"):
"""Internal wrapper for document api and http get handling"""
base_uri = f"{config.vespa_host_app}/document/v1/{namespace}/{doctype}/docid/{docid}?fieldSet=[{fieldset}]"
vc = client.get_vespa_client()
Expand All @@ -49,7 +49,7 @@ def _vespa_get(namespace, doctype, docid, fieldset="all"):
return vr


def _vespa_post(namespace, doctype, docid, doc):
def _vespa_http_post(namespace, doctype, docid, doc):
"""Internal wrapper for document api and http post handling"""
base_uri = f"{config.vespa_host_app}/document/v1/{namespace}/{doctype}/docid/{docid}"
vc = client.get_vespa_client()
Expand All @@ -58,7 +58,7 @@ def _vespa_post(namespace, doctype, docid, doc):
return


def _vespa_put(namespace, doctype, docid, update):
def _vespa_http_put(namespace, doctype, docid, update):
"""Internal wrapper for document api and http put handling"""
base_uri = f"{config.vespa_host_app}/document/v1/{namespace}/{doctype}/docid/{docid}"
vc = client.get_vespa_client()
Expand All @@ -67,7 +67,7 @@ def _vespa_put(namespace, doctype, docid, update):
return


def _vespa_delete(namespace, doctype, docid):
def _vespa_http_delete(namespace, doctype, docid):
"""Internal wrapper for document api and http delete handling"""
base_uri = f"{config.vespa_host_app}/document/v1/{namespace}/{doctype}/docid/{docid}"
vc = client.get_vespa_client()
Expand All @@ -78,7 +78,7 @@ def _vespa_delete(namespace, doctype, docid):

def get(namespace, doctype, docid, fieldset="all", fields_only=True):
"""Retrieve and return a document"""
doc = _vespa_get(namespace, doctype, docid, fieldset)
doc = _vespa_http_get(namespace, doctype, docid, fieldset)
if fields_only:
doc = doc["fields"]
return doc
Expand All @@ -87,7 +87,7 @@ def get(namespace, doctype, docid, fieldset="all", fields_only=True):
def put(namespace, doctype, docid, doc):
"""Add or update a whole document"""
doc_fields = {"fields": doc}
_vespa_post(namespace, doctype, docid, doc_fields)
_vespa_http_post(namespace, doctype, docid, doc_fields)
return True


Expand All @@ -111,13 +111,13 @@ def update(namespace, doctype, docid, operations):
partial_update = {"fields": {}}
for operation, field_name, field_value in operations:
partial_update["fields"][field_name] = {operation: field_value}
_vespa_put(namespace, doctype, docid, partial_update)
_vespa_http_put(namespace, doctype, docid, partial_update)
return True


def remove(namespace, doctype, docid):
"""Delete a document"""
_vespa_delete(namespace, doctype, docid)
_vespa_http_delete(namespace, doctype, docid)
return True


4 changes: 2 additions & 2 deletions venra/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _api_err_check(response):
raise exceptions.VespaRequestError(err)


def _vespa_post(qdata):
def _vespa_http_post(qdata):
"""Internal wrapper for search api http call handling"""
base_uri = f"{config.vespa_host_app}/search/"
vc = client.get_vespa_client()
Expand All @@ -50,7 +50,7 @@ def search(qdata):
The return val is the complete query response json loaded as a dictionary
"""
qstarted = time.time()
qresults = _vespa_post(qdata)
qresults = _vespa_http_post(qdata)
qstopped = time.time()
elapsed = qstopped - qstarted
qresults["venra"] = {"elapsed_ms": elapsed}
Expand Down
6 changes: 3 additions & 3 deletions venra/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _api_err_check(response):
raise exceptions.VespaRequestError(err)


def _vespa_get(full_uri):
def _vespa_http_get(full_uri):
"""Internal wrapper for system api http call handling"""
vc = client.get_vespa_client()
vr = vc.get(f"{full_uri}")
Expand All @@ -54,7 +54,7 @@ def version_app():
"version": "8.13.21"
}
"""
vr = _vespa_get(f"{config.vespa_host_app}/state/v1/version")
vr = _vespa_http_get(f"{config.vespa_host_app}/state/v1/version")
return vr["version"]


Expand All @@ -67,7 +67,7 @@ def version_cfg():
"version": "8.13.21"
}
"""
vr = _vespa_get(f"{config.vespa_host_cfg}/state/v1/version")
vr = _vespa_http_get(f"{config.vespa_host_cfg}/state/v1/version")
return vr["version"]


6 changes: 3 additions & 3 deletions venra/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _api_err_check(response):
raise exceptions.VespaRequestError(err)


def _vespa_get(namespace, doctype, selection=None, continuation=None):
def _vespa_http_get(namespace, doctype, selection=None, continuation=None):
"""Internal wrapper for visit api http call handling"""
base_uri = f"{config.vespa_host_app}/document/v1/{namespace}/{doctype}/docid"

Expand Down Expand Up @@ -54,7 +54,7 @@ def feed(namespace, doctype, selection=None, fields_only=True):
"""

# initial call
vr = _vespa_get(namespace, doctype, selection, None)
vr = _vespa_http_get(namespace, doctype, selection, None)

# page through results
while True:
Expand All @@ -71,7 +71,7 @@ def feed(namespace, doctype, selection=None, fields_only=True):
break

# retrieve the next set of results
vr = _vespa_get(namespace, doctype, selection, continuation)
vr = _vespa_http_get(namespace, doctype, selection, continuation)

return

0 comments on commit f3dabc4

Please sign in to comment.