Skip to content

Commit

Permalink
feat: add healthchecks (#93)
Browse files Browse the repository at this point in the history
* feat: add healthchecks

* fix: six version
  • Loading branch information
dilyararimovna authored Oct 24, 2023
1 parent 8432f1e commit d9ff186
Show file tree
Hide file tree
Showing 87 changed files with 190 additions and 61 deletions.
1 change: 1 addition & 0 deletions annotators/IntentCatcherTransformers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ itsdangerous==2.0.1
gunicorn==19.9.0
requests==2.22.0
sentry-sdk[flask]==0.14.1
six==1.16.0
healthcheck==1.3.3
jinja2<=3.0.3
Werkzeug<=2.0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ flask==1.1.1
gunicorn==19.9.0
requests==2.22.0
sentry-sdk[flask]==0.14.1
six==1.16.0
healthcheck==1.3.3
itsdangerous==2.0.1
jinja2<=3.0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ flask==1.1.1
gunicorn==19.9.0
requests==2.22.0
sentry-sdk[flask]==0.14.1
six==1.16.0
healthcheck==1.3.3
itsdangerous==2.0.1
jinja2<=3.0.3
Expand Down
3 changes: 3 additions & 0 deletions annotators/combined_classification/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ ENV KEEP_ZERO_CONFS=$KEEP_ZERO_CONFS
COPY annotators/combined_classification/ ./
COPY common/ common/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200 --preload
2 changes: 2 additions & 0 deletions annotators/combined_classification/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ transformers==4.15.0
jinja2<=3.0.3
Werkzeug<=2.0.3
pytorch-crf==0.7.2
six==1.16.0
healthcheck==1.3.3
5 changes: 3 additions & 2 deletions annotators/combined_classification/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import os
import time

from flask import Flask, request, jsonify
import sentry_sdk

from flask import Flask, request, jsonify
from healthcheck import HealthCheck
from sentry_sdk.integrations.flask import FlaskIntegration
from deeppavlov import build_model
from common.utils import combined_classes
Expand Down Expand Up @@ -66,6 +66,7 @@ def get_result(sentences, sentences_with_history, postannotations=False):
raise e

app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")


@app.route("/model", methods=["POST"])
Expand Down
3 changes: 3 additions & 0 deletions annotators/doc_processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ COPY annotators/doc_processor /src
COPY documents /src/documents
COPY common /src/common

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200
4 changes: 3 additions & 1 deletion annotators/doc_processor/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ pypdfium2==4.16.0
bs4==0.0.1
python-docx==0.8.11
simplify-docx==0.1.2
filetype==1.2.0
filetype==1.2.0
six==1.16.0
healthcheck==1.3.3
5 changes: 4 additions & 1 deletion annotators/doc_processor/server.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import logging
import os

import sentry_sdk
from common.files_and_folders_processing import SKILLS_USING_DOC
from flask import Flask, jsonify, request
from healthcheck import HealthCheck
from sentry_sdk.integrations.flask import FlaskIntegration
from utils import upload_documents_save_info
from common.files_and_folders_processing import SKILLS_USING_DOC

# logging here because it conflicts with tf

logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
sentry_sdk.init(dsn=os.getenv("SENTRY_DSN"), integrations=[FlaskIntegration()])
app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

DOC_PATHS_OR_LINKS = os.environ.get("DOC_PATHS_OR_LINKS")
if DOC_PATHS_OR_LINKS:
Expand Down
3 changes: 3 additions & 0 deletions annotators/doc_retriever/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ COPY annotators/doc_retriever /src
COPY documents /src/documents
COPY common /src/common

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200
5 changes: 4 additions & 1 deletion annotators/doc_retriever/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ itsdangerous==2.0.1
gunicorn==19.9.0
requests==2.22.0
sentry-sdk[flask]==0.14.1
six==1.16.0
healthcheck==1.3.3
jinja2<=3.0.3
Werkzeug<=2.0.3
Expand All @@ -12,4 +13,6 @@ spacy==3.5
pypdfium2==4.16.0
bs4==0.0.1
python-docx==0.8.11
simplify-docx==0.1.2
simplify-docx==0.1.2
six==1.16.0
healthcheck==1.3.3
11 changes: 7 additions & 4 deletions annotators/doc_retriever/server.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import logging
import os
import sentry_sdk
import requests
from pathlib import PurePath

import requests
import sentry_sdk
from common.files_and_folders_processing import create_folders_if_not_exist
from deeppavlov import build_model
from deeppavlov.core.common.file import read_json
from flask import Flask, jsonify, request
from healthcheck import HealthCheck
from sentry_sdk.integrations.flask import FlaskIntegration
from deeppavlov.core.common.file import read_json
from utils import vectorize_upload_return_attributes, download_files, add_file_id_to_config
from common.files_and_folders_processing import create_folders_if_not_exist

# logging here because it conflicts with tf

logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
sentry_sdk.init(dsn=os.getenv("SENTRY_DSN"), integrations=[FlaskIntegration()])
app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

PARAGRAPHS_NUM = int(os.environ.get("PARAGRAPHS_NUM", 5))
FILE_SERVER_TIMEOUT = float(os.environ.get("FILE_SERVER_TIMEOUT", 30))
Expand Down
1 change: 1 addition & 0 deletions annotators/entity_storer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sentry_sdk[flask]==1.19.1
flask==2.2.3
itsdangerous==2.0.1
gunicorn==20.1.0
six==1.16.0
healthcheck==1.3.3
six==1.15.0
spacy==3.5.1
Expand Down
3 changes: 3 additions & 0 deletions annotators/prompt_selector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ ENV SENTENCE_RANKER_SERVICE_URL ${SENTENCE_RANKER_SERVICE_URL}
ARG N_SENTENCES_TO_RETURN
ENV N_SENTENCES_TO_RETURN ${N_SENTENCES_TO_RETURN}

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app --bind 0.0.0.0:8000
2 changes: 2 additions & 0 deletions annotators/prompt_selector/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ click<=8.0.4
jinja2<=3.1.2
Werkzeug>=2.2.2,<3.0
numpy>=1.17.2
six==1.16.0
healthcheck==1.3.3
2 changes: 2 additions & 0 deletions annotators/prompt_selector/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import numpy as np
import sentry_sdk
from flask import Flask, request, jsonify
from healthcheck import HealthCheck


sentry_sdk.init(getenv("SENTRY_DSN"))
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.DEBUG)
logger = logging.getLogger(__name__)
app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

SENTENCE_RANKER_SERVICE_URL = getenv("SENTENCE_RANKER_SERVICE_URL")
logger.info(f"prompt-selector considered ranker: {SENTENCE_RANKER_SERVICE_URL}")
Expand Down
13 changes: 0 additions & 13 deletions annotators/prompt_selector/template.yml

This file was deleted.

1 change: 1 addition & 0 deletions annotators/toxic_classification_ru/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ flask==1.1.1
gunicorn==19.9.0
requests==2.22.0
sentry-sdk[flask]==0.14.1
six==1.16.0
healthcheck==1.3.3
itsdangerous==2.0.1
jinja2<=3.0.3
Expand Down
1 change: 1 addition & 0 deletions common/dialogflow_framework/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sentry_sdk[flask]==0.14.3
flask==1.1.1
itsdangerous==2.0.1
gunicorn==19.9.0
six==1.16.0
healthcheck==1.3.3
# dialogflow framework
programy==4.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ ENV FILTER_BADLISTED_WORDS ${FILTER_BADLISTED_WORDS}

COPY . /src/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 --bind 0.0.0.0:3003 server:app

This file was deleted.

10 changes: 0 additions & 10 deletions response_selectors/confidence_based_response_selector/pipeline.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ numpy==1.25.0
sentry-sdk==0.12.3
jinja2<=3.0.3
Werkzeug<=2.0.3
six==1.16.0
healthcheck==1.3.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import time
import requests

import sentry_sdk
from flask import Flask, request, jsonify
from healthcheck import HealthCheck
from os import getenv
import sentry_sdk


sentry_sdk.init(getenv("SENTRY_DSN"))
Expand All @@ -16,6 +17,7 @@
logger = logging.getLogger(__name__)

app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

BADLIST_URL = getenv("BADLIST_ANNOTATOR_URL", "http://badlisted-words:8018/badlisted_words_batch")
FILTER_BADLISTED_WORDS = getenv("FILTER_BADLISTED_WORDS", 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ ENV LANGUAGE ${LANGUAGE}
COPY ./response_selectors/convers_evaluation_based_selector/ ./
COPY ./common/ ./common/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=2 server:app
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ sentry-sdk==0.12.3
nltk==3.2.5
jinja2<=3.0.3
Werkzeug<=2.0.3
six==1.16.0
healthcheck==1.3.3
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
import sentry_sdk
from flask import Flask, request, jsonify
from healthcheck import HealthCheck
from nltk.tokenize import sent_tokenize

from common.greeting import greeting_spec, HI_THIS_IS_DREAM
Expand Down Expand Up @@ -41,6 +42,7 @@
logger = logging.getLogger(__name__)

app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

CALL_BY_NAME_PROBABILITY = float(getenv("CALL_BY_NAME_PROBABILITY", 0.5)) # if name is already known
TAG_BASED_SELECTION = getenv("TAG_BASED_SELECTION", False)
Expand Down
2 changes: 2 additions & 0 deletions response_selectors/llm_based_response_selector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ COPY ./response_selectors/llm_based_response_selector/ /src/
WORKDIR /src
COPY ./common/ ./common/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ numpy==1.25.0
sentry-sdk==0.12.3
jinja2<=3.0.3
Werkzeug<=2.0.3
six==1.16.0
healthcheck==1.3.3
3 changes: 3 additions & 0 deletions response_selectors/llm_based_response_selector/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import sentry_sdk
from flask import Flask, request, jsonify
from healthcheck import HealthCheck

from common.containers import get_envvars_for_llm, is_container_running
from common.prompts import send_request_to_prompted_generative_service, compose_sending_variables
from common.utils import is_toxic_or_badlisted_utterance
Expand All @@ -21,6 +23,7 @@
logger = logging.getLogger(__name__)

app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

GENERATIVE_SERVICE_URL = getenv("GENERATIVE_SERVICE_URL")
while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ COPY ./response_selectors/ranking_and_intent_based_response_selector/ /src/
WORKDIR /src
COPY ./common/ ./common/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ numpy==1.25.0
sentry-sdk==0.12.3
jinja2<=3.0.3
Werkzeug<=2.0.3
six==1.16.0
healthcheck==1.3.3
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import sentry_sdk
from flask import Flask, request, jsonify
from healthcheck import HealthCheck
from common.universal_templates import (
is_any_question_sentence_in_utterance,
if_chat_about_particular_topic,
Expand All @@ -31,6 +32,7 @@
logger = logging.getLogger(__name__)

app = Flask(__name__)
health = HealthCheck(app, "/healthcheck")

SENTENCE_RANKER_ANNOTATION_NAME = getenv("SENTENCE_RANKER_ANNOTATION_NAME")
SENTENCE_RANKER_SERVICE_URL = getenv("SENTENCE_RANKER_SERVICE_URL")
Expand Down
2 changes: 2 additions & 0 deletions response_selectors/ranking_based_response_selector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ COPY ./response_selectors/ranking_based_response_selector/ /src/
WORKDIR /src
COPY ./common/ ./common/

# wait for a server answer ( INTERVAL + TIMEOUT ) * RETRIES seconds after that change stutus to unhealthy
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl --fail 127.0.0.1:${SERVICE_PORT}/healthcheck || exit 1

CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ numpy==1.25.0
sentry-sdk==0.12.3
jinja2<=3.0.3
Werkzeug<=2.0.3
six==1.16.0
healthcheck==1.3.3
Loading

0 comments on commit d9ff186

Please sign in to comment.