Skip to content

Commit

Permalink
chore: update example snippets for mvi count items (#429)
Browse files Browse the repository at this point in the history
* chore: bump momento dependency in examples

* chore: update examples for mvi count items
  • Loading branch information
malandis authored Jan 23, 2024
1 parent 5ba6988 commit a754c1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
18 changes: 9 additions & 9 deletions examples/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions examples/py310/doc-examples-python-apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
TopicSubscriptionItem,
)
from momento.responses.vector_index import (
CountItems,
CreateIndex,
DeleteIndex,
DeleteItemBatch,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a754c1b

Please sign in to comment.