Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shifucun committed May 24, 2024
1 parent 24f2f93 commit fd22fe5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions nl_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
CUSTOM_DC_INDEX: str = 'custom_ft'

# App Config constants.
# Key for the registry that holds model objects/client and embedding store.
REGISTRY_KEY: str = 'NL_REGISTRY'
# Key for the catalog object that holds model and index configs.
CATALOG_KEY: str = 'NL_CATALOG'
# Key for the environment config object.
ENV_KEY: str = 'NL_ENV'

# Query to use to check index health if this is the default index.
Expand Down Expand Up @@ -92,6 +95,7 @@ class VertexAIIndexConfig(IndexConfig):


# This represents the full catalog of models and indexes.
# Only a subset of them are enabled/used by the Env config at runtime.
@dataclass(kw_only=True)
class Catalog:
version: str = None
Expand Down
5 changes: 5 additions & 0 deletions nl_server/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@

@dataclass
class Env:
"""
A class to represent the NL server environment config.
This object is used with the Catalog object to configure the server.
"""
default_indexes: List[str]
enabled_indexes: List[str]
vertex_ai_model_info: Dict[str, any]
Expand Down
6 changes: 3 additions & 3 deletions nl_server/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
from shared.lib.custom_dc_util import is_custom_dc


#
# A class to hold embeddings stores and models.
#
class Registry:
"""
A class to hold runtime model handle/client objects and embeddings stores.
"""

# Input is parsed embeddings config.
def __init__(self, catalog: Catalog):
Expand Down
8 changes: 5 additions & 3 deletions nl_server/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def healthz():
if default_embeddings_loaded:
return 'OK', 200

default_index_type = current_app.config[config.ENV_KEY].default_indexes[0]
if not default_index_type:
logging.warning('Health Check Failed: Default index name empty!')
nl_env = current_app.config[config.ENV_KEY]
if not nl_env.default_indexes:
logging.error('Health Check Failed: Default index name empty!')
return 'Service Unavailable', 500

default_index_type = nl_env.default_indexes[0]
nl_embeddings: Embeddings = current_app.config[config.REGISTRY_KEY].get_index(
default_index_type)
if nl_embeddings:
Expand Down

0 comments on commit fd22fe5

Please sign in to comment.