From d52aa2cc40f6d08c223520626c49cb67390299ae Mon Sep 17 00:00:00 2001 From: Antoine Gaudron-desjardins <antoine.gaudrondesjardins@student-cs.fr> Date: Wed, 6 Jul 2022 08:51:17 +0200 Subject: [PATCH] setup linter --- .gitlab-ci.yml | 2 +- README.md | 6 ++++++ backend/db/crud.py | 3 +-- backend/db/database.py | 8 +++++++- backend/setup.cnf | 2 ++ backend/utils/preprocessing.py | 1 + 6 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 backend/setup.cnf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5858a28..cc9e264 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ lint: - source ./venv/bin/activate - pip install pycodestyle script: - - pycodestyle --show-source --show-pep8 ./backend + - pycodestyle --config=./backend ./backend test: diff --git a/README.md b/README.md index 462bb8b..98d206a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,12 @@ Start the development server running `python -m uvicorn main:app --reload --port Navigate to [http://localhost:3001](http://localhost:3001) +<br/> + +### *Le linter* +So the new commits can be deployed, you'll need to use the linter from backend : +`pycodestyle --config=./setup.cnf --exclude=./env ./` + <br/> ## In production mode diff --git a/backend/db/crud.py b/backend/db/crud.py index 45f099a..989c6bc 100644 --- a/backend/db/crud.py +++ b/backend/db/crud.py @@ -7,8 +7,7 @@ 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 diff --git a/backend/db/database.py b/backend/db/database.py index 24d0618..4ea6517 100644 --- a/backend/db/database.py +++ b/backend/db/database.py @@ -9,7 +9,13 @@ import os # load environment variables load_dotenv() -SQLALCHEMY_DATABASE_URL = f"mysql+pymysql://{os.getenv('MYSQL_USER')}:{os.getenv('MYSQL_PASSWORD')}@{os.getenv('DB_HOST')}:{os.getenv('DB_PORT')}/{os.getenv('MYSQL_DATABASE')}?charset=utf8" +user = os.getenv('MYSQL_USER') +password = os.getenv('MYSQL_PASSWORD') +host = os.getenv('DB_HOST') +port = os.getenv('DB_PORT') +database = os.getenv('MYSQL_DATABASE') + +SQLALCHEMY_DATABASE_URL = f"mysql+pymysql://{user}:{password}@{host}:{port}/{database}?charset=utf8" engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/backend/setup.cnf b/backend/setup.cnf new file mode 100644 index 0000000..8fbaf1e --- /dev/null +++ b/backend/setup.cnf @@ -0,0 +1,2 @@ +[pycodestyle] +max-line-length = 160 \ No newline at end of file diff --git a/backend/utils/preprocessing.py b/backend/utils/preprocessing.py index e4ec2c6..19384b5 100644 --- a/backend/utils/preprocessing.py +++ b/backend/utils/preprocessing.py @@ -23,6 +23,7 @@ def norm_by_imagenet(img): print('Wrong shape of the input.') return None + def fix_singular_shape(img, unit_len=16): """ Some network like w-net has both N maxpooling layers and concatenate layers, -- GitLab