From a754c1b23d43aa80501a0947c76596d05602efc0 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Tue, 23 Jan 2024 15:20:34 -0800 Subject: [PATCH] chore: update example snippets for mvi count items (#429) * chore: bump momento dependency in examples * chore: update examples for mvi count items --- examples/poetry.lock | 18 +++++++++--------- examples/py310/doc-examples-python-apis.py | 14 ++++++++++++++ examples/pyproject.toml | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/examples/poetry.lock b/examples/poetry.lock index 71cd235b..a8a26104 100644 --- a/examples/poetry.lock +++ b/examples/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "colorama" @@ -193,30 +193,30 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", [[package]] name = "momento" -version = "1.15.1" +version = "1.17.0" description = "SDK for Momento" optional = false python-versions = ">=3.7,<4.0" files = [ - {file = "momento-1.15.1-py3-none-any.whl", hash = "sha256:7781d6da52364a6d3a3f6dae78eae5a6e118373ad027e810f4cf320631ae5bdc"}, - {file = "momento-1.15.1.tar.gz", hash = "sha256:f676a04597934b3138cb8f59a4053be25d13b91e475b648fb7c5a8c3555bb8a9"}, + {file = "momento-1.17.0-py3-none-any.whl", hash = "sha256:02fb1818f2af9cd4d5690b7825eb00ff43410e1b2e6e06f6352818e15d1164b7"}, + {file = "momento-1.17.0.tar.gz", hash = "sha256:f655f9452cb5af6c50a0abdbc87004b638013295bdaa7cff61cfeba5f7d2834b"}, ] [package.dependencies] grpcio = ">=1.46.0,<2.0.0" importlib-metadata = {version = ">=4", markers = "python_version < \"3.8\""} -momento-wire-types = ">=0.97.1,<0.98.0" +momento-wire-types = ">=0.102.1,<0.103.0" pyjwt = ">=2.4.0,<3.0.0" [[package]] name = "momento-wire-types" -version = "0.97.1" +version = "0.102.2" description = "Momento Client Proto Generated Files" optional = false python-versions = ">=3.7,<4.0" files = [ - {file = "momento_wire_types-0.97.1-py3-none-any.whl", hash = "sha256:de56563db12e53c6511927e1b1277e1a6c53c64d3fe89402d81e373f16bd291f"}, - {file = "momento_wire_types-0.97.1.tar.gz", hash = "sha256:b02e9d41072919432ba94e4123903208a87b6223f459d2cc47157bcc8e891b92"}, + {file = "momento_wire_types-0.102.2-py3-none-any.whl", hash = "sha256:93970f991511b63bf623ebcbe7745b8deea21e5662079d0852a8e9cecfb60c13"}, + {file = "momento_wire_types-0.102.2.tar.gz", hash = "sha256:9f0cbef1fa67527d689d0e489ab8e27a8e85e7b9ed779b1b9ff7487a1764a71a"}, ] [package.dependencies] @@ -446,4 +446,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.7,<3.12" -content-hash = "ea5dce3973c78ec9b85d887fc9780d62a95dc6539f735f35763e63f2761818f4" +content-hash = "b989712be113a77e021597724b0f3d476b4d0e44aaa035fa0ca62cd33737d504" diff --git a/examples/py310/doc-examples-python-apis.py b/examples/py310/doc-examples-python-apis.py index c457dedb..4c3a5aaa 100644 --- a/examples/py310/doc-examples-python-apis.py +++ b/examples/py310/doc-examples-python-apis.py @@ -23,6 +23,7 @@ TopicSubscriptionItem, ) from momento.responses.vector_index import ( + CountItems, CreateIndex, DeleteIndex, DeleteItemBatch, @@ -228,6 +229,18 @@ async def example_API_DeleteIndex(vector_client: PreviewVectorIndexClientAsync): # end example +async def example_API_CountItems(vector_client: PreviewVectorIndexClientAsync): + response = await vector_client.count_items("test-index") + match response: + case CountItems.Success() as success: + print(f"Found {success.item_count} items") + case CountItems.Error() as error: + print(f"Error counting items in index 'test-index': {error.message}") + + +# end example + + async def example_API_UpsertItemBatch(vector_client: PreviewVectorIndexClientAsync): response = await vector_client.upsert_item_batch( "test-index", @@ -343,6 +356,7 @@ async def main(): await example_API_InstantiateVectorClient() await example_API_CreateIndex(vector_client) await example_API_ListIndexes(vector_client) + await example_API_CountItems(vector_client) await example_API_UpsertItemBatch(vector_client) await example_API_GetItemBatch(vector_client) await example_API_GetItemMetadataBatch(vector_client) diff --git a/examples/pyproject.toml b/examples/pyproject.toml index 803dce2f..82624eff 100644 --- a/examples/pyproject.toml +++ b/examples/pyproject.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" [tool.poetry.dependencies] python = ">=3.7,<3.12" -momento = "1.15.1" +momento = "1.17.0" colorlog = "6.7.0" hdrhistogram = "^0.10.1"