Skip to content

Commit d51ab3a

Browse files
authored
Major codebase restructuring (#322)
* more organized file structure * care about pdoc
1 parent 217065e commit d51ab3a

38 files changed

+7766
-7632
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
v 2.0.0
22
=======
3+
Major restructuring of the codebase into directories
4+
- BaseCursor not exported by astrapy.cursors anymore
5+
- some imports (supposedly not used externally) changed slightly
6+
- adapted and limited scope of test_imports.py
37
Rename main branch from 'master' ==> `main`
8+
Cursors' state described by the `CursorState` enum
49
Removal of several deprecated modules/features from previous versions:
510
- 'core' (i.e. pre-1.0) library
611
- 'collection.bulk_write' and the associated result and exception classes

README.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -369,33 +369,34 @@ Client, data and admin abstractions:
369369

370370
```python
371371
from astrapy import (
372-
DataAPIClient,
373-
Database,
374-
AsyncDatabase,
375-
Collection,
376-
AsyncCollection,
377372
AstraDBAdmin,
378373
AstraDBDatabaseAdmin,
374+
AsyncCollection,
375+
AsyncDatabase,
376+
Collection,
377+
DataAPIClient,
379378
DataAPIDatabaseAdmin,
379+
Database,
380380
)
381381
```
382382

383383
Constants for data-related use:
384384

385385
```python
386386
from astrapy.constants import (
387+
DefaultIdType,
388+
Environment,
387389
ReturnDocument,
388390
SortDocuments,
389391
VectorMetric,
390-
DefaultIdType,
391-
Environment,
392392
)
393393
```
394394

395395
ObjectIds and UUIDs:
396396

397397
```python
398398
from astrapy.ids import (
399+
UUID,
399400
ObjectId,
400401
uuid1,
401402
uuid3,
@@ -404,7 +405,6 @@ from astrapy.ids import (
404405
uuid6,
405406
uuid7,
406407
uuid8,
407-
UUID,
408408
)
409409
```
410410

@@ -453,39 +453,42 @@ Info/metadata classes:
453453
```python
454454
from astrapy.info import (
455455
AdminDatabaseInfo,
456-
DatabaseInfo,
457-
CollectionInfo,
458-
CollectionVectorServiceOptions,
459456
CollectionDefaultIDOptions,
460-
CollectionVectorOptions,
461-
CollectionOptions,
462457
CollectionDescriptor,
463-
EmbeddingProviderParameter,
458+
CollectionInfo,
459+
CollectionOptions,
460+
CollectionVectorOptions,
461+
CollectionVectorServiceOptions,
462+
DatabaseInfo,
463+
EmbeddingProvider,
464+
EmbeddingProviderAuthentication,
464465
EmbeddingProviderModel,
466+
EmbeddingProviderParameter,
465467
EmbeddingProviderToken,
466-
EmbeddingProviderAuthentication,
467-
EmbeddingProvider,
468468
FindEmbeddingProvidersResult,
469469
)
470470
```
471471

472-
Admin-related classes and constants:
472+
Admin-related classes, functions and constants:
473473

474474
```python
475475
from astrapy.admin import (
476+
DatabaseAdmin,
476477
ParsedAPIEndpoint,
478+
fetch_database_info,
479+
parse_api_endpoint,
477480
)
478481
```
479482

480483
Cursors:
481484

482485
```python
483486
from astrapy.cursors import (
484-
BaseCursor,
485-
Cursor,
487+
AsyncCommandCursor,
486488
AsyncCursor,
487489
CommandCursor,
488-
AsyncCommandCursor,
490+
Cursor,
491+
CursorState,
489492
)
490493
```
491494

astrapy/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ def get_version() -> str:
7474

7575

7676
__pdoc__ = {
77-
"api_commander": False,
78-
"api_options": False,
79-
"defaults": False,
8077
"ids": False,
81-
"meta": False,
82-
"request_tools": False,
83-
"transform_payload": False,
84-
"user_agents": False,
78+
"settings": False,
8579
}

astrapy/admin/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright DataStax, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
from astrapy.admin.admin import (
18+
AstraDBAdmin,
19+
AstraDBDatabaseAdmin,
20+
DataAPIDatabaseAdmin,
21+
DatabaseAdmin,
22+
ParsedAPIEndpoint,
23+
fetch_database_info,
24+
parse_api_endpoint,
25+
)
26+
27+
__all__ = [
28+
"AstraDBAdmin",
29+
"AstraDBDatabaseAdmin",
30+
"DataAPIDatabaseAdmin",
31+
"DatabaseAdmin",
32+
"ParsedAPIEndpoint",
33+
"fetch_database_info",
34+
"parse_api_endpoint",
35+
]

astrapy/admin.py renamed to astrapy/admin/admin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
from dataclasses import dataclass
2323
from typing import TYPE_CHECKING, Any, Sequence
2424

25-
from astrapy.api_commander import APICommander
2625
from astrapy.authentication import coerce_token_provider, redact_secret
2726
from astrapy.constants import CallerType, Environment
2827
from astrapy.cursors import CommandCursor
29-
from astrapy.defaults import (
28+
from astrapy.exceptions import (
29+
DataAPIFaultyResponseException,
30+
DevOpsAPIException,
31+
MultiCallTimeoutManager,
32+
base_timeout_info,
33+
)
34+
from astrapy.info import AdminDatabaseInfo, DatabaseInfo, FindEmbeddingProvidersResult
35+
from astrapy.settings.defaults import (
3036
API_ENDPOINT_TEMPLATE_ENV_MAP,
3137
API_PATH_ENV_MAP,
3238
API_VERSION_ENV_MAP,
@@ -46,14 +52,8 @@
4652
DEV_OPS_URL_ENV_MAP,
4753
DEV_OPS_VERSION_ENV_MAP,
4854
)
49-
from astrapy.exceptions import (
50-
DataAPIFaultyResponseException,
51-
DevOpsAPIException,
52-
MultiCallTimeoutManager,
53-
base_timeout_info,
54-
)
55-
from astrapy.info import AdminDatabaseInfo, DatabaseInfo, FindEmbeddingProvidersResult
56-
from astrapy.request_tools import HttpMethod
55+
from astrapy.utils.api_commander import APICommander
56+
from astrapy.utils.request_tools import HttpMethod
5757

5858
if TYPE_CHECKING:
5959
from astrapy import AsyncDatabase, Database

astrapy/authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from abc import ABC, abstractmethod
1919
from typing import Any
2020

21-
from astrapy.defaults import (
21+
from astrapy.settings.defaults import (
2222
EMBEDDING_HEADER_API_KEY,
2323
EMBEDDING_HEADER_AWS_ACCESS_ID,
2424
EMBEDDING_HEADER_AWS_SECRET_ID,

astrapy/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import logging
1818
from typing import TYPE_CHECKING, Any, Sequence
1919

20-
from astrapy.admin import (
20+
from astrapy.admin.admin import (
2121
api_endpoint_parsing_error_message,
2222
generic_api_url_parsing_error_message,
2323
parse_api_endpoint,

0 commit comments

Comments
 (0)