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

Remove a special queued experiments #6393

Merged
merged 10 commits into from
Aug 13, 2021
Merged

Conversation

karajan1001
Copy link
Contributor

@karajan1001 karajan1001 commented Aug 9, 2021

fix #6157

  1. dvc exp remove not accept queued experiments name
  2. add some tests for this feature

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

fix iterative#6157
1. dvc exp remove not accept queued experiments name
2. add some tests for this feature
@karajan1001 karajan1001 requested a review from a team as a code owner August 9, 2021 01:39
@karajan1001 karajan1001 requested a review from pared August 9, 2021 01:39
@pmrowla pmrowla self-requested a review August 9, 2021 01:59
@pmrowla
Copy link
Contributor

pmrowla commented Aug 9, 2021

So one other thing that will be needed is removing queued experiments by revision.

For regular experiments we only support removing them by ref (or shortened name), since the operation to remove a finished experiment is a git ref deletion, and using commit SHA's here would be ambiguous.

But for queued (stashed) experiments, they will only be named if the user provided one themselves with exp run -n/--name. Otherwise, it can only be identified by a git commit SHA. Both names and SHAs should be allowed for queued experiments since the remove operation is not actually a name/ref deletion, it is just a stash drop (removing a SHA from the git reflog).

dvc/repo/experiments/remove.py Outdated Show resolved Hide resolved
@karajan1001
Copy link
Contributor Author

But for queued (stashed) experiments, they will only be named if the user provided one themselves with exp run -n/--name. Otherwise, it can only be identified by a git commit SHA. Both names and SHAs should be allowed for queued experiments since the remove operation is not actually a name/ref deletion, it is just a stash drop (removing a SHA from the git reflog).

Yes, there comes another question should the committed ones also accept a revision name? It is natural for uses to extend the usage of queued ones to a committed one.

@pmrowla
Copy link
Contributor

pmrowla commented Aug 9, 2021

Yes, there comes another question should the committed ones also accept a revision name? It is natural for uses to extend the usage of queued ones to a committed one.

No, because the actual operations for removing a queued experiment and a regular one are two different things. Since removing a regular experiment is a git ref deletion, specifying a commit SHA is ambiguous - it's possible for multiple experiment refs to point to a single git SHA, so it is better for us to require the user to be explicit here (and use the ref/name).

Removing queued experiments is not deleting a git ref, it's dropping a git SHA from a list of stashed git SHAs.

1. Extract remove experiments to a new file.
2. revision can be used to remove special queued experiment
if stash_index is None:
raise InvalidArgumentError(
f"'{ref_or_rev}' is neither a valid experiment reference"
" nor a queued experiment revision"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Quite weird here, because the asymmetric in committed and queued experiments.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would separate this into two methods, one for removing a complete experiment ref (only by ref name) and one for removing stash entries (by either name or revision).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But without a flag, we can not know if the input is a ref or a revision. Some ref might use a shortcut name for example.
epoch_1_layers3 - > ep1la3 hard to distinguish them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, you would start by calling
_remove_exp_ref(name).

If that fails because an exact exp ref match for name does not exist, then you would try the stash remove function. Which also needs to try for an exact name match first, and then handling it as git rev second.

Copy link
Contributor

Choose a reason for hiding this comment

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

Basically you can parse the list of names that we get at the start into two separate lists before trying to remove anything at all. One list that matches exact refs, and a second list that does not match exact refs. Everything in the second list is either a stash entry (by name or rev) or is invalid entirely.

Comment on lines 33 to 35
print("*" * 100)
for rev, ref_info in stash_ref_infos.items():
print(rev, ref_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover print statements

Copy link
Contributor Author

@karajan1001 karajan1001 Aug 10, 2021

Choose a reason for hiding this comment

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

Excuse me, How to set an auto-commit for the VSCODE, always get some changes not committed or not updated.

dvc/repo/experiments/remove.py Outdated Show resolved Hide resolved
dvc/repo/experiments/remove.py Outdated Show resolved Hide resolved
if stash_index is None:
raise InvalidArgumentError(
f"'{ref_or_rev}' is neither a valid experiment reference"
" nor a queued experiment revision"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would separate this into two methods, one for removing a complete experiment ref (only by ref name) and one for removing stash entries (by either name or revision).

@karajan1001
Copy link
Contributor Author

asciicast

Some example to this

removed += len(ref_infos)
remained = _remove_commited_exps(repo, exp_names)
remained = _remove_queued_exps(repo, remained)
if remained:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A behavior change here, because we had already removed all of the matched experiments, raise an exception here is needless.

@karajan1001
Copy link
Contributor Author

Better tests cases.

  1. remove a list of committed and non-exist exp.
  2. Tests that committed exp not be affected by remove --queue.
  3. remove a list of mixed queued and committed exp.

We still need to raise Exception in a mixed committed and non exist case. Because of only by this the return values of dvc exp remove would be a non-zero value.

@karajan1001 karajan1001 requested a review from pmrowla August 12, 2021 08:18
@karajan1001 karajan1001 merged commit de97a49 into iterative:master Aug 13, 2021
@karajan1001 karajan1001 deleted the fix6157 branch August 13, 2021 07:15
skshetry added a commit to skshetry/dvc that referenced this pull request Aug 13, 2021
* 'python310' of github.com:skshetry/dvc:
  Unpin networkx
  Remove a special queued experiments (iterative#6393)
  build(deps): bump google-cloud-storage from 1.41.1 to 1.42.0 (iterative#6415)
  Push running checkpoint to remote (iterative#6332)
@efiop efiop added the feature is a feature label Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exp: remove <queued_experiment>
5 participants