diff --git a/docs/sphinx/source/examples/lightgbm-with-categorical-mapping.ipynb b/docs/sphinx/source/examples/lightgbm-with-categorical-mapping.ipynb index e65c39f9..d219c6ea 100644 --- a/docs/sphinx/source/examples/lightgbm-with-categorical-mapping.ipynb +++ b/docs/sphinx/source/examples/lightgbm-with-categorical-mapping.ipynb @@ -601,7 +601,7 @@ "from vespa.io import VespaResponse \n", "\n", "def callback(response:VespaResponse, id:str):\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(f\"Document {id} was not fed to Vespa due to error: {response.get_json()}\")\n", " \n", "app.feed_iterable(feed_batch, callback=callback)" diff --git a/docs/sphinx/source/examples/lightgbm-with-categorical.ipynb b/docs/sphinx/source/examples/lightgbm-with-categorical.ipynb index 3dd10839..ddde6209 100644 --- a/docs/sphinx/source/examples/lightgbm-with-categorical.ipynb +++ b/docs/sphinx/source/examples/lightgbm-with-categorical.ipynb @@ -570,7 +570,7 @@ "from vespa.io import VespaResponse \n", "\n", "def callback(response:VespaResponse, id:str):\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(f\"Document {id} was not fed to Vespa due to error: {response.get_json()}\")\n", " \n", "app.feed_iterable(feed_batch, callback=callback)" diff --git a/docs/sphinx/source/examples/multi-vector-indexing.ipynb b/docs/sphinx/source/examples/multi-vector-indexing.ipynb index e75edc40..9c46368a 100644 --- a/docs/sphinx/source/examples/multi-vector-indexing.ipynb +++ b/docs/sphinx/source/examples/multi-vector-indexing.ipynb @@ -525,7 +525,7 @@ " 'ranking.profile': 'unranked',\n", " 'hits': 2\n", "})\n", - "if not result.is_successfull():\n", + "if not result.is_successful():\n", " raise ValueError(result.get_json())\n", "if len(result.hits) != 2:\n", " raise ValueError(\"Expected 2 hits, got {}\".format(len(result.hits)))\n", diff --git a/docs/sphinx/source/examples/pyvespa-examples.ipynb b/docs/sphinx/source/examples/pyvespa-examples.ipynb index a866ce4b..f116d1d9 100644 --- a/docs/sphinx/source/examples/pyvespa-examples.ipynb +++ b/docs/sphinx/source/examples/pyvespa-examples.ipynb @@ -156,7 +156,7 @@ "with app.syncio(connections=1) as session:\n", " for u in get_feed(\"point\"):\n", " response:VespaResponse = session.update_data(data_id=u[\"id\"], schema=\"neighbors\", fields=u[\"fields\"], create=True)\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(\"Update failed for document {}\".format(u[\"id\"]) + \" with status code {}\".format(response.status_code) + \n", " \" with response {}\".format(response.get_json()))\n", " " @@ -235,7 +235,7 @@ " 'presentation.format.tensors': 'short-value'\n", "})\n", "\n", - "if not response.is_successfull():\n", + "if not response.is_successful():\n", " print(\"Query failed with status code {}\".format(response.status_code) + \n", " \" with response {}\".format(response.get_json()))\n", " raise Exception(\"Query failed\")\n", @@ -503,7 +503,7 @@ "source": [ "for u in get_feed(\"point_angular\"):\n", " response:VespaResponse = session.update_data(data_id=u[\"id\"], schema=\"neighbors\", fields=u[\"fields\"])\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(\"Update failed for document {}\".format(u[\"id\"]) + \" with status code {}\".format(response.status_code) + \n", " \" with response {}\".format(response.get_json()))" ] diff --git a/docs/sphinx/source/getting-started-pyvespa-cloud.ipynb b/docs/sphinx/source/getting-started-pyvespa-cloud.ipynb index 6b5d28bd..2a70704d 100644 --- a/docs/sphinx/source/getting-started-pyvespa-cloud.ipynb +++ b/docs/sphinx/source/getting-started-pyvespa-cloud.ipynb @@ -426,7 +426,7 @@ "from vespa.io import VespaResponse, VespaQueryResponse\n", "\n", "def callback(response:VespaResponse, id:str):\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(f\"Error when feeding document {id}: {response.get_json()}\")\n", "\n", "app.feed_iterable(vespa_feed, schema=\"doc\", namespace=\"tutorial\", callback=callback)" @@ -496,7 +496,7 @@ " query=query, \n", " ranking=\"bm25\"\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -528,7 +528,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -566,7 +566,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -599,7 +599,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -630,7 +630,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, diff --git a/docs/sphinx/source/getting-started-pyvespa.ipynb b/docs/sphinx/source/getting-started-pyvespa.ipynb index d713c0aa..26396799 100644 --- a/docs/sphinx/source/getting-started-pyvespa.ipynb +++ b/docs/sphinx/source/getting-started-pyvespa.ipynb @@ -219,7 +219,7 @@ "from vespa.io import VespaResponse, VespaQueryResponse\n", "\n", "def callback(response:VespaResponse, id:str):\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(f\"Error when feeding document {id}: {response.get_json()}\")\n", "\n", "app.feed_iterable(vespa_feed, schema=\"doc\", namespace=\"tutorial\", callback=callback)" @@ -283,7 +283,7 @@ " query=query, \n", " ranking=\"bm25\"\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -315,7 +315,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -354,7 +354,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -393,7 +393,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, @@ -424,7 +424,7 @@ " \"input.query(q)\": f\"embed({query})\"\n", " }\n", " )\n", - " assert(response.is_successfull())\n", + " assert(response.is_successful())\n", " print(display_hits_as_df(response, [\"id\", \"title\"]))" ] }, diff --git a/docs/sphinx/source/query.ipynb b/docs/sphinx/source/query.ipynb index fc43b16e..a91d6dc3 100644 --- a/docs/sphinx/source/query.ipynb +++ b/docs/sphinx/source/query.ipynb @@ -86,7 +86,7 @@ " hits=1, \n", " query=\"Is remdesivir an effective treatment for COVID-19?\", \n", " ranking=\"bm25\")\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " print(response.url)\n" ] }, @@ -115,7 +115,7 @@ " \"presentation.timing\": True\n", " }\n", " )\n", - " print(response.is_successfull())\n" + " print(response.is_successful())\n" ] }, { @@ -200,7 +200,7 @@ " \"presentation.timing\": True\n", " }\n", " )\n", - " print(response.is_successfull())" + " print(response.is_successful())" ] }, { @@ -231,7 +231,7 @@ " \"timeout\": \"1ms\"\n", " }\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " except VespaError as e:\n", " print(str(e))\n", " \n", @@ -258,7 +258,7 @@ " \"yql\": \"select * from sources * where userQuery()\"\n", " }\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " except VespaError as e:\n", " print(str(e))\n", " " diff --git a/docs/sphinx/source/reads-writes.ipynb b/docs/sphinx/source/reads-writes.ipynb index 0e7ce84a..55d8ec0c 100644 --- a/docs/sphinx/source/reads-writes.ipynb +++ b/docs/sphinx/source/reads-writes.ipynb @@ -229,7 +229,7 @@ "from vespa.io import VespaResponse\n", "\n", "def callback(response:VespaResponse, id:str):\n", - " if not response.is_successfull():\n", + " if not response.is_successful():\n", " print(f\"Failed to feed document {id} with status code {response.status_code}: Reason {response.get_json()}\")\n", " " ] @@ -499,7 +499,7 @@ " \"popularity\": 1.0,\n", " }\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " print(response.get_json())" ] }, @@ -524,7 +524,7 @@ " namespace=\"benchmark\",\n", " data_id=\"1\",\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " print(response.get_json())" ] }, @@ -554,7 +554,7 @@ " fields={ \"popularity\": 3.0 }, \n", " create=True\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " print(response.get_json())" ] }, @@ -571,7 +571,7 @@ " namespace=\"benchmark\",\n", " data_id=\"does-not-exist\",\n", " )\n", - " print(response.is_successfull())\n", + " print(response.is_successful())\n", " print(response.get_json())" ] }, diff --git a/vespa/io.py b/vespa/io.py index ece5bf7a..b4dc2fe2 100644 --- a/vespa/io.py +++ b/vespa/io.py @@ -1,3 +1,4 @@ +import warnings from typing import Optional, Dict, List class VespaResponse(object): @@ -25,6 +26,12 @@ def get_status_code(self) -> int: return self.status_code def is_successfull(self) -> bool: + """[Deprecated] Use is_successful() instead""" + warnings.warn("is_successfull is deprecated, use is_successful() instead.", + DeprecationWarning) + return self.status_code == 200 + + def is_successful(self) -> bool: """True if status code is 200.""" return self.status_code == 200 diff --git a/vespa/test_integration_docker.py b/vespa/test_integration_docker.py index 27124f3b..85182110 100644 --- a/vespa/test_integration_docker.py +++ b/vespa/test_integration_docker.py @@ -281,7 +281,7 @@ def execute_data_operations( response:VespaResponse = app.get_data(schema=schema_name, data_id=fields_to_send["id"]) self.assertEqual(response.status_code, 404) - self.assertFalse(response.is_successfull()) + self.assertFalse(response.is_successful()) # # Feed a data point @@ -355,7 +355,7 @@ def execute_data_operations( # # Deleted data should be gone response: VespaResponse = app.get_data(schema=schema_name, data_id=fields_to_send["id"]) - self.assertFalse(response.is_successfull()) + self.assertFalse(response.is_successful()) # # Update a non-existent data point @@ -411,7 +411,7 @@ def execute_data_operations( response.json["id"], "id:{}:{}::{}".format(schema_name, schema_name, fields_to_send["id"]), ) - self.assertTrue(response.is_successfull()) + self.assertTrue(response.is_successful()) self.assertTrue("trace" in response.json) async def execute_async_data_operations( @@ -484,7 +484,7 @@ async def execute_async_data_operations( schema=schema_name, data_id=fields_to_send[0]["id"], timeout=180 ) self.assertEqual(response.status_code, 200) - self.assertEqual(response.is_successfull(), True) + self.assertEqual(response.is_successful(), True) result = response.json self.assertDictEqual( result, @@ -583,7 +583,7 @@ async def execute_async_data_operations( ) for query in queries: self.assertEqual(query.result().status_code, 200) - self.assertEqual(query.result().is_successfull(), True) + self.assertEqual(query.result().is_successful(), True) def get_model_endpoints_when_no_model_is_available( @@ -870,17 +870,17 @@ def test_streaming(self): self.app.wait_for_application_up(300) def callback(response:VespaResponse, id:str): - if not response.is_successfull(): + if not response.is_successful(): print("Id " + id + " + failed : " + response.json) self.app.feed_iterable(docs, schema="mail", namespace="test", callback=callback) from vespa.io import VespaQueryResponse response:VespaQueryResponse = self.app.query(yql="select * from sources * where title contains 'title'", groupname="a@hotmail.com") - self.assertTrue(response.is_successfull()) + self.assertTrue(response.is_successful()) self.assertEqual(response.number_documents_retrieved, 1) response:VespaQueryResponse = self.app.query(yql="select * from sources * where title contains 'title'", groupname="b@hotmail.com") - self.assertTrue(response.is_successfull()) + self.assertTrue(response.is_successful()) self.assertEqual(response.number_documents_retrieved, 2) with pytest.raises(Exception): @@ -889,12 +889,12 @@ def callback(response:VespaResponse, id:str): self.app.delete_data(schema="mail", namespace="test", data_id=2, groupname="b@hotmail.com") response:VespaQueryResponse = self.app.query(yql="select * from sources * where title contains 'title'", groupname="b@hotmail.com") - self.assertTrue(response.is_successfull()) + self.assertTrue(response.is_successful()) self.assertEqual(response.number_documents_retrieved, 1) self.app.update_data(schema="mail", namespace="test", data_id=1, groupname="b@hotmail.com", fields={"title": "this is a new foo"}) response:VespaQueryResponse = self.app.query(yql="select * from sources * where title contains 'foo'", groupname="b@hotmail.com") - self.assertTrue(response.is_successfull()) + self.assertTrue(response.is_successful()) self.assertEqual(response.number_documents_retrieved, 1) response = self.app.get_data(schema="mail", namespace="test", data_id=1, groupname="b@hotmail.com") diff --git a/vespa/test_integration_vespa_cloud.py b/vespa/test_integration_vespa_cloud.py index b8474558..8115bc3d 100644 --- a/vespa/test_integration_vespa_cloud.py +++ b/vespa/test_integration_vespa_cloud.py @@ -65,7 +65,7 @@ def test_key_cert_arguments(self): }, self.app.get_data(schema="msmarco", data_id="1").json, ) - self.assertEqual(self.app.get_data(schema="msmarco", data_id="1").is_successfull(), False) + self.assertEqual(self.app.get_data(schema="msmarco", data_id="1").is_successful(), False) with pytest.raises(HTTPError): self.app.get_data(schema="msmarco", data_id="1", raise_on_not_found=True) diff --git a/vespa/test_integration_vespa_cloud_token.py b/vespa/test_integration_vespa_cloud_token.py index c9b5814f..f608e7d2 100644 --- a/vespa/test_integration_vespa_cloud_token.py +++ b/vespa/test_integration_vespa_cloud_token.py @@ -57,7 +57,7 @@ def test_right_endpoint_used_with_token(self): }, self.app.get_data(schema="msmarco", data_id="1").json, ) - self.assertEqual(self.app.get_data(schema="msmarco", data_id="1").is_successfull(), False) + self.assertEqual(self.app.get_data(schema="msmarco", data_id="1").is_successful(), False) with pytest.raises(HTTPError): self.app.get_data(schema="msmarco", data_id="1",raise_on_not_found=True) diff --git a/vespa/test_integration_vespa_cloud_vector_search.py b/vespa/test_integration_vespa_cloud_vector_search.py index 72725907..bcc4a62d 100644 --- a/vespa/test_integration_vespa_cloud_vector_search.py +++ b/vespa/test_integration_vespa_cloud_vector_search.py @@ -79,7 +79,7 @@ def callback(response:VespaResponse, id:str): nonlocal ok nonlocal start_time nonlocal callbacks - if response.is_successfull(): + if response.is_successful(): ok +=1 callbacks +=1