Skip to content

Commit

Permalink
Merge pull request #618 from vespa-engine/jobergum/infer_schema_name
Browse files Browse the repository at this point in the history
Jobergum/infer schema name
  • Loading branch information
kkraune committed Nov 8, 2023
2 parents 3312a96 + 5784509 commit 86d4ffe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions docs/sphinx/source/examples/pyvespa-examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,15 @@
"id": "bb5d4d60",
"metadata": {},
"source": [
"Observe the documents now have _two_ vectors:"
"Observe the documents now have _two_ vectors\n",
"\n",
"Notice that we pass [native Vespa document v1 api parameters](https://docs.vespa.ai/en/reference/document-v1-api-reference.html) \n",
"to reduce the tensor verbosity."
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 24,
"id": "b0c25956",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -547,13 +550,13 @@
],
"source": [
"from vespa.io import VespaResponse\n",
"response:VespaResponse = app.get_data(data_id=0, schema=\"neighbors\", **{\"format.tensors\": \"short-value\"})\n",
"response:VespaResponse = app.get_data(data_id=0, **{\"format.tensors\": \"short-value\"})\n",
"print(json.dumps(response.get_json(), indent=4))"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 25,
"id": "14befa36",
"metadata": {},
"outputs": [
Expand Down
8 changes: 6 additions & 2 deletions vespa/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,21 @@ def delete_all_docs(
)

def get_data(
self, schema: str, data_id: str, namespace: str = None, **kwargs
self, data_id: str, schema: Optional[str]=None, namespace: str = None, **kwargs
) -> VespaResponse:
"""
Get a data point from a Vespa app.
:param schema: The schema that we are getting data from.
:param data_id: Unique id associated with this data point.
:param schema: The schema that we are getting data from. Will attempt to infer schema name if not provided.
:param namespace: The namespace that we are getting data from. If no namespace is provided the schema is used.
:param kwargs: Additional arguments to be passed to the HTTP GET request https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters
:return: Response of the HTTP GET request.
"""

if not schema:
schema = self._infer_schema_name()

if not namespace:
namespace = schema

Expand Down

0 comments on commit 86d4ffe

Please sign in to comment.