latest
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""
|
||||
Infrastructure initialization module for ClassroomCopilot
|
||||
Handles Neo4j database, schema, calendar structure, and Supabase storage buckets
|
||||
"""
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
from modules.logger_tool import initialise_logger
|
||||
|
||||
logger = initialise_logger(__name__, os.getenv("LOG_LEVEL"), os.getenv("LOG_PATH"), 'default', True)
|
||||
|
||||
def initialize_infrastructure() -> Dict[str, Any]:
|
||||
"""
|
||||
Initialize infrastructure: Neo4j database, schema, calendar structure, and Supabase buckets
|
||||
|
||||
Returns:
|
||||
dict: Result status and message
|
||||
"""
|
||||
logger.info("Starting infrastructure initialization...")
|
||||
|
||||
try:
|
||||
# 1. Initialize Neo4j database, schema, and calendar structure
|
||||
logger.info("Step 1: Initializing Neo4j infrastructure...")
|
||||
from .neo4j import initialize_neo4j
|
||||
neo4j_result = initialize_neo4j()
|
||||
|
||||
if not neo4j_result["success"]:
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Neo4j infrastructure initialization failed: {neo4j_result['message']}"
|
||||
}
|
||||
|
||||
# 2. Initialize Supabase storage buckets
|
||||
logger.info("Step 2: Initializing Supabase storage buckets...")
|
||||
from .buckets import initialize_buckets
|
||||
buckets_result = initialize_buckets()
|
||||
|
||||
if not buckets_result["success"]:
|
||||
return {
|
||||
"success": False,
|
||||
"message": f"Storage buckets initialization failed: {buckets_result['message']}"
|
||||
}
|
||||
|
||||
logger.info("Infrastructure initialization completed successfully!")
|
||||
return {
|
||||
"success": True,
|
||||
"message": "Infrastructure initialization completed successfully",
|
||||
"neo4j": neo4j_result,
|
||||
"buckets": buckets_result
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Failed to initialize infrastructure: {str(e)}"
|
||||
logger.error(error_msg)
|
||||
return {
|
||||
"success": False,
|
||||
"message": error_msg,
|
||||
"error": str(e)
|
||||
}
|
||||
Reference in New Issue
Block a user