@@ -587,3 +587,39 @@ class EntityB2:
587
587
# This might require to store the (Python) model in the Store.
588
588
# with pytest.raises(ValueError):
589
589
# store_b.box(EntityA)
590
+ def test_sync_dynamic_entities (env ):
591
+ def create_entity (entity_name : str , dimensions : int , distance_type : VectorDistanceType , uid = 0 ):
592
+ DynamicEntity = type (entity_name , (), {
593
+ "id" : Id (),
594
+ "name" : String (),
595
+ "vector" : Float32Vector (index = HnswIndex (dimensions = dimensions , distance_type = distance_type ))
596
+ })
597
+ return Entity (uid = uid )(DynamicEntity ) # Apply @Entity decorator
598
+
599
+ CosineVectorEntity = create_entity ("CosineVectorEntity" ,
600
+ dimensions = 2 ,
601
+ distance_type = VectorDistanceType .COSINE )
602
+ EuclideanVectorEntity = create_entity ("EuclideanVectorEntity" ,
603
+ dimensions = 2 ,
604
+ distance_type = VectorDistanceType .EUCLIDEAN )
605
+ DotProductEntity = create_entity ("DotProductEntity" ,
606
+ dimensions = 2 ,
607
+ distance_type = VectorDistanceType .DOT_PRODUCT_NON_NORMALIZED )
608
+ model = Model ()
609
+ model .entity (CosineVectorEntity )
610
+ model .entity (EuclideanVectorEntity )
611
+ model .entity (DotProductEntity )
612
+ assert env .sync (model )
613
+ CosineVectorEntity_iduid = CosineVectorEntity ._iduid
614
+
615
+ # Rename CosineVectorEntity to MyCosineVectorEntity
616
+ MyCosineVectorEntity = create_entity ("MyCosineVectorEntity" ,
617
+ dimensions = 2 ,
618
+ distance_type = VectorDistanceType .COSINE ,
619
+ uid = CosineVectorEntity_iduid .uid )
620
+ model = Model ()
621
+ model .entity (MyCosineVectorEntity )
622
+ model .entity (EuclideanVectorEntity )
623
+ model .entity (DotProductEntity )
624
+ assert env .sync (model )
625
+ assert CosineVectorEntity_iduid == MyCosineVectorEntity ._iduid
0 commit comments