Spaces:
Sleeping
Sleeping
Download python_backend/api/CodeRunAndModelTrain/routes/coding_router.py from VashuTheGreat2/ML-Learner: direct link, hf CLI and curl.
- Browser
- Download file 604 Bytes
-
https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/api/CodeRunAndModelTrain/routes/coding_router.py
- Command line
-
hf download hf://spaces/VashuTheGreat2/ML-Learner/python_backend/api/CodeRunAndModelTrain/routes/coding_router.py
-
curl -L -o coding_router.py https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/api/CodeRunAndModelTrain/routes/coding_router.py
604 Bytes
| import fastapi | |
| from src.CodeRunAndModelTrain.pipelines.CodeRunPipeline import CodeRunPipeline | |
| from src.CodeRunAndModelTrain.models.code_run_models import Submission | |
| import logging | |
| import sys | |
| from exception import MyException | |
| router = fastapi.APIRouter() | |
| async def submit_code(sub: Submission): | |
| logging.info("Entering submit route (async)") | |
| try: | |
| pipeline = CodeRunPipeline() | |
| result = await pipeline.initiate(sub) | |
| logging.info("Code execution completed") | |
| return {"data": result} | |
| except Exception as e: | |
| raise MyException(e, sys) | |