Skip to content

Commit

Permalink
Update cli with project-related commands (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Zhiling authored and feast-ci-bot committed Dec 30, 2019
1 parent 0fcf08e commit 9761ccb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
62 changes: 56 additions & 6 deletions sdk/python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def feature_set():
pass


@feature_set.command()
def list():
@feature_set.command(name="list")
def feature_set_list():
"""
List all feature sets
"""
Expand All @@ -147,9 +147,9 @@ def list():
print(tabulate(table, headers=["NAME", "VERSION"], tablefmt="plain"))


@feature_set.command()
@feature_set.command("create")
@click.argument("name")
def create(name):
def feature_set_create(name):
"""
Create a feature set
"""
Expand All @@ -160,10 +160,10 @@ def create(name):
feast_client.apply(FeatureSet(name=name))


@feature_set.command()
@feature_set.command("describe")
@click.argument("name", type=click.STRING)
@click.argument("version", type=click.INT)
def describe(name: str, version: int):
def feature_set_describe(name: str, version: int):
"""
Describe a feature set
"""
Expand All @@ -181,6 +181,56 @@ def describe(name: str, version: int):
print(yaml.dump(yaml.safe_load(str(fs)), default_flow_style=False, sort_keys=False))


@cli.group(name="projects")
def project():
"""
Create and manage projects
"""
pass


@project.command(name="create")
@click.argument("name", type=click.STRING)
def project_create(name: str):
"""
Create a project
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client
feast_client.create_project(name)


@project.command(name="archive")
@click.argument("name", type=click.STRING)
def project_archive(name: str):
"""
Archive a project
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client
feast_client.archive_project(name)


@project.command(name="list")
def feature_set_list():
"""
List all projects
"""
feast_client = Client(
core_url=feast_config.get_config_property_or_fail("core_url")
) # type: Client

table = []
for project in feast_client.list_projects():
table.append([project])

from tabulate import tabulate

print(tabulate(table, headers=["NAME"], tablefmt="plain"))


@cli.command()
@click.option(
"--name", "-n", help="Feature set name to ingest data into", required=True
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def list_projects(self) -> List[str]:
) # type: ListProjectsResponse
return list(response.projects)

def create_project(self, project):
def create_project(self, project: str):
"""
Creates a Feast project
Expand Down

0 comments on commit 9761ccb

Please sign in to comment.