gavinzli commited on
Commit
b9d91b4
·
1 Parent(s): 4f365e0

Handle APIRequestError in collection creation and improve logging

Browse files
Files changed (1) hide show
  1. controllers/vectorizer.py +3 -2
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. Verifying settings...", COLLECTION_NAME)
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(