Skip to content

Commit 25fd445

Browse files
icywang86ruiDan Choi
authored andcommitted
feature: add SageMaker FeatureStore support (aws#476) (aws#501) (aws#528)
1 parent 24aad93 commit 25fd445

File tree

13 files changed

+1808
-3
lines changed

13 files changed

+1808
-3
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def read_version():
4747
# Specific use case dependencies
4848
extras = {
4949
"analytics": ["pandas"],
50+
"feature-store": ["pandas"],
5051
"local": [
5152
"urllib3>=1.21.1,<1.26,!=1.25.0,!=1.25.1",
5253
"docker-compose>=1.25.2",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""The Feature Definitions for FeatureStore."""
14+
from __future__ import absolute_import
15+
16+
from enum import Enum
17+
from typing import Dict, Any
18+
19+
import attr
20+
21+
from sagemaker.feature_store.inputs import Config
22+
23+
24+
class FeatureTypeEnum(Enum):
25+
"""Enum of feature types."""
26+
27+
FRACTIONAL = "Fractional"
28+
INTEGRAL = "Integral"
29+
STRING = "String"
30+
31+
32+
@attr.s
33+
class FeatureDefinition(Config):
34+
"""Feature definition.
35+
36+
Attributes:
37+
feature_name (str): The name of the feature
38+
feature_type (FeatureTypeEnum): The type of the feature
39+
"""
40+
41+
feature_name: str = attr.ib()
42+
feature_type: FeatureTypeEnum = attr.ib()
43+
44+
def to_dict(self) -> Dict[str, Any]:
45+
"""Constructs a dictionary based on the attributes"""
46+
return Config.construct_dict(
47+
FeatureName=self.feature_name, FeatureType=self.feature_type.value
48+
)
49+
50+
51+
class FractionalFeatureDefinition(FeatureDefinition):
52+
"""Fractional feature definition.
53+
54+
Attributes:
55+
feature_name (str): The name of the feature
56+
feature_type (FeatureTypeEnum): A `FeatureTypeEnum.FRACTIONAL` type
57+
"""
58+
59+
def __init__(self, feature_name: str):
60+
"""Constructs an instance of FractionalFeatureDefinition.
61+
62+
Args:
63+
feature_name (str): the name of the feature.
64+
"""
65+
super(FractionalFeatureDefinition, self).__init__(feature_name, FeatureTypeEnum.FRACTIONAL)
66+
67+
68+
class IntegralFeatureDefinition(FeatureDefinition):
69+
"""Fractional feature definition.
70+
71+
Attributes:
72+
feature_name (str): the name of the feature.
73+
feature_type (FeatureTypeEnum): a `FeatureTypeEnum.INTEGRAL` type.
74+
"""
75+
76+
def __init__(self, feature_name: str):
77+
"""Constructs an instance of IntegralFeatureDefinition.
78+
79+
Args:
80+
feature_name (str): the name of the feature.
81+
"""
82+
super(IntegralFeatureDefinition, self).__init__(feature_name, FeatureTypeEnum.INTEGRAL)
83+
84+
85+
class StringFeatureDefinition(FeatureDefinition):
86+
"""Fractional feature definition.
87+
88+
Attributes:
89+
feature_name (str): the name of the feature.
90+
feature_type (FeatureTypeEnum): a `FeatureTypeEnum.STRING` type.
91+
"""
92+
93+
def __init__(self, feature_name: str):
94+
"""Constructs an instance of StringFeatureDefinition.
95+
96+
Args:
97+
feature_name (str): the name of the feature.
98+
"""
99+
super(StringFeatureDefinition, self).__init__(feature_name, FeatureTypeEnum.STRING)

0 commit comments

Comments
 (0)