Skip to content

Commit 996a198

Browse files
Bump to 2.1.0 + test improvements + better vectorize docstrings (#372)
* bring udt testing to main testing (data api merged udt to main) * lift the DESC-TYPES-based udt cql-driven tests on Astra * use cluster metadata in lieu of 'DESC TYPES', re-enable cql-udt testing in Astra * reinstate regular testing of findXproviders on Astra which now has full support for apiSupport * enable udt- and collection-columns- filtering tests for Astra as well * Positional param to init for AlterTableOperation subclasses; drop and drop vectorize also accept a single-string input * alter-table operation classes accept plain dicts as values in their 'columns' constructor input * changesfile * version bump to 2.1.0 * vectorize in db/collection docstrings * vectorize in db/table docstrings * type-check fixed for py 3.9 in table_altering * make type ok for python 3.8 in table_altering.py * unit test cover 3.13 * revert adding 3.13 to unit test versions / postponed * upgrade hcd and data-api in HCD docker compose * docker/podman adaptation; revert to hcd 1.2.1-early-preview for HCD testing * style --------- Co-authored-by: Stefano Lottini <[email protected]>
1 parent 524a56f commit 996a198

24 files changed

+499
-161
lines changed

CHANGES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
v 2.1.0
2+
=======
3+
Same as 2.1.0rc1
4+
15
v 2.1.0rc1
26
==========
7+
AlterTableOperation subclasses:
8+
- Added positional passing of parameter constructor
9+
- Accept single-string parameter for the drop-column and drop-vectorize cases
10+
- Add and AddVectorize constructors accept a 'columns' dict with dict values (now individually coerced)
311
Switch default encode_maps_as_lists_in_tables to "DATAAPIMAPS" (no observable changes w.r.t. previous releases)
412
Bugfix: fix paykload encoding for empty maps/DataAPIMaps
513
User-defined types in tables:
@@ -34,6 +42,8 @@ maintenance: improve integration test coverage for:
3442
- tables, lexical/BM25-related DML
3543
- tables, logical filtering (i.e. $and, $or between clauses)
3644
- multiple vectorize columns in a Table
45+
maintenance: replaced "DESC TYPES"-based cql-driven UDT testing into cluster-metadata-inspection-based equivalent (supported on Astra)
46+
maintenance: streamlined several integration tests into targeting Astra as the latest Data API deploy supports the corresponding features
3747
maintenance: subsumed the specific testing opt-in env. var 'ASTRAPY_TEST_MAP2TUPLES=y' into the catch-all 'cutting-edge main' `ASTRAPY_TEST_LATEST_MAIN=y`
3848
maintenance: simplified SerdesOptions management in unit testing; some rationalization/refactoring of pre- and post-processing logic for tables in unit tests
3949
maintenance: switched to uv (from poetry)

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ Depending on the test, different environment variables are needed: refer to
726726
the templates in `tests/env_templates`. The "basic" credentials (one of the three options)
727727
are always required, _even for unit testing_.
728728

729+
#### Docker vs. Podman
730+
731+
In case you use a different Docker-compatible container runtime, viz. `podman`, make sure to export
732+
the environment variable `DOCKER_COMMAND_NAME="podman"` to have the **DockerCompose** tests use it properly.
733+
729734
#### Multiple Python versions
730735

731736
If may be useful to run e.g. unit tests with multiple Python versions. You can have `uv`
@@ -737,7 +742,7 @@ uv venv --python 3.8 .venv-3.8
737742
uv sync --dev --active
738743
```
739744

740-
Then, with the desired virtual env active, you will simply run e.g. `uv run pytest [...]`.
745+
Then, with the desired virtual env active, you will run e.g. `uv run --active pytest [...]`.
741746

742747
Most make targets will also support running in the named virtual env:
743748
assuming you activated a certain virtual env, you can run e.g.: `make format VENV=true`.
@@ -806,11 +811,7 @@ certain environment variables, otherwise the associated tests are excluded from
806811
#### Cutting-edge features on `main`
807812

808813
Prepend tests with a `ASTRAPY_TEST_LATEST_MAIN=y` for features found on `main` that are not released anywhere.
809-
810-
#### testing UDT support
811-
812-
Prepend tests with a `ASTRAPY_TEST_UDT=y` to enable testing of Data API support for user-defined types (UDTs).
813-
These integration tests are off by default, pending release on all test target environments.
814+
_(Tip: run a code search first to see what is currently marked as such. Chances are nothing is.)_
814815

815816
## Appendices
816817

astrapy/data/collection.py

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Collection(Generic[DOC]):
152152
... "https://01234567-....apps.astra.datastax.com",
153153
... token="AstraCS:..."
154154
... )
155-
155+
>>>
156156
>>> # Create a collection using the fluent syntax for its definition
157157
>>> from astrapy.constants import VectorMetric
158158
>>> from astrapy.info import CollectionDefinition
@@ -168,7 +168,7 @@ class Collection(Generic[DOC]):
168168
... "my_events",
169169
... definition=collection_definition,
170170
... )
171-
171+
>>>
172172
>>>
173173
>>> # Create a collection with the definition as object
174174
>>> from astrapy.info import CollectionVectorOptions
@@ -185,7 +185,7 @@ class Collection(Generic[DOC]):
185185
... definition=collection_definition_1,
186186
... )
187187
>>>
188-
188+
>>>
189189
>>> # Create a collection with the definition as plain dictionary
190190
>>> collection_definition_2 = {
191191
... "indexing": {"deny": ["annotations", "logs"]},
@@ -198,12 +198,50 @@ class Collection(Generic[DOC]):
198198
... "my_events",
199199
... definition=collection_definition_2,
200200
... )
201-
201+
>>>
202202
>>> # Get a reference to an existing collection
203203
>>> # (no checks are performed on DB)
204204
>>> my_collection_3a = database.get_collection("my_events")
205205
>>> my_collection_3b = database.my_events
206206
>>> my_collection_3c = database["my_events"]
207+
>>>
208+
>>> # Examples with an embedding service ('vectorize'):
209+
>>>
210+
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
211+
>>> collection_definition_vz1 = (
212+
... CollectionDefinition.builder()
213+
... .set_vector_service(
214+
... "openai",
215+
... "text-embedding-3-small",
216+
... )
217+
... .build()
218+
... )
219+
>>> my_collection_vz1 = database.create_collection(
220+
... "my_entries",
221+
... definition=collection_definition_vz1,
222+
... embedding_api_key="sk-...",
223+
... )
224+
>>>
225+
>>>
226+
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
227+
>>> collection_definition_vz2 = (
228+
... CollectionDefinition.builder()
229+
... .set_vector_service(
230+
... "openai",
231+
... "text-embedding-3-small",
232+
... authentication={
233+
... "providerKey": "EMB_AUTH_KEY",
234+
... },
235+
... )
236+
... .build()
237+
... )
238+
>>> my_collection_vz2 = database.create_collection(
239+
... "my_kms_entries",
240+
... definition=collection_definition_vz2,
241+
... )
242+
>>>
243+
>>> # Get a reference to an existing collection and set its 'vectorize' authentication:
244+
>>> my_collection_vz1a = database.get_collection("my_entries", embedding_api_key="sk-...")
207245
208246
Note:
209247
creating an instance of Collection does not trigger actual creation
@@ -3066,7 +3104,7 @@ class AsyncCollection(Generic[DOC]):
30663104
... "https://01234567-....apps.astra.datastax.com",
30673105
... token="AstraCS:..."
30683106
... )
3069-
3107+
>>>
30703108
>>> # Create a collection using the fluent syntax for its definition
30713109
>>> from astrapy.constants import VectorMetric
30723110
>>> from astrapy.info import CollectionDefinition
@@ -3082,7 +3120,7 @@ class AsyncCollection(Generic[DOC]):
30823120
... "my_events",
30833121
... definition=collection_definition,
30843122
... )
3085-
3123+
>>>
30863124
>>>
30873125
>>> # Create a collection with the definition as object
30883126
>>> from astrapy.info import CollectionVectorOptions
@@ -3099,7 +3137,7 @@ class AsyncCollection(Generic[DOC]):
30993137
... definition=collection_definition_1,
31003138
... )
31013139
>>>
3102-
3140+
>>>
31033141
>>> # Create a collection with the definition as plain dictionary
31043142
>>> collection_definition_2 = {
31053143
... "indexing": {"deny": ["annotations", "logs"]},
@@ -3112,12 +3150,50 @@ class AsyncCollection(Generic[DOC]):
31123150
... "my_events",
31133151
... definition=collection_definition_2,
31143152
... )
3115-
3153+
>>>
31163154
>>> # Get a reference to an existing collection
31173155
>>> # (no checks are performed on DB)
31183156
>>> my_collection_3a = async_database.get_collection("my_events")
31193157
>>> my_collection_3b = async_database.my_events
31203158
>>> my_collection_3c = async_database["my_events"]
3159+
>>>
3160+
>>> # Examples with an embedding service ('vectorize'):
3161+
>>>
3162+
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
3163+
>>> collection_definition_vz1 = (
3164+
... CollectionDefinition.builder()
3165+
... .set_vector_service(
3166+
... "openai",
3167+
... "text-embedding-3-small",
3168+
... )
3169+
... .build()
3170+
... )
3171+
>>> my_collection_vz1 = await async_database.create_collection(
3172+
... "my_entries",
3173+
... definition=collection_definition_vz1,
3174+
... embedding_api_key="sk-...",
3175+
... )
3176+
>>>
3177+
>>>
3178+
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
3179+
>>> collection_definition_vz2 = (
3180+
... CollectionDefinition.builder()
3181+
... .set_vector_service(
3182+
... "openai",
3183+
... "text-embedding-3-small",
3184+
... authentication={
3185+
... "providerKey": "EMB_AUTH_KEY",
3186+
... },
3187+
... )
3188+
... .build()
3189+
... )
3190+
>>> my_collection_vz2 = await async_database.create_collection(
3191+
... "my_kms_entries",
3192+
... definition=collection_definition_vz2,
3193+
... )
3194+
>>>
3195+
>>> # Get a reference to an existing collection and set its 'vectorize' authentication:
3196+
>>> my_collection_vz1a = async_database.get_collection("my_entries", embedding_api_key="sk-...")
31213197
31223198
Note:
31233199
creating an instance of AsyncCollection does not trigger actual creation

0 commit comments

Comments
 (0)