Spaces:
Sleeping
Sleeping
Download python_backend/api/CodeRunAndModelTrain/routes/modelTraining_router.py from VashuTheGreat2/ML-Learner: direct link, hf CLI and curl.
- Browser
- Download file 632 Bytes
-
https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/api/CodeRunAndModelTrain/routes/modelTraining_router.py
- Command line
-
hf download hf://spaces/VashuTheGreat2/ML-Learner/python_backend/api/CodeRunAndModelTrain/routes/modelTraining_router.py
-
curl -L -o modelTraining_router.py https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/api/CodeRunAndModelTrain/routes/modelTraining_router.py
632 Bytes
| import fastapi | |
| from src.CodeRunAndModelTrain.pipelines.ModelTrainPipeline import ModelTrainPipeline | |
| from src.CodeRunAndModelTrain.models.model_train_models import Train as TrainSchema | |
| import logging | |
| import sys | |
| from exception import MyException | |
| router = fastapi.APIRouter() | |
| async def train_model(sub: TrainSchema): | |
| logging.info("Entering train route (async)") | |
| try: | |
| pipeline = ModelTrainPipeline() | |
| result = await pipeline.initiate(schema=sub) | |
| logging.info("Model training completed") | |
| return {"data": result} | |
| except Exception as e: | |
| raise MyException(e, sys) | |