Skip to content

Commit

Permalink
Merge pull request #70 from datastax/feature/#69-rename-size-param
Browse files Browse the repository at this point in the history
Update the size parameter to be dimension
  • Loading branch information
erichare authored Oct 30, 2023
2 parents b5f7747 + 0e3399a commit 5bf400f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions astrapy/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/astrapy_latest_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/astrapy/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/astrapy/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5bf400f

Please sign in to comment.