Skip to content

Commit 4bdf174

Browse files
woopthirteen37
andauthored
Python SDK enhancements (#264)
* Python SDK enhancements * Refactor CLI * Support additional types with tests * Improve YAML loading * Improve List type performance * Fix bug with source handling * Improve exception handling * Update Version check for Feast Serving and fix type for get_feature_set * Add more "happy path" unit tests to Python Client * Fixed type in docs * Add docs, exception handling, and clean up Feast client * Add Optional to max_age of feature set Co-Authored-By: Yu-Xi Lim <thirteen37@users.noreply.github.com>
1 parent 56f6aba commit 4bdf174

17 files changed

Lines changed: 1088 additions & 599 deletions

sdk/python/cli.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
import click
1818
from feast import config as feast_config
1919
from feast.client import Client
20+
from feast.resource import ResourceFactory
2021
from feast.feature_set import FeatureSet
2122
import toml
2223
import pkg_resources
23-
from feast import resource
24+
from feast.utils import loaders
2425
import yaml
2526
import json
2627

@@ -131,8 +132,7 @@ def list():
131132
List all feature sets
132133
"""
133134
feast_client = Client(
134-
core_url=feast_config.get_config_property_or_fail("core_url"),
135-
serving_url=feast_config.get_config_property_or_fail("serving_url"),
135+
core_url=feast_config.get_config_property_or_fail("core_url")
136136
) # type: Client
137137

138138
for fs in feast_client.list_feature_sets():
@@ -146,8 +146,7 @@ def create(name):
146146
Create a feature set
147147
"""
148148
feast_client = Client(
149-
core_url=feast_config.get_config_property_or_fail("core_url"),
150-
serving_url=feast_config.get_config_property_or_fail("serving_url"),
149+
core_url=feast_config.get_config_property_or_fail("core_url")
151150
) # type: Client
152151

153152
feast_client.apply(FeatureSet(name=name))
@@ -161,8 +160,7 @@ def describe(name, version):
161160
Describe a feature set
162161
"""
163162
feast_client = Client(
164-
core_url=feast_config.get_config_property_or_fail("core_url"),
165-
serving_url=feast_config.get_config_property_or_fail("serving_url"),
163+
core_url=feast_config.get_config_property_or_fail("core_url")
166164
) # type: Client
167165

168166
fs = feast_client.get_feature_set(name=name, version=version)
@@ -213,20 +211,20 @@ def ingest(name, version, filename, file_type):
213211
"--filename",
214212
"-f",
215213
help="Path to the configuration file that will be applied",
216-
type=click.File("r"),
214+
type=click.Path(exists=True),
217215
)
218216
def apply(filename):
219217
"""
220218
Apply a configuration to a resource by filename or stdin
221219
"""
222-
resources = []
223-
# resources can be divided by a separator of '---'
224-
for resource_yaml in filename.read().split("---"):
225-
resources.append(resource.from_yaml(resource_yaml))
220+
221+
resources = [
222+
ResourceFactory.get_resource(res_dict["kind"]).from_dict(res_dict)
223+
for res_dict in loaders.yaml_loader(filename)
224+
]
226225

227226
feast_client = Client(
228-
core_url=feast_config.get_config_property_or_fail("core_url"),
229-
serving_url=feast_config.get_config_property_or_fail("serving_url"),
227+
core_url=feast_config.get_config_property_or_fail("core_url")
230228
) # type: Client
231229

232230
feast_client.apply(resources)

0 commit comments

Comments
 (0)