Start integrating the onboarding flow with backend 3
This commit is contained in:
@@ -27,7 +27,7 @@ from app.services.messaging import (
|
||||
publish_job_started
|
||||
)
|
||||
|
||||
from shared.auth.decorators import require_admin_role, get_current_user_dep, get_current_tenant_id_dep
|
||||
from shared.auth.decorators import require_admin_role, get_current_user_dep
|
||||
from shared.database.base import create_database_manager
|
||||
from shared.monitoring.decorators import track_execution_time
|
||||
from shared.monitoring.metrics import get_metrics_collector
|
||||
@@ -48,7 +48,6 @@ async def start_enhanced_training_job(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
background_tasks: BackgroundTasks = BackgroundTasks(),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -69,15 +68,6 @@ async def start_enhanced_training_job(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Enhanced tenant validation
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_training_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
# Generate enhanced job ID
|
||||
job_id = f"enhanced_training_{tenant_id}_{uuid.uuid4().hex[:8]}"
|
||||
|
||||
@@ -310,7 +300,6 @@ async def start_enhanced_single_product_training(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
inventory_product_id: str = Path(..., description="Inventory product UUID"),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -325,14 +314,6 @@ async def start_enhanced_single_product_training(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Enhanced tenant validation
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_single_product_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
logger.info("Starting enhanced single product training",
|
||||
inventory_product_id=inventory_product_id,
|
||||
@@ -390,7 +371,6 @@ async def get_enhanced_training_job_status(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
job_id: str = Path(..., description="Job ID"),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -399,15 +379,7 @@ async def get_enhanced_training_job_status(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Validate tenant access
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_status_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
|
||||
# Get status using enhanced service
|
||||
status_info = await enhanced_training_service.get_training_status(job_id)
|
||||
|
||||
@@ -448,7 +420,6 @@ async def get_enhanced_tenant_models(
|
||||
skip: int = Query(0, description="Number of models to skip"),
|
||||
limit: int = Query(100, description="Number of models to return"),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -457,15 +428,7 @@ async def get_enhanced_tenant_models(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Validate tenant access
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_models_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
|
||||
# Get models using enhanced service
|
||||
models = await enhanced_training_service.get_tenant_models(
|
||||
tenant_id=tenant_id,
|
||||
@@ -508,7 +471,6 @@ async def get_enhanced_model_performance(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
model_id: str = Path(..., description="Model ID"),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -517,15 +479,6 @@ async def get_enhanced_model_performance(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Validate tenant access
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_performance_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
# Get performance using enhanced service
|
||||
performance = await enhanced_training_service.get_model_performance(model_id)
|
||||
|
||||
@@ -563,7 +516,6 @@ async def get_enhanced_model_performance(
|
||||
async def get_enhanced_tenant_statistics(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
request_obj: Request = None,
|
||||
current_tenant: str = Depends(get_current_tenant_id_dep),
|
||||
enhanced_training_service: EnhancedTrainingService = Depends(get_enhanced_training_service)
|
||||
):
|
||||
"""
|
||||
@@ -572,15 +524,7 @@ async def get_enhanced_tenant_statistics(
|
||||
metrics = get_metrics_collector(request_obj)
|
||||
|
||||
try:
|
||||
# Validate tenant access
|
||||
if tenant_id != current_tenant:
|
||||
if metrics:
|
||||
metrics.increment_counter("enhanced_statistics_access_denied_total")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied to tenant resources"
|
||||
)
|
||||
|
||||
|
||||
# Get statistics using enhanced service
|
||||
statistics = await enhanced_training_service.get_tenant_statistics(tenant_id)
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
from app.services.messaging import training_publisher
|
||||
from shared.auth.decorators import (
|
||||
get_current_user_dep,
|
||||
get_current_tenant_id_dep
|
||||
get_current_user_dep
|
||||
)
|
||||
|
||||
# Create WebSocket router
|
||||
|
||||
Reference in New Issue
Block a user