Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions sdk/python/feast/cli/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@ def project_current(ctx: click.Context):
)


@projects_cmd.command("delete")
@click.argument("name", type=click.STRING)
@click.option(
"--yes",
"-y",
is_flag=True,
default=False,
help="Skip confirmation prompt.",
)
@click.pass_context
def project_delete(ctx: click.Context, name: str, yes: bool):
"""
Delete a project and all its registered objects.
"""
store = create_feature_store(ctx)

try:
store.get_project(name)
except FeastObjectNotFoundException as e:
print(e)
exit(1)

if not yes:
click.confirm(
f"This will permanently delete project '{name}' and all its registered objects. Are you sure?",
abort=True,
)

store.delete_project(name)
print(f"Project '{name}' successfully deleted.")


@projects_cmd.command(name="list")
@tagsOption
@click.pass_context
Expand Down
13 changes: 13 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,19 @@ def get_project(self, name: Optional[str]) -> Project:
"""
return self.registry.get_project(name or self.project)

def delete_project(self, name: str, commit: bool = True) -> None:
"""
Deletes a project from the registry.

Args:
name: Name of the project to delete.
commit: Whether the change should be persisted immediately.

Raises:
ProjectObjectNotFoundException: The project could not be found.
Comment on lines +3399 to +3400
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Docstring documents wrong exception type (ProjectObjectNotFoundException vs actual ProjectNotFoundException)

The FeatureStore.delete_project docstring states it raises ProjectObjectNotFoundException, but all registry implementations (registry.py:1519, sql.py:1667, snowflake.py:1330) actually raise ProjectNotFoundException. These are different classes with different inheritance: ProjectObjectNotFoundException extends FeastObjectNotFoundException (line 553 in errors.py), while ProjectNotFoundException extends FeastError directly (line 548 in errors.py). A caller writing except ProjectObjectNotFoundException based on this docstring would fail to catch the actual ProjectNotFoundException, resulting in an unhandled exception. The CLI code at sdk/python/feast/cli/projects.py:77-81 avoids this issue by catching the exception only around get_project (which correctly raises ProjectObjectNotFoundException), not around delete_project.

Suggested change
Raises:
ProjectObjectNotFoundException: The project could not be found.
Raises:
ProjectNotFoundException: The project could not be found.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

"""
return self.registry.delete_project(name, commit=commit)

def list_saved_datasets(
self, allow_cache: bool = False, tags: Optional[dict[str, str]] = None
) -> List[SavedDataset]:
Expand Down
Loading