@@ -39,6 +39,87 @@ class FeatureTypeEnum(Enum):
3939 STRING = "String"
4040
4141
42+ class CollectionTypeEnum (Enum ):
43+ """Enum of collection types.
44+
45+ The collection type of a feature can be List, Set or Vector.
46+ """
47+
48+ LIST = "List"
49+ SET = "Set"
50+ VECTOR = "Vector"
51+
52+
53+ @attr .s
54+ class CollectionType (Config ):
55+ """Collection type and its configuration.
56+
57+ This initiates a collectiontype object where CollectionType is a subclass of Config.
58+
59+ Attributes:
60+ collection_type (CollectionTypeEnum): The type of the collection
61+ collection_config (Dict[str, Any]): The configuration for the collection.
62+ """
63+
64+ collection_type : CollectionTypeEnum = attr .ib ()
65+ collection_config : Dict [str , Any ] = attr .ib ()
66+
67+ def to_dict (self ) -> Dict [str , Any ]:
68+ """Construct a dictionary based on each attribute."""
69+ return Config .construct_dict (
70+ CollectionType = self .collection_type .value , CollectionConfig = self .collection_config
71+ )
72+
73+
74+ class ListCollectionType (CollectionType ):
75+ """List collection type
76+
77+ This class instantiates a ListCollectionType object, as subclass of CollectionType
78+ where the collection type is defined as List.
79+
80+ """
81+
82+ def __init__ (self ):
83+ """Construct an instance of ListCollectionType."""
84+ super (ListCollectionType , self ).__init__ (CollectionTypeEnum .LIST , None )
85+
86+
87+ class SetCollectionType (CollectionType ):
88+ """Set collection type
89+
90+ This class instantiates a SetCollectionType object, as subclass of CollectionType
91+ where the collection type is defined as Set.
92+
93+ """
94+
95+ def __init__ (self ):
96+ """Construct an instance of SetCollectionType."""
97+ super (SetCollectionType , self ).__init__ (CollectionTypeEnum .SET , None )
98+
99+
100+ class VectorCollectionType (CollectionType ):
101+ """Vector collection type
102+
103+ This class instantiates a VectorCollectionType object, as subclass of CollectionType
104+ where the collection type is defined as Vector.
105+
106+ Attributes:
107+ dimension (int): The dimension size for the Vector.
108+ """
109+
110+ def __init__ (self , dimension : int ):
111+ """Construct an instance of VectorCollectionType.
112+
113+ Attributes:
114+ dimension (int): The dimension size for the Vector.
115+ """
116+ collection_config : Dict [str , Any ] = {}
117+ vector_config : Dict [str , Any ] = {}
118+ vector_config ["Dimension" ] = dimension
119+ collection_config ["VectorConfig" ] = vector_config
120+ super (VectorCollectionType , self ).__init__ (CollectionTypeEnum .VECTOR , collection_config )
121+
122+
42123@attr .s
43124class FeatureDefinition (Config ):
44125 """Feature definition.
@@ -48,15 +129,25 @@ class FeatureDefinition(Config):
48129 Attributes:
49130 feature_name (str): The name of the feature
50131 feature_type (FeatureTypeEnum): The type of the feature
132+ collection_type (CollectionType): The type of collection for the feature
51133 """
52134
53135 feature_name : str = attr .ib ()
54136 feature_type : FeatureTypeEnum = attr .ib ()
137+ collection_type : CollectionType = attr .ib (default = None )
55138
56139 def to_dict (self ) -> Dict [str , Any ]:
57140 """Construct a dictionary based on each attribute."""
141+
58142 return Config .construct_dict (
59- FeatureName = self .feature_name , FeatureType = self .feature_type .value
143+ FeatureName = self .feature_name ,
144+ FeatureType = self .feature_type .value ,
145+ CollectionType = (
146+ self .collection_type .collection_type .value if self .collection_type else None
147+ ),
148+ CollectionConfig = (
149+ self .collection_type .collection_config if self .collection_type else None
150+ ),
60151 )
61152
62153
@@ -69,15 +160,18 @@ class FractionalFeatureDefinition(FeatureDefinition):
69160 Attributes:
70161 feature_name (str): The name of the feature
71162 feature_type (FeatureTypeEnum): A `FeatureTypeEnum.FRACTIONAL` type
163+ collection_type (CollectionType): The type of collection for the feature
72164 """
73165
74- def __init__ (self , feature_name : str ):
166+ def __init__ (self , feature_name : str , collection_type : CollectionType = None ):
75167 """Construct an instance of FractionalFeatureDefinition.
76168
77169 Args:
78170 feature_name (str): the name of the feature.
79171 """
80- super (FractionalFeatureDefinition , self ).__init__ (feature_name , FeatureTypeEnum .FRACTIONAL )
172+ super (FractionalFeatureDefinition , self ).__init__ (
173+ feature_name , FeatureTypeEnum .FRACTIONAL , collection_type
174+ )
81175
82176
83177class IntegralFeatureDefinition (FeatureDefinition ):
@@ -89,15 +183,18 @@ class IntegralFeatureDefinition(FeatureDefinition):
89183 Attributes:
90184 feature_name (str): the name of the feature.
91185 feature_type (FeatureTypeEnum): a `FeatureTypeEnum.INTEGRAL` type.
186+ collection_type (CollectionType): The type of collection for the feature.
92187 """
93188
94- def __init__ (self , feature_name : str ):
189+ def __init__ (self , feature_name : str , collection_type : CollectionType = None ):
95190 """Construct an instance of IntegralFeatureDefinition.
96191
97192 Args:
98193 feature_name (str): the name of the feature.
99194 """
100- super (IntegralFeatureDefinition , self ).__init__ (feature_name , FeatureTypeEnum .INTEGRAL )
195+ super (IntegralFeatureDefinition , self ).__init__ (
196+ feature_name , FeatureTypeEnum .INTEGRAL , collection_type
197+ )
101198
102199
103200class StringFeatureDefinition (FeatureDefinition ):
@@ -109,12 +206,15 @@ class StringFeatureDefinition(FeatureDefinition):
109206 Attributes:
110207 feature_name (str): the name of the feature.
111208 feature_type (FeatureTypeEnum): a `FeatureTypeEnum.STRING` type.
209+ collection_type (CollectionType): The type of collection for the feature.
112210 """
113211
114- def __init__ (self , feature_name : str ):
212+ def __init__ (self , feature_name : str , collection_type : CollectionType = None ):
115213 """Construct an instance of StringFeatureDefinition.
116214
117215 Args:
118216 feature_name (str): the name of the feature.
119217 """
120- super (StringFeatureDefinition , self ).__init__ (feature_name , FeatureTypeEnum .STRING )
218+ super (StringFeatureDefinition , self ).__init__ (
219+ feature_name , FeatureTypeEnum .STRING , collection_type
220+ )
0 commit comments