mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
exp push/pull: default to head rev
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
b20a59d748
commit
04b50c5cd0
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
|
||||
def pull( # noqa: C901
|
||||
repo,
|
||||
git_remote: str,
|
||||
exp_names: Union[Iterable[str], str],
|
||||
exp_names: Optional[Union[Iterable[str], str]] = None,
|
||||
all_commits=False,
|
||||
rev: Optional[Union[List[str], str]] = None,
|
||||
num=1,
|
||||
|
||||
@@ -97,7 +97,7 @@ def exp_refs_from_rev(scm: "Git", rev: List[str], num: int = 1) -> Set["ExpRefIn
|
||||
def push(
|
||||
repo: "Repo",
|
||||
git_remote: str,
|
||||
exp_names: Union[List[str], str],
|
||||
exp_names: Optional[Union[List[str], str]] = None,
|
||||
all_commits: bool = False,
|
||||
rev: Optional[Union[List[str], str]] = None,
|
||||
num: int = 1,
|
||||
|
||||
@@ -35,6 +35,9 @@ def test_push(tmp_dir, scm, dvc, git_upstream, exp_stage, use_url):
|
||||
dvc.experiments.push(remote, [ref_info1.name])
|
||||
assert git_upstream.tmp_dir.scm.get_ref(str(ref_info1)) == exp1
|
||||
|
||||
dvc.experiments.push(remote)
|
||||
assert git_upstream.tmp_dir.scm.get_ref(str(ref_info3)) == exp3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("all_,rev,result3", [(True, False, True), (False, True, None)])
|
||||
def test_push_args(tmp_dir, scm, dvc, git_upstream, exp_stage, all_, rev, result3):
|
||||
@@ -173,6 +176,11 @@ def test_list_remote(tmp_dir, scm, dvc, git_downstream, exp_stage, use_url):
|
||||
def test_pull(tmp_dir, scm, dvc, git_downstream, exp_stage, use_url):
|
||||
from dvc.exceptions import InvalidArgumentError
|
||||
|
||||
# fetch and checkout to downstream so both repos start from same commit
|
||||
downstream_repo = git_downstream.tmp_dir.scm.gitpython.repo
|
||||
fetched = downstream_repo.remote(git_downstream.remote).fetch()
|
||||
downstream_repo.git.checkout(fetched)
|
||||
|
||||
remote = git_downstream.url if use_url else git_downstream.remote
|
||||
downstream_exp = git_downstream.tmp_dir.dvc.experiments
|
||||
with pytest.raises(InvalidArgumentError):
|
||||
@@ -200,6 +208,9 @@ def test_pull(tmp_dir, scm, dvc, git_downstream, exp_stage, use_url):
|
||||
downstream_exp.pull(remote, [str(ref_info1)])
|
||||
assert git_downstream.tmp_dir.scm.get_ref(str(ref_info1)) == exp1
|
||||
|
||||
downstream_exp.pull(remote)
|
||||
assert git_downstream.tmp_dir.scm.get_ref(str(ref_info3)) == exp3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("all_,rev,result3", [(True, False, True), (False, True, None)])
|
||||
def test_pull_args(tmp_dir, scm, dvc, git_downstream, exp_stage, all_, rev, result3):
|
||||
|
||||
@@ -294,12 +294,7 @@ def test_experiments_push(dvc, scm, mocker):
|
||||
)
|
||||
cmd = cli_args.func(cli_args)
|
||||
|
||||
with pytest.raises(InvalidArgumentError) as exp_info:
|
||||
cmd.run()
|
||||
assert (
|
||||
str(exp_info.value) == "Either provide an `experiment` argument"
|
||||
", or use the `--rev` or `--all-commits` flag."
|
||||
)
|
||||
assert cmd.run() == 0
|
||||
|
||||
|
||||
def test_experiments_pull(dvc, scm, mocker):
|
||||
@@ -351,12 +346,7 @@ def test_experiments_pull(dvc, scm, mocker):
|
||||
)
|
||||
cmd = cli_args.func(cli_args)
|
||||
|
||||
with pytest.raises(InvalidArgumentError) as exp_info:
|
||||
cmd.run()
|
||||
assert (
|
||||
str(exp_info.value) == "Either provide an `experiment` argument"
|
||||
", or use the `--rev` or `--all-commits` flag."
|
||||
)
|
||||
assert cmd.run() == 0
|
||||
|
||||
|
||||
def test_experiments_remove_flag(dvc, scm, mocker, capsys, caplog):
|
||||
|
||||
Reference in New Issue
Block a user