-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
commands/update: add --rev option #2993
Conversation
to update with a specific git revision
@ilgooz looks like you need to install the pre-commit hook that takes care of the code style - please, take a look at the contributing guide. |
Thanks Ivan, I'll do that and also some fixes, and add some tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is incomplete:
- format things, e.g. with pre-commit hooks, to run tests
- need a functional test for
dvc update --rev
- need to check that
dvc update --rev ...
shows an appropriate error for aimport-url
stage
done by 95db0ea |
Hi guys, big thanks for your encouraging collaboration, I'll do the requested changes. Can you please participate to the discussion at the following link as well? #2849 (comment) |
Co-Authored-By: Jorge Orpinel <[email protected]> Co-Authored-By: Ruslan Kuprieiev <[email protected]>
* small refactoring on the related test to use new testing util.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Any ideas of how to get Travis check back? Should I split the string into two lines? https://travis-ci.com/iterative/dvc/jobs/272434824
|
@ilgooz Yes, please split it somehow. |
cc @Suor up for reviews! |
Co-Authored-By: Ruslan Kuprieiev <[email protected]>
Tests won't pass again, I'll check this tomorrow! |
LGTM, but |
if not rev: | ||
rev = self.def_repo.get("rev") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do that. See _make_rev
, where it will merge your args with def_repo anyways.
@@ -53,6 +53,6 @@ def add_parser(subparsers, parent_parser): | |||
"-o", "--out", nargs="?", help="Destination path to download files to" | |||
) | |||
import_parser.add_argument( | |||
"--rev", nargs="?", help="Git revision (e.g. branch, tag, SHA)" | |||
"--rev", nargs="?", help="Git revision in repository to update from." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilgooz , why removing the examples? Not everyone is familiar with the term revision)
class UpdateWithRevNotPossibleError(DvcException): | ||
def __init__(self): | ||
super(UpdateWithRevNotPossibleError, self).__init__( | ||
"Revision option (`--rev`) is not a feature of non-Git sources." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually it is easier to read without double negations:
not a feature of non-Git sources
-> only a feature of Git sources
"Revision option (`--rev`) is not a feature of non-Git sources." | |
"Revision option (`--rev`) is supported only for Git sources." |
|
||
|
||
def test_update_rev(tmp_dir, dvc, erepo_dir, monkeypatch): | ||
with monkeypatch.context() as m: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilgooz , if the reason for using monkeypatch
is to chdir
to erepo_dir
, you can use instead:
with monkeypatch.context() as m: | |
with erepo_dir.chdir(): |
def test_update_rev(tmp_dir, dvc, erepo_dir, monkeypatch): | ||
with monkeypatch.context() as m: | ||
m.chdir(fspath(erepo_dir)) | ||
erepo_dir.scm.checkout("new_branch", create_new=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another useful helper to change to a branch temporarily:
erepo_dir.scm.checkout("new_branch", create_new=True) | |
with erepo_dir.branch("new_branch", new=True): | |
# ... |
erepo_dir.scm.checkout("new_branch", create_new=True) | ||
erepo_dir.dvc_gen("foo", "foo content", commit="create foo on branch") | ||
erepo_dir.scm.checkout("master") | ||
erepo_dir.scm.checkout("new_branch_2", create_new=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
erepo_dir.scm.checkout("new_branch_2", create_new=True) | |
with erepo_dir.branch("new_branch_2", new=True): |
assert (tmp_dir / "foo_imported").read_text() == "foo content 2" | ||
|
||
|
||
def test_update_rev_non_git_failure(repo_dir, dvc_repo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using repo_dir
and dvc_repo
anymore, instead, we use tmp_dir
or dvc
.
This is not crucial, but it would be nice if you could read the docstring from tests/dir_helpers.py
.
Sorry for the extra work, @ilgooz π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a suggestion, to save you some time:
def test_update_rev_non_git_failure(tmp_dir, dvc):
tmp_dir.gen("file", "text")
stage = dvc.imp_url("file", "imported")
with pytest.raises(UpdateWithRevNotPossibleError):
dvc_repo.update(stage.path, rev="dev")
Looks neat)
Test changes are caused by this PR existing through the period of us refactoring our test suite πSorry for the inconvenience. |
Closing as stale. |
to update with a specific git revision.
please see updates on the docs iterative/dvc.org#890.
resolves #2849.
--
β Have you followed the guidelines in the Contributing to DVC list?
π Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
β Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. π