Skip to content

Commit

Permalink
Python SDK enhancements (#264)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
woop and thirteen37 authored Oct 22, 2019
1 parent 56f6aba commit 4bdf174
Show file tree
Hide file tree
Showing 17 changed files with 1,088 additions and 599 deletions.
File renamed without changes.
26 changes: 12 additions & 14 deletions sdk/python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import click
from feast import config as feast_config
from feast.client import Client
from feast.resource import ResourceFactory
from feast.feature_set import FeatureSet
import toml
import pkg_resources
from feast import resource
from feast.utils import loaders
import yaml
import json

Expand Down Expand Up @@ -131,8 +132,7 @@ def list():
List all feature sets
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url"),
serving_url=feast_config.get_config_property_or_fail("serving_url"),
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client

for fs in feast_client.list_feature_sets():
Expand All @@ -146,8 +146,7 @@ def create(name):
Create a feature set
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url"),
serving_url=feast_config.get_config_property_or_fail("serving_url"),
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client

feast_client.apply(FeatureSet(name=name))
Expand All @@ -161,8 +160,7 @@ def describe(name, version):
Describe a feature set
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url"),
serving_url=feast_config.get_config_property_or_fail("serving_url"),
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client

fs = feast_client.get_feature_set(name=name, version=version)
Expand Down Expand Up @@ -213,20 +211,20 @@ def ingest(name, version, filename, file_type):
"--filename",
"-f",
help="Path to the configuration file that will be applied",
type=click.File("r"),
type=click.Path(exists=True),
)
def apply(filename):
"""
Apply a configuration to a resource by filename or stdin
"""
resources = []
# resources can be divided by a separator of '---'
for resource_yaml in filename.read().split("---"):
resources.append(resource.from_yaml(resource_yaml))

resources = [
ResourceFactory.get_resource(res_dict["kind"]).from_dict(res_dict)
for res_dict in loaders.yaml_loader(filename)
]

feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url"),
serving_url=feast_config.get_config_property_or_fail("serving_url"),
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client

feast_client.apply(resources)
Expand Down
Loading

0 comments on commit 4bdf174

Please # to comment.