Browse Source

add some new files and add CRUD routers for model path

highing666 3 years ago
parent
commit
d2c6329cd5

+ 0 - 0
app/api/routers/model_path/__init__.py


+ 51 - 0
app/api/routers/model_path/early_start.py

@@ -0,0 +1,51 @@
+from typing import List
+
+from fastapi import APIRouter, Depends, HTTPException
+from sqlalchemy.orm import Session
+
+from app.api.dependencies.db import get_db
+from app.crud.model_path.early_start import model_path_early_start_dtr
+from app.schemas.model_path.early_start import (
+    EarlyStartDTRModelPath,
+    EarlyStartDTRModelPathCreate,
+    EarlyStartDTRModelPathUpdate
+)
+
+router = APIRouter()
+
+
+@router.post('/early-start/dtr', response_model=EarlyStartDTRModelPath)
+async def create_model_path(model_path: EarlyStartDTRModelPathCreate, db: Session = Depends(get_db)):
+    return model_path_early_start_dtr.create(db=db, obj_in=model_path)
+
+
+@router.get('/early-start/dtr', response_model=List[EarlyStartDTRModelPath])
+async def read_model_path(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
+    model_paths = model_path_early_start_dtr.get_multi(db, skip=skip, limit=limit)
+    return model_paths
+
+
+@router.get('/early-start/dtr/{device_id}', response_model=EarlyStartDTRModelPath)
+async def read_model_path_by_device(device_id: str, db: Session = Depends(get_db)):
+    db_model_path = model_path_early_start_dtr.get_path_by_device(db=db, device_id=device_id)
+    return db_model_path
+
+
+@router.put('/early-start/dtr/{device_id}', response_model=EarlyStartDTRModelPath)
+async def update_model_path(device_id: str, model_path_in: EarlyStartDTRModelPathUpdate, db: Session = Depends(get_db)):
+    model_path = model_path_early_start_dtr.get_path_by_device(db=db, device_id=device_id)
+    if model_path.device_id == device_id:
+        new_model_path = model_path_early_start_dtr.update(db=db, db_obj=model_path, obj_in=model_path_in)
+    else:
+        raise HTTPException(status_code=404, detail='Model path not found')
+
+    return new_model_path
+
+
+@router.delete('/early-start/dtr/{id}', response_model=EarlyStartDTRModelPath)
+async def delete_model_path(id: int, db: Session = Depends(get_db)):
+    model_path = model_path_early_start_dtr.get(db=db, id=id)
+    if not model_path:
+        raise HTTPException(status_code=404, detail='Model path not found')
+    model_path = model_path_early_start_dtr.remove(db=db, id=id)
+    return model_path

+ 0 - 0
app/controllers/equipment/fcu/early_start.py


+ 0 - 0
app/crud/model_path/__init__.py


+ 0 - 0
app/crud/model_path/early_start.py


+ 0 - 0
app/models/ml_models_path/__init__.py


+ 15 - 0
app/models/ml_models_path/early_start.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+
+from sqlalchemy import Column, Integer, String
+
+from app.db.session import Base
+
+
+class EarlyStartDTRModel(Base):
+    __tablename__ = 'early_start_DTR_models'
+
+    id = Column(Integer, primary_key=True, index=True)
+    project_id = Column(String, index=True, nullable=False)
+    space_id = Column(String, index=True, nullable=False)
+    device_id = Column(String, index=True, nullable=False)
+    model_path = Column(String)

+ 0 - 0
app/schemas/model_path/__init__.py


+ 0 - 0
app/schemas/model_path/early_start.py