Skip to content

Commit b0db50c

Browse files
sfc-gh-madkinsadchia
authored andcommitted
feat: Allow all snowflake python connector connection methods to be available to Feast (#2356)
* Allow all snowflake python connector connection methods to be available to feast Signed-off-by: Miles Adkins <miles.adkins@snowflake.com> * format/lint Signed-off-by: Miles Adkins <miles.adkins@snowflake.com> * feat: have feast using snowflake python connector for authentication Signed-off-by: Miles Adkins <miles.adkins@snowflake.com> * fix random print Signed-off-by: Miles Adkins <miles.adkins@snowflake.com>
1 parent 6ff6c96 commit b0db50c

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

sdk/python/feast/entity.py

+12-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import warnings
1514
from datetime import datetime
1615
from typing import Dict, Optional
1716

@@ -45,7 +44,7 @@ class Entity:
4544
value_type: ValueType
4645
join_key: str
4746
description: str
48-
tags: Dict[str, str]
47+
labels: Dict[str, str]
4948
owner: str
5049
created_timestamp: Optional[datetime]
5150
last_updated_timestamp: Optional[datetime]
@@ -65,17 +64,10 @@ def __init__(
6564
self.join_key = join_key if join_key else name
6665
self.description = description
6766

68-
if labels is not None:
69-
self.tags = labels
70-
warnings.warn(
71-
(
72-
"The parameter 'labels' is being deprecated. Please use 'tags' instead. "
73-
"Feast 0.20 and onwards will not support the parameter 'labels'."
74-
),
75-
DeprecationWarning,
76-
)
67+
if labels is None:
68+
self.labels = dict()
7769
else:
78-
self.tags = labels or tags or {}
70+
self.labels = labels
7971

8072
self.created_timestamp = None
8173
self.last_updated_timestamp = None
@@ -163,9 +155,9 @@ def from_proto(cls, entity_proto: EntityV2Proto):
163155
)
164156

165157
if entity_proto.meta.HasField("created_timestamp"):
166-
entity._created_timestamp = entity_proto.meta.created_timestamp.ToDatetime()
158+
entity.created_timestamp = entity_proto.meta.created_timestamp.ToDatetime()
167159
if entity_proto.meta.HasField("last_updated_timestamp"):
168-
entity._last_updated_timestamp = (
160+
entity.last_updated_timestamp = (
169161
entity_proto.meta.last_updated_timestamp.ToDatetime()
170162
)
171163

@@ -179,10 +171,10 @@ def to_proto(self) -> EntityV2Proto:
179171
An EntityV2Proto protobuf.
180172
"""
181173
meta = EntityMetaProto()
182-
if self._created_timestamp:
183-
meta.created_timestamp.FromDatetime(self._created_timestamp)
184-
if self._last_updated_timestamp:
185-
meta.last_updated_timestamp.FromDatetime(self._last_updated_timestamp)
174+
if self.created_timestamp:
175+
meta.created_timestamp.FromDatetime(self.created_timestamp)
176+
if self.last_updated_timestamp:
177+
meta.last_updated_timestamp.FromDatetime(self.last_updated_timestamp)
186178

187179
spec = EntitySpecProto(
188180
name=self.name,
@@ -249,5 +241,5 @@ def _update_from_entity(self, entity):
249241
self.value_type = entity.value_type
250242
self.labels = entity.labels
251243
self.join_key = entity.join_key
252-
self._created_timestamp = entity.created_timestamp
253-
self._last_updated_timestamp = entity.last_updated_timestamp
244+
self.created_timestamp = entity.created_timestamp
245+
self.last_updated_timestamp = entity.last_updated_timestamp

sdk/python/feast/feature_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FeatureService:
3232

3333
name: str
3434
feature_view_projections: List[FeatureViewProjection]
35-
description: str
35+
description: Optional[str] = None
3636
tags: Dict[str, str]
3737
created_timestamp: Optional[datetime] = None
3838
last_updated_timestamp: Optional[datetime] = None

sdk/python/feast/infra/utils/snowflake_utils.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,27 @@ def get_snowflake_conn(config, autocommit=True) -> SnowflakeConnection:
4343
if config.type == "snowflake.offline":
4444
config_header = "connections.feast_offline_store"
4545

46-
config = dict(config)
46+
config_dict = dict(config)
4747

4848
# read config file
4949
config_reader = configparser.ConfigParser()
50-
config_reader.read([config["config_path"]])
50+
config_reader.read([config_dict["config_path"]])
5151
if config_reader.has_section(config_header):
5252
kwargs = dict(config_reader[config_header])
5353
else:
5454
kwargs = {}
5555

56-
kwargs.update((k, v) for k, v in config.items() if v is not None)
56+
kwargs.update((k, v) for k, v in config_dict.items() if v is not None)
57+
[
58+
kwargs.update({k: '"' + v + '"'})
59+
for k, v in kwargs.items()
60+
if k in ["role", "warehouse", "database", "schema_"]
61+
]
62+
kwargs["schema"] = kwargs.pop("schema_")
5763

5864
try:
5965
conn = snowflake.connector.connect(
60-
account=kwargs["account"],
61-
user=kwargs["user"],
62-
password=kwargs["password"],
63-
role=f'''"{kwargs['role']}"''',
64-
warehouse=f'''"{kwargs['warehouse']}"''',
65-
database=f'''"{kwargs['database']}"''',
66-
schema=f'''"{kwargs['schema_']}"''',
67-
application="feast",
68-
autocommit=autocommit,
66+
application="feast", autocommit=autocommit, **kwargs
6967
)
7068

7169
return conn

0 commit comments

Comments
 (0)