Handle APIRequestError in collection creation and improve logging
Browse files
controllers/vectorizer.py
CHANGED
@@ -12,6 +12,7 @@ from langchain_community.document_loaders import DataFrameLoader
|
|
12 |
from astrapy import DataAPIClient
|
13 |
from astrapy.info import CollectionVectorServiceOptions
|
14 |
from astrapy.exceptions import CollectionAlreadyExistsException
|
|
|
15 |
|
16 |
logging.basicConfig(
|
17 |
format='%(asctime)s - %(levelname)s - %(funcName)s - %(message)s',
|
@@ -48,8 +49,8 @@ try:
|
|
48 |
service=VECTOR_OPTIONS
|
49 |
)
|
50 |
logging.info("Created new collection '%s'", COLLECTION_NAME)
|
51 |
-
except CollectionAlreadyExistsException:
|
52 |
-
logging.info("Collection '%s' already exists.
|
53 |
collection = database.get_collection(COLLECTION_NAME)
|
54 |
|
55 |
vstore = AstraDBVectorStore(
|
|
|
12 |
from astrapy import DataAPIClient
|
13 |
from astrapy.info import CollectionVectorServiceOptions
|
14 |
from astrapy.exceptions import CollectionAlreadyExistsException
|
15 |
+
from astrapy.core.api import APIRequestError
|
16 |
|
17 |
logging.basicConfig(
|
18 |
format='%(asctime)s - %(levelname)s - %(funcName)s - %(message)s',
|
|
|
49 |
service=VECTOR_OPTIONS
|
50 |
)
|
51 |
logging.info("Created new collection '%s'", COLLECTION_NAME)
|
52 |
+
except (CollectionAlreadyExistsException, APIRequestError) as e:
|
53 |
+
logging.info("Collection '%s' already exists. Error Message: %s", COLLECTION_NAME, e)
|
54 |
collection = database.get_collection(COLLECTION_NAME)
|
55 |
|
56 |
vstore = AstraDBVectorStore(
|