Skip to content

Commit 833d495

Browse files
woopfeast-ci-bot
authored andcommitted
Remove "resource" concept and the need to specify a kind in feature sets (feast-dev#432)
1 parent 2a33f7b commit 833d495

6 files changed

Lines changed: 19 additions & 48 deletions

File tree

infra/docker-compose/docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ services:
5959

6060
redis:
6161
image: redis:5-alpine
62+
ports:
63+
- "6379:6379"
6264

6365
kafka:
6466
image: confluentinc/cp-kafka:5.2.1
@@ -70,7 +72,8 @@ services:
7072
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
7173
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
7274
ports:
73-
- 9094:9092
75+
- "9092:9092"
76+
- "9094:9094"
7477

7578
depends_on:
7679
- zookeeper

sdk/__init__.py

Whitespace-only changes.

sdk/python/feast/cli.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import click
1818
from feast import config as feast_config
1919
from feast.client import Client
20-
from feast.resource import ResourceFactory
2120
from feast.feature_set import FeatureSet
2221
import toml
2322
import pkg_resources
@@ -147,17 +146,25 @@ def feature_set_list():
147146
print(tabulate(table, headers=["NAME", "VERSION"], tablefmt="plain"))
148147

149148

150-
@feature_set.command("create")
151-
@click.argument("name")
152-
def feature_set_create(name):
149+
@feature_set.command("apply")
150+
@click.option(
151+
"--filename",
152+
"-f",
153+
help="Path to a feature set configuration file that will be applied",
154+
type=click.Path(exists=True),
155+
)
156+
def feature_set_create(filename):
153157
"""
154-
Create a feature set
158+
Create or update a feature set
155159
"""
160+
161+
feature_sets = [FeatureSet.from_dict(fs_dict) for fs_dict in yaml_loader(filename)]
162+
156163
feast_client = Client(
157164
core_url=feast_config.get_config_property_or_fail("core_url")
158165
) # type: Client
159166

160-
feast_client.apply(FeatureSet(name=name))
167+
feast_client.apply(feature_sets)
161168

162169

163170
@feature_set.command("describe")
@@ -264,29 +271,5 @@ def ingest(name, version, filename, file_type):
264271
feature_set.ingest_file(file_path=filename)
265272

266273

267-
@cli.command()
268-
@click.option(
269-
"--filename",
270-
"-f",
271-
help="Path to the configuration file that will be applied",
272-
type=click.Path(exists=True),
273-
)
274-
def apply(filename):
275-
"""
276-
Apply a configuration to a resource by filename or stdin
277-
"""
278-
279-
resources = [
280-
ResourceFactory.get_resource(res_dict["kind"]).from_dict(res_dict)
281-
for res_dict in yaml_loader(filename)
282-
]
283-
284-
feast_client = Client(
285-
core_url=feast_config.get_config_property_or_fail("core_url")
286-
) # type: Client
287-
288-
feast_client.apply(resources)
289-
290-
291274
if __name__ == "__main__":
292275
cli()

sdk/python/feast/feature_set.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,6 @@ def from_dict(cls, fs_dict):
689689
Returns a FeatureSet object based on the feature set dict
690690
"""
691691

692-
if ("kind" not in fs_dict) and (fs_dict["kind"].strip() != "feature_set"):
693-
raise Exception(f"Resource kind is not a feature set {str(fs_dict)}")
694692
feature_set_proto = json_format.ParseDict(
695693
fs_dict, FeatureSetProto(), ignore_unknown_fields=True
696694
)

sdk/python/feast/loaders/yaml.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_yaml_contents(yml: str) -> str:
5353
with open(yml, "r") as f:
5454
yml_content = f.read()
5555

56-
elif isinstance(yml, str) and "kind" in yml.lower():
56+
elif isinstance(yml, str):
5757
yml_content = yml
5858
else:
5959
raise Exception(
@@ -73,7 +73,4 @@ def _yaml_to_dict(yaml_string):
7373
Dictionary containing the same object
7474
"""
7575

76-
yaml_dict = yaml.safe_load(yaml_string)
77-
if not isinstance(yaml_dict, dict) or not "kind" in yaml_dict:
78-
raise Exception(f"Could not detect YAML kind from resource: ${yaml_string}")
79-
return yaml_dict
76+
return yaml.safe_load(yaml_string)

sdk/python/feast/resource.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)