async def set_training_state_to_initiated(workspace_id: ObjectId): await WorkspaceRepository(get_async_db()).set_training_state( workspace_id, TrainingState.TRAINING_INITIATED)
async def get_prediction_key(prediction_id: ObjectId) -> PredictionKey: key = await MlModelRepository(get_async_db() ).get_prediction_key(prediction_id) return key
async def generate_prediction_id_for_model(workspace_id: ObjectId, ml_model_id: ObjectId): key = PredictionKey(None, workspace_id=workspace_id, model_id=ml_model_id) return await MlModelRepository(get_async_db()).add_prediction_key(key)
async def delete_ml_model_ref_from_workspace(workspace_id: ObjectId, ml_model_ref: ObjectId): await WorkspaceRepository(get_async_db() ).delete_ml_model_ref(workspace_id, ml_model_ref)
async def delete_ml_model(ml_model_id: ObjectId): await MlModelRepository(get_async_db()).delete_ml_model(ml_model_id)
async def get_ml_model(ml_model_id: ObjectId) -> MlModel: model = await MlModelRepository(get_async_db()).get_ml_model(ml_model_id) return model
async def add_workspace(workspace: Workspace): workspace_repository = WorkspaceRepository(get_async_db()) if await workspace_repository.workspace_exists(workspace._id): raise HTTPException(status.HTTP_406_NOT_ACCEPTABLE, detail="This workspace id is already in use.") await WorkspaceRepository(get_async_db()).add_workspace(workspace)
async def get_workspace(workspace_id: ObjectId) -> Workspace: workspace = await WorkspaceRepository(get_async_db() ).get_workspace(workspace_id) return workspace