Skip to content

Commit

Permalink
Allow configuration of log level in REST API via ENV (#541)
Browse files Browse the repository at this point in the history
* configure log level via env. adjust debug messages

* pin faiss version
  • Loading branch information
tholor committed Nov 4, 2020
1 parent df13a68 commit 46fac41
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions haystack/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def get_answers(self, question: str, top_k_reader: int = 1, top_k_retriever: int

# 1) Apply retriever(with optional filters) to get fast candidate documents
documents = self.retriever.retrieve(question, filters=filters, top_k=top_k_retriever, index=index)
logger.info(f"Got {len(documents)} candidates from retriever")
logger.debug(f"Retrieved document IDs: {[doc.id for doc in documents]}")

if len(documents) == 0:
logger.info("Retriever did not return any documents. Skipping reader ...")
Expand Down
4 changes: 0 additions & 4 deletions haystack/retriever/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def retrieve(self, query: str, filters: dict = None, top_k: int = 10, index: str
index = self.document_store.index

documents = self.document_store.query(query, filters, top_k, self.custom_query, index)
logger.info(f"Got {len(documents)} candidates from retriever")

return documents


Expand All @@ -73,8 +71,6 @@ def retrieve(self, query: str, filters: dict = None, top_k: int = 10, index: str
index = self.document_store.index
documents = self.document_store.query(query=None, filters=filters, top_k=top_k,
custom_query=self.custom_query, index=index)
logger.info(f"Got {len(documents)} candidates from retriever")

return documents

# TODO make Paragraph generic for configurable units of text eg, pages, paragraphs, or split by a char_limit
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python-multipart
python-docx
sqlalchemy_utils
# for using FAISS with GPUs, install faiss-gpu
faiss-cpu; sys_platform != 'win32' and sys_platform != 'cygwin'
faiss-cpu==1.6.3; sys_platform != 'win32' and sys_platform != 'cygwin'
tika
uvloop; sys_platform != 'win32' and sys_platform != 'cygwin'
httptools
Expand Down
1 change: 1 addition & 0 deletions rest_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
VALID_LANGUAGES = ast.literal_eval(VALID_LANGUAGES)

# Monitoring
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
APM_SERVER = os.getenv("APM_SERVER", None)
APM_SERVICE_NAME = os.getenv("APM_SERVICE_NAME", "haystack-backend")
6 changes: 4 additions & 2 deletions rest_api/controller/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RETRIEVER_TYPE, EMBEDDING_MODEL_PATH, USE_GPU, READER_MODEL_PATH, BATCHSIZE, CONTEXT_WINDOW_SIZE, \
TOP_K_PER_CANDIDATE, NO_ANS_BOOST, MAX_PROCESSES, MAX_SEQ_LEN, DOC_STRIDE, CONCURRENT_REQUEST_PER_WORKER, \
FAQ_QUESTION_FIELD_NAME, EMBEDDING_MODEL_FORMAT, READER_TYPE, READER_TOKENIZER, GPU_NUMBER, NAME_FIELD_NAME, \
VECTOR_SIMILARITY_METRIC, CREATE_INDEX
VECTOR_SIMILARITY_METRIC, CREATE_INDEX, LOG_LEVEL

from rest_api.controller.request import Question
from rest_api.controller.response import Answers, AnswersToIndividualQuestion
Expand All @@ -28,7 +28,9 @@
from haystack.retriever.sparse import ElasticsearchRetriever, ElasticsearchFilterOnlyRetriever
from haystack.retriever.dense import EmbeddingRetriever

logger = logging.getLogger(__name__)
logger = logging.getLogger('haystack')
logger.setLevel(LOG_LEVEL)

router = APIRouter()

# Init global components: DocumentStore, Retriever, Reader, Finder
Expand Down

0 comments on commit 46fac41

Please sign in to comment.