Release v2.0.0
These release notes list changes compared to version 1.5.2 (previous stable).
For more on each item, please consult the
API Reference
and the Documentation.
New features
API Tables
Added Table support in the clients
- New Database methods:
.get_table(),.create_table(),.list_tables(),.list_table_names(),.drop_table(),.drop_table_index(). - New classes:
Table,AsyncTable(with notable methods.definition(),.create_index(),.create_vector_index(),.list_index_names(),.alter()in addition to those similar as for Collections). - New classes
TableFindCursorandAsyncTableFindCursorforfindresults iteration. - New classes
TableInsertOneResult,TableInsertManyResult,TableInsertManyExceptionfor table-specific results and exceptions. - New classes to create/inspect tables:
TableInfo,CreateTableDefinition,ListTableDescriptor,ListTableDefinition,TablePrimaryKeyDescriptor,TableValuedColumnType,TableKeyValuedColumnType,TableVectorColumnType,TableUnsupportedColumnType,TableColumnTypeDescriptor,TableScalarColumnTypeDescriptor,TableVectorColumnTypeDescriptor,TableValuedColumnTypeDescriptor,TableKeyValuedColumnTypeDescriptor,TableUnsupportedColumnTypeDescriptor,TableAPISupportDescriptor. - New classes to create/inspect table indexes:
TableIndexType,TableIndexOptions,TableVectorIndexOptions,TableBaseIndexDefinition,TableIndexDefinition,TableVectorIndexDefinition,TableAPIIndexSupportDescriptor,TableUnsupportedIndexDefinition,TableIndexDescriptor. - New classes to alter tables:
AlterTableOperation,AlterTableAddColumns,AlterTableDropColumns,AlterTableAddVectorize,AlterTableDropVectorize.
Maps in tables can be expressed as list of pairs (association lists):
- Support for automatic handling of DataAPIMaps (+possibly dicts) in the proper table payload portions
- Introduced serdes option
encode_maps_as_lists_in_tables(default to "NEVER") to control this
Tables come with full typing support (usage is optional), much like is now for Collections.
Find-and-rerank for Collections
Added support for findAndRerank ("hybrid search") API command
Method .find_and_rerank() in Collection/AsyncCollection classes:
- New cursor classes
[Async]CollectionFindAndRerankCursor(returned by said method). - Introduced class
RerankedResult, over which these cursors iterate (modulo custom mappings).
Support for reranker header-based authentication where needed:
- New authentication classes
RerankingHeadersProvider,RerankingAPIKeyHeaderProviderfor collections. - Introduced
reranking_api_keyparameter for APIOptions, also exposed in:{get|create}_{table|collection}database methods; collection/tablewith_options; collection/tableto_[a]syncmethods.
Changes to .create_collection() method of [Async]Database:
- New classes
CollectionLexicalOptions,CollectionRerankOptions,RerankServiceOptions. - New
lexicalandrerankentries in CollectionDefinition (and associated builder interface management).
New [async_]find_reranking_providers methods in database admin class:
- New class hierarchy introduced:
RerankingProviderParameter,RerankingProviderModel,RerankingProviderToken,RerankingProviderAuthentication,RerankingProvider,FindRerankingProvidersResultto express the response.
Other new features
Introduced new astrapy-specific data types to fully express database values (see serdes_options below for fine control):
DataAPIVectordata type.DataAPIDate,DataAPITime,DataAPITimestamp,DataAPIDurationdata types.- (e.g. instead of 'datetime.datetime', instances of
DataAPITimestampare returned by default.)
- (e.g. instead of 'datetime.datetime', instances of
DataAPISet,DataAPIMapcollective data types.
Introduced a consistent API Options system:
- An
APIOptionsobject supplied atDataAPIClient()creation and inherited at each "spawn" operation, with overrides. - Sensible defaults if nothing supplied.
serdes_optionsto control data types accepted for writes and to select data types for reads.- Defaults prefer custom data types for lossless expressivity (set
serdes_options.custom_datatypes_in_reading = Falseto fall back to stdlib types). serdes_options.binary_encode_vectors, to control usage of binary-encoding for writing vectors (on by default for Collections).- Numbers are treated by default as ints and floats. Set
serdes_option.use_decimals_in_collections = Trueto switch toDecimal. - Fine control over naive-datetime tolerance and timezone is introduced (see
accept_naive_datetimesand
datetime_tzinfooptions). Acceptance of naive datetimes is off by default.
- Defaults prefer custom data types for lossless expressivity (set
- Support for arbitrary 'database' and 'admin' headers throughout the object chain.
- Fully reworked timeout options through all abstractions:
TimeoutOptionshas six classes of timeouts, applying differently to various methods according to the kind of method. Timeouts can be overridden on a per-method-call basis- Removal of the 'max_time_ms
parameter (keeping a quick migration path of replacing it withtimeout_ms` throughout). - Timeout of
0means completely disabled.
Typing support for Collections (optional):
- Database
.get_collection()and.create_collection()methods have adocument_typeparameter, for spawning instances matching a type hint ofCollection[MyType]. - If unspecified, fallback to
DefaultCollection = Collection[dict[str, Any]]. - Cursors from
findalso support strict typechecking. - Async collections mirror this typing behaviour.
Arbitrary field names and dot-escaping:
- Utilities
astrapy.utils.document_paths.escape_field_namesandastrapy.utils.document_paths.unescape_field_path. - The
distinctmethod can accept a list of (literal)str|intas well as whole (escaped) path-identifier strings.
Support for Astra DB "custom domain" endpoints for database (in which case: .id, .region, .get_database_admin(), .info() and .name() aren't available.)
Changes and improvements
Collections and Cursors
DataAPIMap, DataAPIDate accepted for writes. For dates, the same timezone caveats as for datetime.date apply.
Cursors' API changes (breaking changes):
- Cursors are typed, similarly to Tables and Collections. The
findmethod has an optionaldocument_typeparameter for typechecking. - Introduced
.map()and.to_list()methods. .state()now has values in theCursorStateenum (for a string, usemy_cursor.state.value).- '.address' is removed.
.rewind()returns None, mutates cursor in-place.- '.distinct()' removed: use the corresponding collection(/table) method.
- '.keyspace' property removed.
- '.retrieved' removed: use
.consumed. - Added several cursor management methods (see docstrings for details).
- The
.clone()method does not strip the mapping anymore, rather retains it. - Removed the 'alive' property (replace with the check
cursors.state != CursorState.CLOSED). - Class hierarchy around cursors revised:
- Renamed the abstract root-class 'FindCursor' to
AbstractCursor(accommodating "find and rerank" cursors). - Cursor classes renamed to
[Async]CollectionFindCursor(likewise for table cursors).
- Renamed the abstract root-class 'FindCursor' to
Creation of collections with .create_collection() database method changed substantially:
- A single
definition: CollectionDefinitionparameter with the whole structure, instead of a growing list of "flat" parameters.- This parameter can also be a plain dictionary if desired.
- Replaces and removes 'dimension', 'metric', 'source_model', 'service', 'indexing', 'default_id_type' (all of them subsumed in
definition).
CollectionDefinition: implemented fluent interface to build collection definition objects.- Removed parameters 'additional_options' and 'timeout_ms' from
.create_collection()(the latter as part of the broader timeout rework). - This is also the return type of
Collection.options()(formerly called 'CollectionOptions'). - The database
.list_collections()method returns a list ofCollectionDescriptoritems, one of whose attributes is theCollectionDefinitionas used in creation.
Exceptions
Exception hierarchy revised in a breaking way:
Revised API and semantics for the "bulk operation" exceptions:
- The four
CollectionInsertManyException,CollectionUpdateManyException,CollectionDeleteManyException,TableInsertManyExceptionclasses now inherit directly fromDataAPIResponseException. - New structure for
[Collection|Table]InsertManyException: they have membersinserted_ids(/inserted_id_tuples) and anexceptionslist for the root cause(s). - New structure for
Collection[Update|Delete]ManyException: they have memberspartial_resultand a single-exceptioncause. They are now raised consistently for API exceptions occurring during the respective methods.
Introduced InvalidEnvironmentException for operations invalid on some Data API environments.
Removed several exceptions not needed anymore:
- removed 'CursorIsStartedException': now
CursorExceptionraised for all state-related illegal calls in cursors. - removed 'CollectionNotFoundException', replaced by a ValueError in the few cases it's needed.
- removed 'CollectionAlreadyExistsException' class (not used anymore once 'check_exists' parameter removed from
create_collection). - removed 'DataAPIDetailedErrorDescriptor'.
- removed 'CumulativeOperationException`.
Renamed some exceptions:
- renamed 'InsertManyException' to
CollectionInsertManyException. - renamed 'DeleteManyException' to
CollectionDeleteManyException. - renamed 'UpdateManyException' to
CollectionUpdateManyException. - renamed 'DevOpsAPIFaultyResponseException' to
UnexpectedDevOpsAPIResponseException. - renamed 'DataAPIFaultyResponseException' to
UnexpectedDataAPIResponseException.
String representation improved for: DataAPIResponseException, DataAPIDetailedErrorDescriptor.
All astrapy exceptions derive directly from Exception (and not 'ValueError' anymore).
Replaced the ValueError not directly coming from function calls/constructors with more appropriate exceptions.
Admin- (and schema-) related changes
Spawner methods for databases/admins do not issue DevOps API calls anymore and have standardized their signature and behaviour:
AstraDBAdmin.get_[async]_database():- Does not run DevOps API calls anymore (for missing keyspace/region).
- Defers defaults to the [Async]Database class consistently.
- Removed 'database_admin_timeout_ms', 'request_timeout_ms', 'timeout_ms' parameters.
regionnow required ifidpassed instead of endpoint.
AstraDBDatabaseAdmin.get[_async]_database():- removed 'database_admin_timeout_ms', 'request_timeout_ms', 'timeout_ms' parameters.
AstraDBDatabaseAdmin.get_database_admin()standardized and simplified:- does not run DevOps API calls anymore (for missing keyspace/region).
- removed 'database_admin_timeout_ms', 'request_timeout_ms', 'timeout_ms' parameters;
regionnow required ifidpassed instead of endpoint.
- removed 'normalize_region_for_id' utility method, not used anymore.
Signature change from {"ok": 1} to None (void methods) for some admin and schema methods:
AstraDBAdmin:drop_database(and its async counterpart).AstraDBDatabaseAdmin,DataAPIDatabaseAdmin:create_keyspace,drop_keyspace,drop(+ async).Database,AsyncDatabase:drop_collection,drop_table.Collection,AsyncCollection:drop.
removed the 'CommandCursor'/'AsyncCommandCursor' classes:
AstraDBAdmin:list_databases,async_list_databasesmethods return regular lists.[Async]Database:list_collections,list_tablesmethods return regular lists.
[Async]Database: added a .region property.
Database info structure: changed class name and reworked attributes of AstraDBAdminDatabaseInfo (formerly 'AdminDatabaseInfo') and AstraDBDatabaseInfo (formerly 'DatabaseInfo').
Switching to the api_options parameter consistently brings many changes to the classes' with_options and to_[a]sync methods:
DataAPIClient_copy(),with_options(): removed 'callers'.get_..._database...(): removed 'api_path', 'api_version'.get_admin(): removed 'dev_ops_url', 'dev_ops_api_version'.
AstraDBAdmin_copy: removed 'environment', 'dev_ops_url', 'dev_ops_api_version', 'callers'with_options: removed 'callers'.create..._database: addedtoken,spawn_api_options.get..._database: removed 'api_path', 'api_version', 'database_request_timeout_ms', 'database_timeout_ms'; renamed 'database_api_options' tospawn_api_options.get_database_admin: addedtoken,spawn_api_options.
AstraDBDatabaseAdmin_copy(): removed 'api_endpoint', 'environment', 'dev_ops_url', 'dev_ops_api_version', 'api_path', 'api_version', 'callers'.with_options(): removed 'api_endpoint', 'callers'.get..._database(): removed 'api_path', 'api_version', 'database_request_timeout_ms', 'database_timeout_ms'; renamed 'database_api_options' tospawn_api_options.
DataAPIDatabaseAdmin_copy(): removed 'api_endpoint', 'environment', 'api_path', 'api_version', 'callers'.with_options(): removed 'api_endpoint', 'callers'.get..._database(): removed 'api_path', 'api_version', 'database_request_timeout_ms', 'database_timeout_ms'; renamed 'database_api_options' tospawn_api_options.
[Async]Database_copy(): removed 'api_endpoint', 'callers', 'environment', 'api_path', 'api_version'.with_options(): removed 'callers'; addedtoken.to_[a]sync(): removed 'api_endpoint', 'callers', 'environment', 'api_path', 'api_version'.get_collection(): removed 'collection_request_timeout_ms', 'collection_timeout_ms'; renamed 'collection_api_options' tospawn_api_options.get_table(): removed 'table_request_timeout_ms', 'table_timeout_ms'; renamed 'table_api_options' tospawn_api_options.create_collection(): removed 'collection_request_timeout_ms', 'collection_timeout_ms'; renamed 'collection_api_options' tospawn_api_options.create_table(): removed 'table_request_timeout_ms', 'table_timeout_ms'; renamed 'table_api_options' tospawn_api_options.get_database_admin(): removed 'dev_ops_url', 'dev_ops_api_version'.
[Async]Collection_copy(): removed 'request_timeout_ms', 'collection_timeout_ms', 'callers'.with_options: removed 'request_timeout_ms', 'collection_timeout_ms', 'name', 'callers'.to_[a]sync(): removed 'request_timeout_ms', 'collection_timeout_ms', 'keyspace', 'name', 'callers'.
[Async]Table_copy(): removed 'database', 'name', 'keyspace', 'request_timeout_ms', 'table_timeout_ms', 'callers'.with_options: removed 'name', 'request_timeout_ms', 'table_timeout_ms', 'callers'.to_[a]sync(): removed 'database', 'name', 'keyspace', 'request_timeout_ms', 'table_timeout_ms', 'callers'.
Other changes (some breaking)
Some (naming) changes prompted by the need to generalize to Tables/Collections:
- Renamed 'CollectionVectorServiceOptions' class to
VectorServiceOptions. - Renamed 'astrapy.constants.SortDocuments' to
SortMode. - Renamed (collection-specific) "result" classes as follows:
- 'DeleteResult' to
CollectionDeleteResult. - 'InsertOneResult' to
CollectionInsertOneResult. - 'InsertManyResult' to
CollectionInsertManyResult. - 'UpdateResult' to
CollectionUpdateResult.
- 'DeleteResult' to
[Async]Database.drop_collection method does not accept an object anymore, only the string name of the target to drop.
[Async]Database drop_collection method now accepts a keyspace parameter.
AsyncDatabase methods get_collection and get_table are not async functions anymore (remove the 'await' when calling them).
The following "info" methods are made async (i.e. awaitable): AsyncDatabase.info(), AsyncDatabase.name(), AsyncCollection.info(), AsyncTable.info(), AsyncDatabase.list_collections(), AsyncDatabase.list_tables()
[Async]Collection and [Async]Database: .info() method now accepts the relevant timeout parameters.
Improved StrEnum matching for e.g. better coercion of TableIndexType (and future enum with e.g. dashes in values).
- Renamed parameter 'collection_name' to
collection_or_table_nameand allow forkeyspace=Nonein databasecommand()method.
Removal of deprecated modules, objects, components, parameters, interfaces
Version 2 of the clients marks the removal of several long-deprecated items:
- 'core' (i.e. pre-1.0) library.
- 'collection.bulk_write' and the associated result and exception classes.
- 'vector=', 'vectorize=' and 'vectors=' parameters from collection methods.
- 'set_caller' method of
DataAPIClient,AstraDBAdmin,DataAPIDatabaseAdmin,AstraDBDatabaseAdmin,[Async]Database,[Async]Collection. - 'caller_name' and 'caller_version' parameters. A single list-of-pairs
callersis now expected. - 'id' and 'region' to DataAPIClient's 'get_database' (and async version). Use
api_endpointwhich is now the one positional parameter.- Accordingly, the syntax
client[api_endpoint]also does not accept a database ID anymore.
- Accordingly, the syntax
- 'region' parameter of
AstraDBDatabaseAdmin.get[_async]_database(was ignored already in the method). - 'namespace' parameter of several methods of: DataAPIClient, admin objects, Database and Collection (use
keyspace). - 'namespace' property of CollectionInfo, DatabaseInfo, CollectionNotFoundException, CollectionAlreadyExistsException (use
keyspace). - 'namespace' property of
DatabaseandCollection(switch tokeyspace). - 'update_db_namespace' parameter for keyspace admin methods (use
update_db_keyspace).
-'use_namespace' forDatabases(switch touse_keyspace).
-'delete_all' method ofCollectionandAsyncCollection(usedelete_many({})).
Other secondary removed items:
- 'check_exists' parameter removed from
[Async]Database.create_collectionmethod: the client does no checks now. - static method
from_api_endpointofAstraDBDatabaseAdmin(reason: unused). - 'database' parameter to the
to_sync()andto_async()conversion methods for collections.
Internal changes, repo maintenance/management
- Restored support for Python 3.8, 3.9 (certaing type variables were not compatible with the syntax).
- API payloads are encoded with full Unicode (not encoded in ASCII anymore) for HTTP requests.
- Switch to DSE6.9 for local non-Astra testing.
- Full restructuring of tests and CI (tables+collections on same footing; and other related improvements).
- Adopt
blockbusterin async tests to detect (and bust) any blocking call. - Classes in the hierarchy other than
DataAPIClienthave breaking changes in their constructor (now options-first and keyword-arg-only). Not user-facing as the user is never supposed to directly instantiate any of them. - Token and Embedding API key coercion into
*Providernow happens at the Options' init layer. [Async]Collection.find_onemethod uses the actual findOne API command.- Rename main branch from 'master' to
main. - Major restructuring of the codebase in directories (some internal-only imports changed; reduced the scope of
test_imports). - Collection and Table
insert_manymethods employ the Data APIreturnDocumentResponsesprimitive under the hood. - Removal of unused imports from toplevel
__init__.py(ids, constants, cursors). - Simplified timeout management classes and representations.