From aabd56395ccf042d1aa9aa4fb758ded556b223f0 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 30 Oct 2023 12:11:11 -0700 Subject: [PATCH 1/2] Update the size parameter to be dimension --- README.md | 4 ++-- astrapy/db.py | 8 +++++--- scripts/astrapy_latest_interface.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0794fd02..8f46842e 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,9 @@ api_endpoint = f"https://{database_id}-{database_region}.{database_base_url}" astra_db = AstraDB(token=token, api_endpoint=api_endpoint) # Possible Operations -astra_db.create_collection(collection_name="collection_test_delete", size=5) +astra_db.create_collection(collection_name="collection_test_delete", dimension=5) astra_db.delete_collection(collection_name="collection_test_delete") -astra_db.create_collection(collection_name="collection_test", size=5) +astra_db.create_collection(collection_name="collection_test", dimension=5) # Collections astra_db_collection = AstraDBCollection( diff --git a/astrapy/db.py b/astrapy/db.py index db24c56e..8242f56f 100644 --- a/astrapy/db.py +++ b/astrapy/db.py @@ -347,9 +347,11 @@ def get_collections(self): return response - def create_collection(self, size=None, options={}, function="", collection_name=""): - if size and not options: - options = {"vector": {"size": size}} + def create_collection( + self, dimension=None, options={}, function="", collection_name="" + ): + if dimension and not options: + options = {"vector": {"dimension": dimension}} if function: options["vector"]["function"] = function if options: diff --git a/scripts/astrapy_latest_interface.py b/scripts/astrapy_latest_interface.py index 1f7724c2..6d9ff34e 100644 --- a/scripts/astrapy_latest_interface.py +++ b/scripts/astrapy_latest_interface.py @@ -43,9 +43,9 @@ astra_db = AstraDB(token=token, api_endpoint=api_endpoint) # Possible Operations -astra_db.create_collection(collection_name="collection_test_delete", size=5) +astra_db.create_collection(collection_name="collection_test_delete", dimension=5) astra_db.delete_collection(collection_name="collection_test_delete") -astra_db.create_collection(collection_name="collection_test", size=5) +astra_db.create_collection(collection_name="collection_test", dimension=5) # Collections astra_db_collection = AstraDBCollection( From 0e3399aea850372e09e3f351ff2c96bf157d92a6 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 30 Oct 2023 12:13:44 -0700 Subject: [PATCH 2/2] Update tests to use proper dimension --- tests/astrapy/test_db.py | 4 ++-- tests/astrapy/test_pagination.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/astrapy/test_db.py b/tests/astrapy/test_db.py index f7418413..3d58089b 100644 --- a/tests/astrapy/test_db.py +++ b/tests/astrapy/test_db.py @@ -75,7 +75,7 @@ def cliff_data(cliff_uuid): @pytest.fixture(scope="module") def collection(db, cliff_data): - db.create_collection(collection_name=TEST_FIXTURE_COLLECTION_NAME, size=5) + db.create_collection(collection_name=TEST_FIXTURE_COLLECTION_NAME, dimension=5) collection = db.collection(collection_name=TEST_FIXTURE_COLLECTION_NAME) collection.insert_one(document=cliff_data) @@ -87,7 +87,7 @@ def collection(db, cliff_data): @pytest.mark.describe("should create a vector collection") def test_create_collection(db): - res = db.create_collection(collection_name=TEST_COLLECTION_NAME, size=5) + res = db.create_collection(collection_name=TEST_COLLECTION_NAME, dimension=5) print("CREATE", res) assert res is not None diff --git a/tests/astrapy/test_pagination.py b/tests/astrapy/test_pagination.py index 79cfa842..9f67f0ed 100644 --- a/tests/astrapy/test_pagination.py +++ b/tests/astrapy/test_pagination.py @@ -67,7 +67,7 @@ def test_collection(): api_endpoint=f"https://{ASTRA_DB_ID}-{ASTRA_DB_REGION}.{ASTRA_DB_BASE_URL}", namespace=ASTRA_DB_KEYSPACE, ) - res = astra_db.create_collection(collection_name=TEST_COLLECTION_NAME, size=2) + res = astra_db.create_collection(collection_name=TEST_COLLECTION_NAME, dimension=2) astra_db_collection = AstraDBCollection( collection_name=TEST_COLLECTION_NAME, token=ASTRA_DB_APPLICATION_TOKEN,