Skip to content

Commit cf65025

Browse files
authored
Merge branch 'main' into feat-verify-certs
2 parents cbaa06a + 11dfee0 commit cf65025

24 files changed

Lines changed: 192 additions & 102 deletions

.github/workflows/codecov_aggregator.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
secrets:
3333
ASTRA_DB_APPLICATION_TOKEN: ${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}
3434
ASTRA_DB_API_ENDPOINT: ${{ secrets.ASTRA_DB_API_ENDPOINT }}
35-
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
35+
HEADER_EMBEDDING_API_KEY_VOYAGEAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_VOYAGEAI }}
3636

3737
local_it:
3838
uses: ./.github/workflows/local.yml
@@ -46,7 +46,7 @@ jobs:
4646
AWS_ECR_ROLE_NAME: ${{ secrets.AWS_ECR_ROLE_NAME }}
4747
AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }}
4848
AWS_ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}
49-
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
49+
HEADER_EMBEDDING_API_KEY_VOYAGEAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_VOYAGEAI }}
5050
# hardcoding the target DB
5151
DOCKER_COMPOSE_LOCAL_DATA_API: "yes"
5252
# turn on header-based reranker auth

.github/workflows/local.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222
required: true
2323
AWS_ECR_REGISTRY:
2424
required: true
25-
HEADER_EMBEDDING_API_KEY_OPENAI:
25+
HEADER_EMBEDDING_API_KEY_VOYAGEAI:
2626
required: true
2727
DOCKER_COMPOSE_LOCAL_DATA_API:
2828
required: true
@@ -41,7 +41,7 @@ jobs:
4141
AWS_ECR_ROLE_NAME: ${{ secrets.AWS_ECR_ROLE_NAME }}
4242
AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }}
4343
AWS_ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}
44-
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
44+
HEADER_EMBEDDING_API_KEY_VOYAGEAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_VOYAGEAI }}
4545
DOCKER_COMPOSE_LOCAL_DATA_API: ${{ secrets.DOCKER_COMPOSE_LOCAL_DATA_API }}
4646
HEADER_RERANKING_API_KEY_NVIDIA: ${{ secrets.HEADER_RERANKING_API_KEY_NVIDIA }}
4747
runs-on: ubuntu-latest

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ on:
1616
required: true
1717
ASTRA_DB_API_ENDPOINT:
1818
required: true
19-
HEADER_EMBEDDING_API_KEY_OPENAI:
19+
HEADER_EMBEDDING_API_KEY_VOYAGEAI:
2020
required: true
2121

2222
jobs:
2323
test:
2424
env:
2525
ASTRA_DB_APPLICATION_TOKEN: ${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}
2626
ASTRA_DB_API_ENDPOINT: ${{ secrets.ASTRA_DB_API_ENDPOINT }}
27-
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
27+
HEADER_EMBEDDING_API_KEY_VOYAGEAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_VOYAGEAI }}
2828
LEGACY_INSERTMANY_BEHAVIOUR_PRE2193: ${{ secrets.LEGACY_INSERTMANY_BEHAVIOUR_PRE2193 }}
2929
runs-on: ubuntu-latest
3030

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
env:
125125
ASTRA_DB_APPLICATION_TOKEN: ${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}
126126
ASTRA_DB_API_ENDPOINT: ${{ secrets.ASTRA_DB_API_ENDPOINT }}
127-
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
127+
HEADER_EMBEDDING_API_KEY_VOYAGEAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_VOYAGEAI }}
128128
LEGACY_INSERTMANY_BEHAVIOUR_PRE2193: ${{ secrets.LEGACY_INSERTMANY_BEHAVIOUR_PRE2193 }}
129129
run: make test-integration
130130

DEVELOPING.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ Note that the variables defined in the desired "base" template **must** be set t
6969

7070
Additionally, you will need to define the environment variables in `tests/env_templates/env.vectorize-minimal.template`,
7171
which are needed by the minimal set of "vectorize" testing belonging to the "base" test group.
72+
These rely on a single embedding provider and model
73+
(the one configured in `embedding_provider_switcher.py`, to match variables in the env template).
7274

7375
For Astra DB, you can include "shared secret" vectorize tests (i.e. KMS-based authentication).
74-
To run those tests, you must scope an OpenAI API key
75-
to the target Astra DB with secret name `"SHARED_SECRET_EMBEDDING_API_KEY_OPENAI"`
76+
To run those tests, you must scope an embedding provider API key
77+
to the target Astra DB with secret name matching the name set in
78+
the provider-switcher (e.g. `"SHARED_SECRET_EMBEDDING_API_KEY_VOYAGEAI"`).
7679
and comment the environment flag that suppresses them (see the base Astra env template).
7780

7881
For non-Astra, the reranking-related tests run only if one sets

tests/base/conftest.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
ADMIN_ENV_LIST,
4545
ADMIN_ENV_VARIABLE_MAP,
4646
CQL_AVAILABLE,
47-
HEADER_EMBEDDING_API_KEY_OPENAI,
47+
EMBEDDING_PROVIDER_API_KEY,
48+
EMBEDDING_PROVIDER_DIMENSION,
49+
EMBEDDING_PROVIDER_MODEL_NAME,
50+
EMBEDDING_PROVIDER_NAME,
51+
EMBEDDING_PROVIDER_SHARED_SECRET_KEY_NAME,
4852
HEADER_RERANKING_API_KEY_NVIDIA,
4953
IS_ASTRA_DB,
5054
RUN_SHARED_SECRET_VECTORIZE_TESTS,
@@ -227,10 +231,10 @@ def async_empty_collection(
227231
@pytest.fixture(scope="session")
228232
def service_collection_parameters() -> Iterable[dict[str, Any]]:
229233
yield {
230-
"dimension": 1536,
231-
"provider": "openai",
232-
"modelName": "text-embedding-ada-002",
233-
"api_key": HEADER_EMBEDDING_API_KEY_OPENAI,
234+
"dimension": EMBEDDING_PROVIDER_DIMENSION,
235+
"provider": EMBEDDING_PROVIDER_NAME,
236+
"modelName": EMBEDDING_PROVIDER_MODEL_NAME,
237+
"api_key": EMBEDDING_PROVIDER_API_KEY,
234238
"reranking_api_key": HEADER_RERANKING_API_KEY_NVIDIA,
235239
}
236240

@@ -996,7 +1000,11 @@ def async_empty_table_logicalfiltering(
9961000
"clean_nulls_from_dict",
9971001
"is_future_version",
9981002
"sync_fail_if_not_removed",
999-
"HEADER_EMBEDDING_API_KEY_OPENAI",
1003+
"EMBEDDING_PROVIDER_NAME",
1004+
"EMBEDDING_PROVIDER_MODEL_NAME",
1005+
"EMBEDDING_PROVIDER_API_KEY",
1006+
"EMBEDDING_PROVIDER_DIMENSION",
1007+
"EMBEDDING_PROVIDER_SHARED_SECRET_KEY_NAME",
10001008
"IS_ASTRA_DB",
10011009
"ADMIN_ENV_LIST",
10021010
"ADMIN_ENV_VARIABLE_MAP",

tests/base/integration/collections/test_collection_cursor_async.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626

2727
from ..conftest import DefaultAsyncCollection
2828

29-
NUM_DOCS = 25 # keep this between 20 and 39
30-
NUM_DOCS_PAGINATION = 90 # keep this above 2 * (2 * 20) and below 2 * (3 * 20)
29+
PAGE_SIZE = 20 # TODO: set to 50, default as per Data API config after PR 2461
30+
NUM_DOCS = 2 * PAGE_SIZE + 5
31+
NUM_DOCS_PAGINATION = 2 * (2 * PAGE_SIZE) + 5
3132

3233

3334
@pytest.fixture
@@ -161,16 +162,16 @@ async def test_collection_cursors_started_properties_async(
161162
await cur.__anext__()
162163
# now this has 19 items in buffer, one is consumed
163164
assert cur.consumed == 1
164-
assert cur.buffered_count == 19
165+
assert cur.buffered_count == PAGE_SIZE - 1
165166
assert len(cur.consume_buffer(3)) == 3
166167
assert cur.consumed == 4
167-
assert cur.buffered_count == 16
168+
assert cur.buffered_count == PAGE_SIZE - 4
168169
# from time to time the buffer is empty:
169-
for _ in range(16):
170+
for _ in range(PAGE_SIZE - 4):
170171
await cur.__anext__()
171172
assert cur.buffered_count == 0
172173
assert cur.consume_buffer(3) == []
173-
assert cur.consumed == 20
174+
assert cur.consumed == PAGE_SIZE
174175
assert cur.buffered_count == 0
175176

176177
with pytest.raises(CursorException):
@@ -213,12 +214,12 @@ async def test_collection_cursors_has_next_async(
213214
assert curmf.has_next()
214215
assert curmf.consumed == 2
215216
assert curmf.state == CursorState.STARTED
216-
for _ in range(18):
217+
for _ in range(PAGE_SIZE - 2):
217218
await curmf.__anext__()
218219
assert await curmf.has_next()
219-
assert curmf.consumed == 20
220+
assert curmf.consumed == PAGE_SIZE
220221
assert curmf.state == CursorState.STARTED
221-
assert curmf.buffered_count == NUM_DOCS - 20
222+
assert curmf.buffered_count == PAGE_SIZE
222223

223224
cur0 = async_filled_collection.find()
224225
cur0.close()
@@ -494,11 +495,9 @@ async def test_collection_cursors_initialpagestate_async(
494495
self,
495496
async_filled_pagination_collection: DefaultAsyncCollection,
496497
) -> None:
497-
page_size = 20
498-
499498
cur0 = async_filled_pagination_collection.find(filter={"even": True})
500499
ids0: list[int] = []
501-
for _ in range(page_size):
500+
for _ in range(PAGE_SIZE):
502501
doc = await cur0.__anext__()
503502
ids0.append(doc["_id"])
504503
nps0 = cur0._next_page_state
@@ -509,7 +508,7 @@ async def test_collection_cursors_initialpagestate_async(
509508
initial_page_state=nps0,
510509
)
511510
ids1: list[int] = []
512-
for _ in range(page_size):
511+
for _ in range(PAGE_SIZE):
513512
doc = await cur1.__anext__()
514513
ids1.append(doc["_id"])
515514
nps1 = cur1._next_page_state

tests/base/integration/collections/test_collection_cursor_sync.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626

2727
from ..conftest import DefaultCollection
2828

29-
NUM_DOCS = 25 # keep this between 20 and 39
30-
NUM_DOCS_PAGINATION = 90 # keep this above 2 * (2 * 20) and below 2 * (3 * 20)
29+
PAGE_SIZE = 20 # TODO: set to 50, default as per Data API config after PR 2461
30+
NUM_DOCS = 2 * PAGE_SIZE + 5
31+
NUM_DOCS_PAGINATION = 2 * (2 * PAGE_SIZE) + 5
3132

3233

3334
@pytest.fixture
@@ -159,16 +160,16 @@ def test_collection_cursors_started_properties_sync(
159160
next(cur)
160161
# now this has 19 items in buffer, one is consumed
161162
assert cur.consumed == 1
162-
assert cur.buffered_count == 19
163+
assert cur.buffered_count == PAGE_SIZE - 1
163164
assert len(cur.consume_buffer(3)) == 3
164165
assert cur.consumed == 4
165-
assert cur.buffered_count == 16
166+
assert cur.buffered_count == PAGE_SIZE - 4
166167
# from time to time the buffer is empty:
167-
for _ in range(16):
168+
for _ in range(PAGE_SIZE - 4):
168169
next(cur)
169170
assert cur.buffered_count == 0
170171
assert cur.consume_buffer(3) == []
171-
assert cur.consumed == 20
172+
assert cur.consumed == PAGE_SIZE
172173
assert cur.buffered_count == 0
173174

174175
with pytest.raises(CursorException):
@@ -211,12 +212,12 @@ def test_collection_cursors_has_next_sync(
211212
assert curmf.has_next()
212213
assert curmf.consumed == 2
213214
assert curmf.state == CursorState.STARTED
214-
for _ in range(18):
215+
for _ in range(PAGE_SIZE - 2):
215216
next(curmf)
216217
assert curmf.has_next()
217-
assert curmf.consumed == 20
218+
assert curmf.consumed == PAGE_SIZE
218219
assert curmf.state == CursorState.STARTED
219-
assert curmf.buffered_count == NUM_DOCS - 20
220+
assert curmf.buffered_count == PAGE_SIZE
220221

221222
cur0 = filled_collection.find()
222223
cur0.close()
@@ -417,26 +418,24 @@ def test_collection_cursors_initialpagestate_sync(
417418
self,
418419
filled_pagination_collection: DefaultCollection,
419420
) -> None:
420-
page_size = 20
421-
422421
cur0 = filled_pagination_collection.find(filter={"even": True})
423-
ids0 = [doc["_id"] for _, doc in zip(range(page_size), cur0)]
422+
ids0 = [doc["_id"] for _, doc in zip(range(PAGE_SIZE), cur0)]
424423
nps0 = cur0._next_page_state
425424
assert isinstance(nps0, str)
426425

427426
cur1 = filled_pagination_collection.find(
428427
filter={"even": True},
429428
initial_page_state=nps0,
430429
)
431-
ids1 = [doc["_id"] for _, doc in zip(range(page_size), cur1)]
430+
ids1 = [doc["_id"] for _, doc in zip(range(PAGE_SIZE), cur1)]
432431
nps1 = cur1._next_page_state
433432
assert isinstance(nps1, str)
434433

435434
cur2 = filled_pagination_collection.find(
436435
filter={"even": True},
437436
initial_page_state=nps1,
438437
)
439-
ids2 = [doc["_id"] for _, doc in zip(range(page_size), cur2)]
438+
ids2 = [doc["_id"] for doc in cur2]
440439
assert cur2._next_page_state is None
441440

442441
expected_ids = [i for i in range(NUM_DOCS_PAGINATION) if i % 2 == 0]

tests/base/integration/collections/test_collection_vectorize_methods_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
from astrapy.info import CollectionDefinition
2727

2828
from ..conftest import (
29-
HEADER_EMBEDDING_API_KEY_OPENAI,
29+
EMBEDDING_PROVIDER_API_KEY,
3030
DefaultAsyncCollection,
3131
)
3232

3333

3434
@pytest.mark.skipif(
35-
HEADER_EMBEDDING_API_KEY_OPENAI is None,
36-
reason="No HEADER_EMBEDDING_API_KEY_OPENAI credential",
35+
EMBEDDING_PROVIDER_API_KEY is None,
36+
reason="No embedding API Key credential",
3737
)
3838
class TestCollectionVectorizeMethodsAsync:
3939
@pytest.mark.describe("test of vectorize in collection methods, async")

tests/base/integration/collections/test_collection_vectorize_methods_sync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
from astrapy.info import CollectionDefinition
2525

2626
from ..conftest import (
27-
HEADER_EMBEDDING_API_KEY_OPENAI,
27+
EMBEDDING_PROVIDER_API_KEY,
2828
DefaultCollection,
2929
)
3030

3131

3232
@pytest.mark.skipif(
33-
HEADER_EMBEDDING_API_KEY_OPENAI is None,
34-
reason="No HEADER_EMBEDDING_API_KEY_OPENAI credential",
33+
EMBEDDING_PROVIDER_API_KEY is None,
34+
reason="No embedding API Key credential",
3535
)
3636
class TestCollectionVectorizeMethodsSync:
3737
@pytest.mark.describe("test of vectorize in collection methods, sync")

0 commit comments

Comments
 (0)