Deep copy txt units on local search to avoid race conditions (#1118)

* Deep copy txt units on local search to avoid race conditions

* Format
This commit is contained in:
Alonso Guevara 2024-09-11 14:12:03 -06:00 committed by GitHub
parent e7ee8cb8a5
commit cdf5fc4d67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Deep copy txt units on local search to avoid race conditions"
}

View File

@ -3,6 +3,7 @@
"""Algorithms to build context data for local search prompt."""
import logging
from copy import deepcopy
from typing import Any
import pandas as pd
@ -319,7 +320,7 @@ class LocalSearchMixedContext(LocalContextBuilder):
for text_id in entity.text_unit_ids or []:
if text_id not in text_unit_ids_set and text_id in self.text_units:
text_unit_ids_set.add(text_id)
selected_unit = self.text_units[text_id]
selected_unit = deepcopy(self.text_units[text_id])
num_relationships = count_relationships(
selected_unit, entity, self.relationships
)