Skip to content

Commit 686a55c

Browse files
feat(cli): add 'feast projects delete' command (issue 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 an interactive confirmation prompt that can be bypassed with --yes/-y for scripted workflows. - Adds type guard (`assert store._registry is not None`) for mypy. - Catches both FeastObjectNotFoundException and ProjectNotFoundException so the CLI exits cleanly (exit code 1) for either variant raised by concrete registry implementations. Squashed history: this commit consolidates the previous unsigned commits on the branch into a single DCO-signed commit, per DCO requirements. Signed-off-by: Venkateswarlu Boggavarapu <[email protected]>
1 parent e1b1d2d commit 686a55c

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

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

Lines changed: 44 additions & 7 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(
@@ -58,7 +57,7 @@ def project_current(ctx: click.Context):
5857
)
5958

6059

61-
@projects_cmd.command(name="list")
60+
@projects_cmd.command("list")
6261
@tagsOption
6362
@click.pass_context
6463
def project_list(ctx: click.Context, tags: list[str]):
@@ -75,6 +74,44 @@ def project_list(ctx: click.Context, tags: list[str]):
7574

7675
print(
7776
tabulate(
78-
table, headers=["NAME", "DESCRIPTION", "TAGS", "OWNER"], tablefmt="plain"
77+
table,
78+
headers=["NAME", "DESCRIPTION", "TAGS", "OWNER"],
79+
tablefmt="plain",
7980
)
8081
)
82+
83+
84+
@projects_cmd.command("delete")
85+
@click.argument("name", type=click.STRING)
86+
@click.option(
87+
"--yes",
88+
"-y",
89+
is_flag=True,
90+
help="Skip confirmation prompt and delete immediately.",
91+
)
92+
@click.pass_context
93+
def project_delete(ctx: click.Context, name: str, yes: bool):
94+
"""
95+
Delete a project and all its resources from the registry.
96+
97+
This removes the project entry from the registry. Individual objects
98+
(feature views, entities, data sources) that belong to the project
99+
are also purged when commit=True (the default).
100+
"""
101+
store = create_feature_store(ctx)
102+
103+
if not yes:
104+
click.confirm(
105+
f"Are you sure you want to delete project '{name}'? "
106+
"This will remove all associated resources from the registry.",
107+
abort=True,
108+
)
109+
110+
try:
111+
assert store._registry is not None
112+
store._registry.delete_project(name, commit=True)
113+
except (FeastObjectNotFoundException, ProjectNotFoundException) as e:
114+
print(str(e))
115+
raise SystemExit(1)
116+
117+
print(f"Project '{name}' deleted successfully.")

0 commit comments

Comments
 (0)