Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Reset the LanceDB database and reload with new diverse content | |
| """ | |
| import asyncio | |
| import logging | |
| import shutil | |
| import os | |
| from pathlib import Path | |
| # Setup logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger("reset_db") | |
| async def reset_database(): | |
| """Reset the database and reload with diverse content""" | |
| try: | |
| # Path to the database directory | |
| db_path = Path("lancedb_data") | |
| if db_path.exists(): | |
| logger.info("ποΈ Removing existing database...") | |
| shutil.rmtree(db_path) | |
| logger.info("β Existing database removed") | |
| # Recreate the database directory | |
| db_path.mkdir(exist_ok=True) | |
| logger.info("π Created new database directory") | |
| # Now run the setup documents script | |
| logger.info("π Loading new diverse documents...") | |
| from setup_documents import setup_sample_documents | |
| await setup_sample_documents() | |
| logger.info("π Database reset complete with diverse content!") | |
| except Exception as e: | |
| logger.error(f"β Error resetting database: {e}") | |
| if __name__ == "__main__": | |
| asyncio.run(reset_database()) |