Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up file & code #7

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/api/router/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ def get_db():
)


@router.get("/")
def hello_world():
return {"message": "Hello predict"}


@router.put("/insurance")
def predict_insurance(info: RegModelPrediction, db: Session = Depends(get_db)):
"""
Expand Down
84 changes: 0 additions & 84 deletions app/api/router/test.py

This file was deleted.

72 changes: 0 additions & 72 deletions app/api/router/train.py

This file was deleted.

52 changes: 0 additions & 52 deletions app/api/router/upload.py

This file was deleted.

44 changes: 0 additions & 44 deletions app/api/schemas.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
from pydantic import BaseModel


class ItemBase(BaseModel):
title: str


class ItemCreate(ItemBase):
pass


class Item(ItemBase):
class Config:
orm_mode = True


class DatasetBase(BaseModel):
path: str
version: int


class DatasetCreate(DatasetBase):
pass


class Dataset(DatasetBase):
class config:
orm_mode = True


class ClfModelBase(BaseModel):
path: str
version: int
name: str
classes: int
score: float


class ClfModelCreate(ClfModelBase):
pass


class ClfModel(ClfModelBase):
class Config:
orm_mode = True


class RegModelBase(BaseModel):
model_name: str

Expand Down
29 changes: 0 additions & 29 deletions app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,6 @@
from app.api import schemas


def get_dataset(db: Session, version=1):
return db.query(models.Dataset).filter(
models.Dataset.version == version
).first()


def create_dataset(db: Session, Dataset: schemas.DatasetCreate):
db_dataset = models.Dataset(**Dataset)
db.add(db_dataset)
db.commit()
db.refresh(db_dataset)
return db_dataset


def get_clf_model(db: Session, version=1, name='random_forest'):
return db.query(models.ClfModel).filter(
models.ClfModel.version == version and
models.ClfModel.name == name
).first()


def create_clf_model(db: Session, clf_model: schemas.ClfModelCreate):
db_cf_model = models.ClfModel(**clf_model)
db.add(db_cf_model)
db.commit()
db.refresh(db_cf_model)
return db_cf_model


def get_reg_model(db: Session, model_name: schemas.RegModelBase):
return db.query(models.RegModel).filter(
models.RegModel.model_name == model_name
Expand Down
28 changes: 1 addition & 27 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import datetime
from sqlalchemy import Column, Integer, String, FLOAT, DateTime, ForeignKey
from sqlalchemy import Column, String, FLOAT, DateTime, ForeignKey
from sqlalchemy.sql.functions import now
from sqlalchemy.orm import relationship

Expand All @@ -9,32 +9,6 @@
KST = datetime.timezone(datetime.timedelta(hours=9))


class Item(Base):
__tablename__ = 'items'

id = Column(Integer, primary_key=True, index=True, autoincrement=True)
title = Column(String, index=True, default='test')


class Dataset(Base):
__tablename__ = 'dataset'

id = Column(Integer, primary_key=True, index=True, autoincrement=True)
path = Column(String, index=True)
version = Column(Integer, index=True, autoincrement=True)


class ClfModel(Base):
__tablename__ = 'clf_model'

id = Column(Integer, primary_key=True, index=True, autoincrement=True)
path = Column(String, index=True)
version = Column(Integer, index=True, autoincrement=True)
name = Column(String, index=True)
classes = Column(Integer)
score = Column(FLOAT)


class RegModel(Base):
__tablename__ = 'reg_model'

Expand Down
15 changes: 0 additions & 15 deletions app/util.py

This file was deleted.

14 changes: 1 addition & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.api.router import test, predict, train, upload
from app.database import SessionLocal
from app.api.router import predict

app = FastAPI()

Expand All @@ -16,18 +15,7 @@
allow_headers=["*"],
)

app.include_router(test.router)
app.include_router(predict.router)
app.include_router(upload.router)
app.include_router(train.router)


def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()


@app.get("/")
Expand Down
Loading