Rely api healthcheck on status code rather than json decoding (#1871)

* Rely api healthcheck on status code rather than json decoding

* Install UI dependencies on the Linux and Windows CI

Co-authored-by: Fabrice Depaulis <fabrice.depaulis@orange.com>
Co-authored-by: ZanSara <sarazanzo94@gmail.com>
This commit is contained in:
Fabrice Depaulis 2021-12-10 18:05:23 +01:00 committed by GitHub
parent 4eb4503f25
commit 77d52ad215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

View File

@ -41,6 +41,7 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
pip install --upgrade --upgrade-strategy eager -r requirements.txt -e .
pip install --upgrade --upgrade-strategy eager -r ui/requirements.txt -e .
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cpu.html
prepare-build:

View File

@ -44,6 +44,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
pip install --upgrade --upgrade-strategy eager -r ui/requirements-dev.txt -e .
pip install --upgrade --upgrade-strategy eager -f https://download.pytorch.org/whl/torch_stable.html -r requirements.txt -e .
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cpu.html

View File

@ -63,4 +63,4 @@ weaviate-client==2.5.0
ray==1.5.0
dataclasses-json
quantulum3
azure-ai-formrecognizer==3.2.0b2
azure-ai-formrecognizer==3.2.0b2

15
test/test_ui_utils.py Normal file
View File

@ -0,0 +1,15 @@
from unittest.mock import MagicMock, patch
from ui.utils import haystack_is_ready
def test_haystack_is_ready():
with patch('requests.get') as mocked_get:
mocked_get.return_value.status_code = 200
assert haystack_is_ready()
def test_haystack_is_ready_fail():
with patch('requests.get') as mocked_get:
mocked_get.return_value.status_code = 400
assert not haystack_is_ready()

View File

@ -22,7 +22,7 @@ def haystack_is_ready():
"""
url = f"{API_ENDPOINT}/{STATUS}"
try:
if requests.get(url).json():
if requests.get(url).status_code < 400:
return True
except Exception as e:
logging.exception(e)