Skip to content

Commit

Permalink
faiss-index-manager: load config-enabled features only
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocarrara committed Aug 3, 2023
1 parent f47080f commit b7edb59
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions visione/services/index/faiss-index-manager/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from flask import Flask, request, jsonify
import numpy as np

from visione import load_config


# setup logging
logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -101,9 +103,14 @@ def search():
args = parser.parse_args()

if not args.lazy_load:
features_indices = Path('/data').glob('faiss-index_*.faiss')
features_types = map(lambda x: x.name[len('faiss-index_'):len('.faiss')], features_indices)
config = load_config('/data/config.yaml')

enabled_features = config.get('analysis', []).get('features', [])
features_types = config.get('index', []).get('features', [])
features_types = [k for k, v in features_types.items() if v.get('index_engine', '') == 'faiss' and k in enabled_features]

for features_type in features_types:
logging.info(f'Loading: {features_type}')
load_index(features_type)

# run the flask app
Expand Down

0 comments on commit b7edb59

Please sign in to comment.