Skip to content

Commit

Permalink
Optimize NL server healthz checks (#4270)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradh authored May 23, 2024
1 parent 1759fdb commit a16b8c7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nl_server/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@

bp = Blueprint('main', __name__, url_prefix='/')

#
# A global bool to ensure we keep failing healthz till we
# load the default embeddings fully on the server.
#
default_embeddings_loaded = False


@bp.route('/healthz')
def healthz():
global default_embeddings_loaded

if default_embeddings_loaded:
return 'OK', 200

default_index_type = current_app.config[
config.EMBEDDINGS_SPEC_KEY].default_index
if not default_index_type:
Expand All @@ -48,6 +59,7 @@ def healthz():
result: VarCandidates = search.search_vars([nl_embeddings],
[query]).get(query)
if result and result.svs:
default_embeddings_loaded = True
return 'OK', 200
else:
logging.warning(f'Health Check Failed: query "{query}" failed!')
Expand Down

0 comments on commit a16b8c7

Please sign in to comment.