From d5419dffc9f900d268de2621a879837538cece7b Mon Sep 17 00:00:00 2001 From: Daniel Hladek Date: Thu, 11 Apr 2024 12:25:17 +0200 Subject: [PATCH 1/2] db uri --- annotation_app/initial.py | 4 +--- annotation_app/requirements.txt | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/annotation_app/initial.py b/annotation_app/initial.py index f3098fe..2f900dd 100644 --- a/annotation_app/initial.py +++ b/annotation_app/initial.py @@ -16,10 +16,8 @@ if __name__ == '__main__': try: with open(os.path.join('dataset', 'final_id_v2.jsonl'), encoding='utf-8') as file: data = [json.loads(line) for line in file] + db.session.add(Samples(data['text'])) - - for sample in data: - db.session.add(Samples(sample['text'])) db.session.commit() print('Data sucessfully inserted') except FileNotFoundError as err: diff --git a/annotation_app/requirements.txt b/annotation_app/requirements.txt index a490d85..5bf2d49 100644 --- a/annotation_app/requirements.txt +++ b/annotation_app/requirements.txt @@ -11,3 +11,4 @@ SQLAlchemy==2.0.28 typing_extensions==4.10.0 Werkzeug==3.0.1 zipp==3.18.1 +psycopg2-binary From b6ff963bcb4b45c95ea95890a99916f72303f242 Mon Sep 17 00:00:00 2001 From: Daniel Hladek Date: Thu, 11 Apr 2024 17:31:10 +0200 Subject: [PATCH 2/2] deployment fixes --- annotation_app/Dockerfile | 4 ++-- annotation_app/initial.py | 5 +++-- annotation_app/models.py | 2 +- annotation_app/requirements.txt | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/annotation_app/Dockerfile b/annotation_app/Dockerfile index 233cdd6..1a06b43 100644 --- a/annotation_app/Dockerfile +++ b/annotation_app/Dockerfile @@ -11,5 +11,5 @@ ENV SECRET_KEY="random_secret_key" EXPOSE 5050 -# CMD ["python3", "app.py"] -ENTRYPOINT ["tail", "-f", "/dev/null"] +CMD ["gunicorn", "--bind","0.0.0.0:5050","app:app"] +#ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/annotation_app/initial.py b/annotation_app/initial.py index 2f900dd..082c088 100644 --- a/annotation_app/initial.py +++ b/annotation_app/initial.py @@ -15,8 +15,9 @@ if __name__ == '__main__': try: with open(os.path.join('dataset', 'final_id_v2.jsonl'), encoding='utf-8') as file: - data = [json.loads(line) for line in file] - db.session.add(Samples(data['text'])) + for line in file: + data = json.loads(line) + db.session.add(Samples(data['text'])) db.session.commit() print('Data sucessfully inserted') diff --git a/annotation_app/models.py b/annotation_app/models.py index 165cba9..f8514f6 100644 --- a/annotation_app/models.py +++ b/annotation_app/models.py @@ -33,7 +33,7 @@ class Samples(db.Model): __tablename__ = 'samples' _id = db.Column("id", db.Integer, primary_key=True) - text = db.Column(db.String(512), nullable=False) + text = db.Column(db.Text, nullable=False) annotations = db.relationship('Annotations', lazy=True, backref='sample') # corrected relationship and added backref def __init__(self, text): diff --git a/annotation_app/requirements.txt b/annotation_app/requirements.txt index 5bf2d49..0fcb387 100644 --- a/annotation_app/requirements.txt +++ b/annotation_app/requirements.txt @@ -12,3 +12,4 @@ typing_extensions==4.10.0 Werkzeug==3.0.1 zipp==3.18.1 psycopg2-binary +gunicorn