Spaces:
Sleeping
Sleeping
File size: 1,412 Bytes
266d7bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import asyncio
from src.infrastructure.qdrant.qdrant_vectorstore import AsyncQdrantVectorStore
from src.utils.logger_util import setup_logging
logger = setup_logging()
async def main() -> None:
"""Create a Qdrant collection asynchronously using AsyncQdrantVectorStore.
This function initializes an AsyncQdrantVectorStore instance and calls its
create_collection method to set up a Qdrant collection for vector storage.
Errors during collection creation are logged
and handled gracefully.
Args:
None
Returns:
None
Raises:
RuntimeError: If an error occurs during Qdrant collection creation.
Exception: For unexpected errors during execution.
"""
# Initialize the logger
logger.info("Creating Qdrant collection")
try:
# Initialize the AsyncQdrantVectorStore instance
vectorstore = AsyncQdrantVectorStore()
# Create the Qdrant collection asynchronously
await vectorstore.create_collection()
logger.info("Qdrant collection created successfully")
except RuntimeError as e:
logger.error(f"Failed to create Qdrant collection: {e}")
raise RuntimeError("Error creating Qdrant collection") from e
except Exception as e:
logger.error(f"Unexpected error during Qdrant collection creation: {e}")
raise
if __name__ == "__main__":
asyncio.run(main())
|