mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-22 01:30:08 +02:00
only warmup on index swap (#3003)
* only warmup on index swap * move conditional
This commit is contained in:
parent
1a7d627949
commit
dba2d67cdb
@ -105,19 +105,22 @@ def check_for_indexing(self: Task, *, tenant_id: str | None) -> int | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
with get_session_with_tenant(tenant_id=tenant_id) as db_session:
|
with get_session_with_tenant(tenant_id=tenant_id) as db_session:
|
||||||
check_index_swap(db_session=db_session)
|
old_search_settings = check_index_swap(db_session=db_session)
|
||||||
current_search_settings = get_current_search_settings(db_session)
|
current_search_settings = get_current_search_settings(db_session)
|
||||||
# So that the first time users aren't surprised by really slow speed of first
|
# So that the first time users aren't surprised by really slow speed of first
|
||||||
# batch of documents indexed
|
# batch of documents indexed
|
||||||
if current_search_settings.provider_type is None and not MULTI_TENANT:
|
if current_search_settings.provider_type is None and not MULTI_TENANT:
|
||||||
embedding_model = EmbeddingModel.from_db_model(
|
if old_search_settings:
|
||||||
search_settings=current_search_settings,
|
embedding_model = EmbeddingModel.from_db_model(
|
||||||
server_host=INDEXING_MODEL_SERVER_HOST,
|
search_settings=current_search_settings,
|
||||||
server_port=INDEXING_MODEL_SERVER_PORT,
|
server_host=INDEXING_MODEL_SERVER_HOST,
|
||||||
)
|
server_port=INDEXING_MODEL_SERVER_PORT,
|
||||||
warm_up_bi_encoder(
|
)
|
||||||
embedding_model=embedding_model,
|
|
||||||
)
|
# only warm up if search settings were changed
|
||||||
|
warm_up_bi_encoder(
|
||||||
|
embedding_model=embedding_model,
|
||||||
|
)
|
||||||
|
|
||||||
cc_pair_ids: list[int] = []
|
cc_pair_ids: list[int] = []
|
||||||
with get_session_with_tenant(tenant_id) as db_session:
|
with get_session_with_tenant(tenant_id) as db_session:
|
||||||
|
@ -14,7 +14,6 @@ from danswer.db.search_settings import get_secondary_search_settings
|
|||||||
from danswer.db.search_settings import update_search_settings_status
|
from danswer.db.search_settings import update_search_settings_status
|
||||||
from danswer.key_value_store.factory import get_kv_store
|
from danswer.key_value_store.factory import get_kv_store
|
||||||
from danswer.utils.logger import setup_logger
|
from danswer.utils.logger import setup_logger
|
||||||
from shared_configs.configs import MULTI_TENANT
|
|
||||||
|
|
||||||
|
|
||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
@ -23,7 +22,14 @@ logger = setup_logger()
|
|||||||
def check_index_swap(db_session: Session) -> SearchSettings | None:
|
def check_index_swap(db_session: Session) -> SearchSettings | None:
|
||||||
"""Get count of cc-pairs and count of successful index_attempts for the
|
"""Get count of cc-pairs and count of successful index_attempts for the
|
||||||
new model grouped by connector + credential, if it's the same, then assume
|
new model grouped by connector + credential, if it's the same, then assume
|
||||||
new index is done building. If so, swap the indices and expire the old one."""
|
new index is done building. If so, swap the indices and expire the old one.
|
||||||
|
|
||||||
|
Returns None if search settings did not change, or the old search settings if they
|
||||||
|
did change.
|
||||||
|
"""
|
||||||
|
|
||||||
|
old_search_settings = None
|
||||||
|
|
||||||
# Default CC-pair created for Ingestion API unused here
|
# Default CC-pair created for Ingestion API unused here
|
||||||
all_cc_pairs = get_connector_credential_pairs(db_session)
|
all_cc_pairs = get_connector_credential_pairs(db_session)
|
||||||
cc_pair_count = max(len(all_cc_pairs) - 1, 0)
|
cc_pair_count = max(len(all_cc_pairs) - 1, 0)
|
||||||
@ -43,9 +49,9 @@ def check_index_swap(db_session: Session) -> SearchSettings | None:
|
|||||||
|
|
||||||
if cc_pair_count == 0 or cc_pair_count == unique_cc_indexings:
|
if cc_pair_count == 0 or cc_pair_count == unique_cc_indexings:
|
||||||
# Swap indices
|
# Swap indices
|
||||||
now_old_search_settings = get_current_search_settings(db_session)
|
current_search_settings = get_current_search_settings(db_session)
|
||||||
update_search_settings_status(
|
update_search_settings_status(
|
||||||
search_settings=now_old_search_settings,
|
search_settings=current_search_settings,
|
||||||
new_status=IndexModelStatus.PAST,
|
new_status=IndexModelStatus.PAST,
|
||||||
db_session=db_session,
|
db_session=db_session,
|
||||||
)
|
)
|
||||||
@ -67,6 +73,6 @@ def check_index_swap(db_session: Session) -> SearchSettings | None:
|
|||||||
for cc_pair in all_cc_pairs:
|
for cc_pair in all_cc_pairs:
|
||||||
resync_cc_pair(cc_pair, db_session=db_session)
|
resync_cc_pair(cc_pair, db_session=db_session)
|
||||||
|
|
||||||
if MULTI_TENANT:
|
old_search_settings = current_search_settings
|
||||||
return now_old_search_settings
|
|
||||||
return None
|
return old_search_settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user