From eba9ea088d513a07481185797806a818ced5fbc3 Mon Sep 17 00:00:00 2001 From: pr0m3th3usEx Date: Sat, 12 Feb 2022 18:30:09 +0100 Subject: [PATCH 1/3] fix: migrations db --- Back-End/API/.dockerignore | 3 +-- Back-End/API/migrations/setup.py | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Back-End/API/.dockerignore b/Back-End/API/.dockerignore index b92a7d0..dfae634 100644 --- a/Back-End/API/.dockerignore +++ b/Back-End/API/.dockerignore @@ -1,5 +1,4 @@ __pycache__ .env env -tests -migrations/ \ No newline at end of file +tests \ No newline at end of file diff --git a/Back-End/API/migrations/setup.py b/Back-End/API/migrations/setup.py index 435e58b..51ed86d 100755 --- a/Back-End/API/migrations/setup.py +++ b/Back-End/API/migrations/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import os import enum import uuid import sqlalchemy @@ -9,7 +10,10 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.dialects.postgresql import UUID -engine = create_engine('postgresql://root:password@localhost:5432/koic_detections', echo = True) +engine = create_engine( + os.getenv("DATABASE_URI", "postgresql://root:password@localhost:5432/koic_detections"), + echo = True +) Base = declarative_base() class Animals(enum.Enum): From 9836a7eb6d22d39c5fefdefbc37ecf6a3492f0c5 Mon Sep 17 00:00:00 2001 From: pr0m3th3usEx Date: Sat, 12 Feb 2022 18:39:52 +0100 Subject: [PATCH 2/3] feat: add migration from docker + requirements for producer --- RPIProducer/requirements.txt | 3 +++ launch.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 RPIProducer/requirements.txt diff --git a/RPIProducer/requirements.txt b/RPIProducer/requirements.txt new file mode 100644 index 0000000..e3ed3c0 --- /dev/null +++ b/RPIProducer/requirements.txt @@ -0,0 +1,3 @@ +kafka-python==2.0.2 +numpy==1.22.2 +opencv-contrib-python==4.5.5.62 diff --git a/launch.sh b/launch.sh index 1ff25ca..b271419 100755 --- a/launch.sh +++ b/launch.sh @@ -26,7 +26,7 @@ fi sleep 2 -if ./Back-End/API/migrations/setup.py &> /dev/null; then +if docker-compose --file Back-End/docker-compose.yml run api migrations/setup.py &> /dev/null; then printf "${GREEN}[ DONE ]${NC} Create table in DB\n" else printf "${RED}[ CRASH ]${NC} Create table in DB\n" From cea18d87271d0f17e4155ab8a2bf4721a0667977 Mon Sep 17 00:00:00 2001 From: pr0m3th3usEx Date: Sat, 12 Feb 2022 18:44:11 +0100 Subject: [PATCH 3/3] feat: add Readme instruction install requirements producer --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5318ad1..b77fd96 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ And save. Check that the above steps have been carried out. If you would test without pi run his command: ```bash +python3 -m pip install -r ./RPIProducer/requirements.txt ./RPIProducer/tests/fake_producer.py ```