Skip to main content

agrag.ingestion.merge.select_canonical

select_canonical(entities:list[Entity], entity_type:EntityType | None) -> tuple[Entity, list[Entity]]

Return the canonical entity and the rest, from two or more entities.

Schema-completeness (fewest missing declared fields) first, then earliest created_at, then lexicographically smallest id.

Parameters:

  • entities (list[Entity]) – The entities to choose from.
  • entity_type (EntityType | None) – The schema type for this label, if declared.

Returns:

  • tuple[Entity, list[Entity]] – The canonical entity and the other entities.