fix: unique entity_value fallback to prevent bulk_create ignore_conflicts from skipping duplicates

This commit is contained in:
PM-pinou
2026-07-22 23:14:00 +08:00
parent c1db7ad7eb
commit 0d92a5a170
+4 -4
View File
@@ -986,10 +986,10 @@ def _run_clustering_pipeline(run, store, entity_ds_id, feature_columns, algorith
profiles = []
cr_cache = {}
for i, row in enumerate(df_umap.iter_rows(named=True)):
ev = str(row.get(ent_col, ''))
if not ev:
# Fallback: use row index when entity column is empty
ev = f'entity_{i}'
ev = str(row.get(ent_col, '')) or f'entity_{i}'
# Ensure uniqueness by appending row index when using fallback
if not row.get(ent_col, ''):
ev = f'{ev}_{i}'
lbl = labels_list[i] if i < len(labels_list) else -1
cache_key = f'{run.id}_{lbl}'
if cache_key not in cr_cache: