Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Added trial count to delete_trials message #656

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions src/orion/core/cli/db/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


TRIALS_RM_MESSAGE = """
Matching trials of all experiments above will be deleted.
Matching trials ({}) of all experiments above will be deleted.
To select a specific version use --version <VERSION>.
Note that trials of all children of a given version will be deleted.

Expand Down Expand Up @@ -110,6 +110,27 @@ def add_subparser(parser):
return rm_parser


def get_trial_count(storage, root, status):
"""Select the matching trials of the given experiment."""
trials_total = 0
for node in root:
if status == "*":
query = {}
else:
query = {"status": status}

count = len(storage.fetch_trials(uid=node.item.id, where=query))
logger.debug(
"%d trials selected in experiment %s-v%d",
count,
node.item.name,
node.item.version,
)
trials_total += count

return trials_total


def process_trial_rm(storage, root, status):
"""Delete the matching trials of the given experiment."""
trials_total = 0
Expand Down Expand Up @@ -167,7 +188,8 @@ def delete_experiments(storage, root, name, force):

def delete_trials(storage, root, name, status, force):
"""Delete all matching trials after user confirmation."""
confirmed = confirm_name(TRIALS_RM_MESSAGE, name, force)
count = get_trial_count(storage, root, status)
confirmed = confirm_name(TRIALS_RM_MESSAGE.format(count), name, force)

if not confirmed:
print("Confirmation failed, aborting operation.")
Expand Down