Fix issues 2
This commit is contained in:
@@ -51,10 +51,6 @@ def make_json_serializable(obj):
|
||||
return obj.tolist()
|
||||
elif isinstance(obj, pd.DataFrame):
|
||||
return obj.to_dict('records')
|
||||
elif isinstance(obj, datetime):
|
||||
return obj.isoformat()
|
||||
elif isinstance(obj, date):
|
||||
return obj.isoformat()
|
||||
elif isinstance(obj, uuid.UUID):
|
||||
return str(obj)
|
||||
elif hasattr(obj, '__class__') and 'UUID' in str(obj.__class__):
|
||||
@@ -132,8 +128,7 @@ class EnhancedTrainingService:
|
||||
tenant_id=tenant_id)
|
||||
|
||||
# Get session and initialize repositories
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
try:
|
||||
@@ -431,8 +426,7 @@ class EnhancedTrainingService:
|
||||
async def get_training_status(self, job_id: str) -> Dict[str, Any]:
|
||||
"""Get training job status using repository"""
|
||||
try:
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session()() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
log = await self.training_log_repo.get_log_by_job_id(job_id)
|
||||
@@ -466,8 +460,7 @@ class EnhancedTrainingService:
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Get models for a tenant using repository"""
|
||||
try:
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
if active_only:
|
||||
@@ -494,8 +487,7 @@ class EnhancedTrainingService:
|
||||
async def get_model_performance(self, model_id: str) -> Dict[str, Any]:
|
||||
"""Get model performance metrics using repository"""
|
||||
try:
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
# Get model summary
|
||||
@@ -526,8 +518,7 @@ class EnhancedTrainingService:
|
||||
async def get_tenant_statistics(self, tenant_id: str) -> Dict[str, Any]:
|
||||
"""Get comprehensive tenant statistics using repositories"""
|
||||
try:
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
# Get model statistics
|
||||
@@ -577,8 +568,7 @@ class EnhancedTrainingService:
|
||||
tenant_id: str = None):
|
||||
"""Update job status using repository pattern"""
|
||||
try:
|
||||
from app.core.database import get_background_db_session
|
||||
async with get_background_db_session() as session:
|
||||
async with self.database_manager.get_session() as session:
|
||||
await self._init_repositories(session)
|
||||
|
||||
# Check if log exists, create if not
|
||||
|
||||
Reference in New Issue
Block a user