From 137c18660010199e9542bf5483105007c05fd03a Mon Sep 17 00:00:00 2001 From: Antoine Gaudron-desjardins <antoine.gaudrondesjardins@student-cs.fr> Date: Tue, 5 Jul 2022 23:50:24 +0200 Subject: [PATCH] linting --- backend/db/crud.py | 5 +++-- backend/db/database.py | 1 - backend/db/models.py | 2 +- backend/db/schemas.py | 11 +++++++---- backend/main.py | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/db/crud.py b/backend/db/crud.py index b90c047..45f099a 100644 --- a/backend/db/crud.py +++ b/backend/db/crud.py @@ -7,7 +7,8 @@ from db import models, schemas def get_records(place: str, db: Session): """ Get all the records for the given place """ - records = db.query(models.Records).filter(models.Records.place == place).order_by(models.Records.date.desc()).all() + records = db.query(models.Records).filter( + models.Records.place == place).order_by(models.Records.date.desc()).all() return records @@ -17,4 +18,4 @@ def create_record(new_record: schemas.RecordBase, db: Session): db.add(db_record) db.commit() db.refresh(db_record) - return db_record \ No newline at end of file + return db_record diff --git a/backend/db/database.py b/backend/db/database.py index 6f99502..24d0618 100644 --- a/backend/db/database.py +++ b/backend/db/database.py @@ -15,4 +15,3 @@ engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) Base = declarative_base() - diff --git a/backend/db/models.py b/backend/db/models.py index 55820de..4971ef3 100644 --- a/backend/db/models.py +++ b/backend/db/models.py @@ -14,4 +14,4 @@ class Records(Base): place = Column(String(10)) date = Column(DateTime) density = Column(Float) - waiting_time = Column(Interval) \ No newline at end of file + waiting_time = Column(Interval) diff --git a/backend/db/schemas.py b/backend/db/schemas.py index 600efc7..5f10ba9 100644 --- a/backend/db/schemas.py +++ b/backend/db/schemas.py @@ -8,14 +8,17 @@ from pydantic import BaseModel, Field class RecordBase(BaseModel): """Records base schema""" - place: str = Field(..., title="Name of the RU corresponding the given record") + place: str = Field(..., + title="Name of the RU corresponding the given record") date: datetime = Field(..., title="Date of the record") density: float = Field(..., title="Estimated density of people") - waiting_time: Optional[timedelta] = Field(title="Estimated waiting time for people coming at this date") - + waiting_time: Optional[timedelta] = Field( + title="Estimated waiting time for people coming at this date") + + class Record(RecordBase): """Database records schema""" id: int class Config: - orm_mode = True \ No newline at end of file + orm_mode = True diff --git a/backend/main.py b/backend/main.py index 3d1329d..ac7fe9c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -25,6 +25,7 @@ app.add_middleware( allow_headers=["*"] ) + def get_db(): """Create a database session.""" db = database.SessionLocal() @@ -83,4 +84,4 @@ async def estimate_(id: str) -> float: pred_map = np.squeeze(model.predict(input_image)) count_prediction = np.sum(pred_map) return count_prediction -""" \ No newline at end of file +""" -- GitLab