Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the size parameter to be dimension #70

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading