Skip to content

Commit

Permalink
fix delete_project method (#466)
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Davidyuk <igor.davidyuk@intel.com>
  • Loading branch information
igor-davidyuk authored Jul 16, 2024
1 parent ce6b6e6 commit 3c340f0
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions geti_sdk/rest_clients/project_client/project_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,30 @@ def delete_project(
raise TypeError(f"{type(project)} is not a valid project type.")

if requires_confirmation:
media_response = self.session.get_rest_response(
url=f"{self.base_url}projects/{project.id}/datasets/"
f"{project.datasets[0].id}/media",
method="GET",
)
# Update project details
project = self._get_project_detail(project)
if project.datasets is None:
project.datasets = []
image_count = 0
video_count = 0
for dataset in project.datasets:
dataset_statistics = self.session.get_rest_response(
url=f"{self.base_url}projects/{project.id}/datasets/"
f"{dataset.id}/statistics",
method="GET",
)
if dataset_statistics is dict:
dataset_statistics["overview"].get("image_count", 0)
image_count += dataset_statistics.get("images", 0)
video_count += dataset_statistics.get("videos", 0)
else:
logging.warning(
f"Unable to retrieve statistics for dataset {dataset.name}."
)

media_count = media_response.get("media_count", {"images": 0, "videos": 0})
user_confirmation = input(
f"CAUTION: You are about to delete project '{project.name}', "
f"containing {media_count['images']} images and {media_count['videos']}"
f"containing {image_count} images and {video_count}"
f" videos, from the platform. Are you sure you want to continue? Type "
f"Y or YES to continue, any other key to cancel."
)
Expand Down

0 comments on commit 3c340f0

Please sign in to comment.