Skip to content

Commit 95d1e50

Browse files
authored
Merge branch 'master' into master
2 parents 698e4fc + f631e41 commit 95d1e50

File tree

10 files changed

+481
-18
lines changed

10 files changed

+481
-18
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v2.190.0 (2023-10-04)
4+
5+
### Features
6+
7+
* Add support for in-memory feature groups and collection type features in Feature Store.
8+
9+
### Bug Fixes and Other Changes
10+
11+
* chore: xfail resource in use failure for specific test
12+
* Add missing API docs for processors
13+
14+
### Documentation Changes
15+
16+
* Bring back (de)serializers documentation
17+
* Add missing AirFlow operators + link to airflow documentation
18+
319
## v2.189.0 (2023-10-03)
420

521
### Features

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.189.1.dev0
1+
2.190.1.dev0

doc/api/prep_data/feature_store.rst

+23
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ Feature Definition
4141
:members:
4242
:show-inheritance:
4343

44+
.. autoclass:: sagemaker.feature_store.feature_definition.CollectionTypeEnum
45+
:members:
46+
:show-inheritance:
47+
48+
.. autoclass:: sagemaker.feature_store.feature_definition.CollectionType
49+
:members:
50+
:show-inheritance:
51+
52+
.. autoclass:: sagemaker.feature_store.feature_definition.ListCollectionType
53+
:members:
54+
:show-inheritance:
55+
56+
.. autoclass:: sagemaker.feature_store.feature_definition.SetCollectionType
57+
:members:
58+
:show-inheritance:
59+
60+
.. autoclass:: sagemaker.feature_store.feature_definition.VectorCollectionType
61+
:members:
62+
:show-inheritance:
4463

4564
Inputs
4665
******
@@ -77,6 +96,10 @@ Inputs
7796
:members:
7897
:show-inheritance:
7998

99+
.. autoclass:: sagemaker.feature_store.inputs.OnlineStoreStorageTypeEnum
100+
:members:
101+
:show-inheritance:
102+
80103
.. autoclass:: sagemaker.feature_store.inputs.ResourceEnum
81104
:members:
82105
:show-inheritance:

src/sagemaker/feature_store/feature_definition.py

+107-7
Original file line numberDiff line numberDiff line change
@@ -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
43124
class 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

83177
class 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

103200
class 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+
)

src/sagemaker/feature_store/feature_group.py

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
DeletionModeEnum,
6464
TtlDuration,
6565
OnlineStoreConfigUpdate,
66+
OnlineStoreStorageTypeEnum,
6667
)
6768
from sagemaker.utils import resolve_value_from_config
6869

@@ -539,6 +540,7 @@ def create(
539540
description: str = None,
540541
tags: List[Dict[str, str]] = None,
541542
table_format: TableFormatEnum = None,
543+
online_store_storage_type: OnlineStoreStorageTypeEnum = None,
542544
) -> Dict[str, Any]:
543545
"""Create a SageMaker FeatureStore FeatureGroup.
544546
@@ -566,6 +568,8 @@ def create(
566568
description (str): description of the FeatureGroup (default: None).
567569
tags (List[Dict[str, str]]): list of tags for labeling a FeatureGroup (default: None).
568570
table_format (TableFormatEnum): format of the offline store table (default: None).
571+
online_store_storage_type (OnlineStoreStorageTypeEnum): storage type for the
572+
online store (default: None).
569573
570574
Returns:
571575
Response dict from service.
@@ -606,6 +610,7 @@ def create(
606610
online_store_config = OnlineStoreConfig(
607611
enable_online_store=enable_online_store,
608612
ttl_duration=ttl_duration,
613+
storage_type=online_store_storage_type,
609614
)
610615
if online_store_kms_key_id is not None:
611616
online_store_config.online_store_security_config = OnlineStoreSecurityConfig(

src/sagemaker/feature_store/inputs.py

+16
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ def to_dict(self) -> Dict[str, Any]:
108108
)
109109

110110

111+
class OnlineStoreStorageTypeEnum(Enum):
112+
"""Enum of storage types for online store.
113+
114+
The online store storage types can be Standard or InMemory.
115+
"""
116+
117+
STANDARD = "Standard"
118+
IN_MEMORY = "InMemory"
119+
120+
111121
@attr.s
112122
class OnlineStoreConfig(Config):
113123
"""OnlineStoreConfig for FeatureStore.
@@ -121,6 +131,7 @@ class OnlineStoreConfig(Config):
121131
enable_online_store: bool = attr.ib(default=True)
122132
online_store_security_config: OnlineStoreSecurityConfig = attr.ib(default=None)
123133
ttl_duration: TtlDuration = attr.ib(default=None)
134+
storage_type: OnlineStoreStorageTypeEnum = attr.ib(default=None)
124135

125136
def to_dict(self) -> Dict[str, Any]:
126137
"""Construct a dictionary based on the attributes.
@@ -132,6 +143,7 @@ def to_dict(self) -> Dict[str, Any]:
132143
EnableOnlineStore=self.enable_online_store,
133144
SecurityConfig=self.online_store_security_config,
134145
TtlDuration=self.ttl_duration,
146+
StorageType=self.storage_type.value if self.storage_type else None,
135147
)
136148

137149

@@ -254,10 +266,13 @@ class FeatureValue(Config):
254266
Attributes:
255267
feature_name (str): name of the Feature.
256268
value_as_string (str): value of the Feature in string form.
269+
value_as_string_list (List[str]): value of the Feature in string list
270+
form used for collection type.
257271
"""
258272

259273
feature_name: str = attr.ib(default=None)
260274
value_as_string: str = attr.ib(default=None)
275+
value_as_string_list: List[str] = attr.ib(default=None)
261276

262277
def to_dict(self) -> Dict[str, Any]:
263278
"""Construct a dictionary based on the attributes provided.
@@ -268,6 +283,7 @@ def to_dict(self) -> Dict[str, Any]:
268283
return Config.construct_dict(
269284
FeatureName=self.feature_name,
270285
ValueAsString=self.value_as_string,
286+
ValueAsStringList=self.value_as_string_list,
271287
)
272288

273289

0 commit comments

Comments
 (0)