summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authortmartins <thigm85@gmail.com>2020-08-20 11:19:24 +0200
committertmartins <thigm85@gmail.com>2020-08-20 11:19:24 +0200
commitc95df5be4b49c9734a8b745974e5c864432e952e (patch)
tree73a7318d57e249db86268dd7606b83aefcb493ee /python
parentbd6580811a97f5aee746966dc0300478397dea65 (diff)
add method to feed a data point.
Diffstat (limited to 'python')
-rw-r--r--python/vespa/vespa/application.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/vespa/vespa/application.py b/python/vespa/vespa/application.py
index 3646cf87bf2..9dc5cd10d9a 100644
--- a/python/vespa/vespa/application.py
+++ b/python/vespa/vespa/application.py
@@ -3,6 +3,7 @@
from typing import Optional, Dict, Tuple, List
from requests import post
from pandas import DataFrame
+from requests import post
from vespa.query import Query, VespaResult
from vespa.evaluation import EvalMetric
@@ -76,6 +77,21 @@ class Vespa(object):
r = post(self.search_end_point, json=body)
return VespaResult(vespa_result=r.json())
+ def feed_data_point(self, schema: str, data_id: str, fields: Dict):
+ """
+ Feed a data point to a Vespa app.
+
+ :param schema: The schema that we are sending data to.
+ :param data_id: Unique id associated with this data point.
+ :param fields: Dict containing all the fields required by the `schema`.
+ :return: Response of the HTTP POST request.
+ """
+ end_point = "{}/document/v1/{}/{}/docid/{}".format(
+ self.end_point, schema, schema, str(data_id)
+ )
+ response = post(end_point, json=fields)
+ return response
+
def collect_training_data_point(
self,
query: str,