Skip to content

Commit acdf7e3

Browse files
mailtoboggavarapu-coderntkathole
authored andcommitted
feat(cli): Add feast projects delete command (closes feast-dev#5095)
Exposes project deletion via the CLI. The new `feast projects delete <name>` command calls store.registry.delete_project() which is already implemented in all concrete registries. - Adds interactive confirmation prompt with --yes/-y flag for scripting - Catches both FeastObjectNotFoundException and ProjectNotFoundException - Exits with code 1 for non-existent projects Signed-off-by: Venkateswarlu Boggavarapu <[email protected]>
1 parent 50ad181 commit acdf7e3

1 file changed

Lines changed: 43 additions & 28 deletions

File tree

‎sdk/python/feast/cli/projects.py‎

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33

44
from feast import utils
55
from feast.cli.cli_options import tagsOption
6-
from feast.errors import FeastObjectNotFoundException
6+
from feast.errors import FeastObjectNotFoundException, ProjectNotFoundException
77
from feast.repo_operations import create_feature_store
88

99

1010
@click.group(name="projects")
1111
def projects_cmd():
1212
"""
13-
Access projects
13+
Access and manage projects
1414
"""
15-
pass
1615

1716

1817
@projects_cmd.command("describe")
@@ -27,8 +26,8 @@ def project_describe(ctx: click.Context, name: str):
2726
try:
2827
project = store.get_project(name)
2928
except FeastObjectNotFoundException as e:
30-
print(e)
31-
exit(1)
29+
print(str(e))
30+
raise SystemExit(1)
3231

3332
print(
3433
yaml.dump(
@@ -41,40 +40,56 @@ def project_describe(ctx: click.Context, name: str):
4140
@click.pass_context
4241
def project_current(ctx: click.Context):
4342
"""
44-
Returns the current project configured with FeatureStore object
43+
Returns the current project configured with FeatureStore
4544
"""
4645
store = create_feature_store(ctx)
47-
48-
try:
49-
project = store.get_project(name=None)
50-
except FeastObjectNotFoundException as e:
51-
print(e)
52-
exit(1)
53-
54-
print(
55-
yaml.dump(
56-
yaml.safe_load(str(project)), default_flow_style=False, sort_keys=False
57-
)
58-
)
46+
print(store.project)
5947

6048

61-
@projects_cmd.command(name="list")
49+
@projects_cmd.command("list")
6250
@tagsOption
6351
@click.pass_context
6452
def project_list(ctx: click.Context, tags: list[str]):
6553
"""
6654
List all projects
6755
"""
6856
store = create_feature_store(ctx)
69-
table = []
70-
tags_filter = utils.tags_list_to_dict(tags)
71-
for project in store.list_projects(tags=tags_filter):
72-
table.append([project.name, project.description, project.tags, project.owner])
7357

74-
from tabulate import tabulate
58+
projects = store.list_projects(
59+
tags=dict(tag.split(":", 1) for tag in tags),
60+
)
7561

76-
print(
77-
tabulate(
78-
table, headers=["NAME", "DESCRIPTION", "TAGS", "OWNER"], tablefmt="plain"
62+
for project in projects:
63+
print(utils.py_object_to_proto(project).name)
64+
65+
66+
@projects_cmd.command("delete")
67+
@click.argument("name", type=click.STRING)
68+
@click.option(
69+
"-y",
70+
"--yes",
71+
is_flag=True,
72+
default=False,
73+
help="Skip confirmation prompt and delete immediately.",
74+
)
75+
@click.pass_context
76+
def project_delete(ctx: click.Context, name: str, yes: bool):
77+
"""
78+
Delete a project and all its resources from the registry.
79+
"""
80+
store = create_feature_store(ctx)
81+
82+
if not yes:
83+
click.confirm(
84+
f"Are you sure you want to delete project '{name}'? "
85+
"This will remove all associated resources from the registry.",
86+
abort=True,
7987
)
80-
)
88+
89+
try:
90+
store.registry.delete_project(name, commit=True)
91+
except (FeastObjectNotFoundException, ProjectNotFoundException) as e:
92+
print(str(e))
93+
raise SystemExit(1)
94+
95+
print(f"Project '{name}' deleted successfully.")

0 commit comments

Comments
 (0)