fix: make all entity_values unique by appending row index to support bulk_create with ignore_conflicts

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