mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 15:28:27 +01:00
experiments: add dvc exp push/pull/list (#5042)
* git: add support for on_diverged in push_refspec * experiments: update executor for push-refspec changes * experiments: implement push() * tests: add tests for experiments.push * git: add iter_remote_refs * roughly equivalent to `git ls-remote --refs` * experiments: add experiments.list for listing local and remote experiments * refactor git upstream/downstream in tests * experiments: add experiments.pull * experiments: add CLI commands for push/pull/list * exp list: drop short options * experiments: s/list/ls/ * dulwich: catch not repo errors when creating remote client * fix remote rev resolution for list * fix command test * add tests for push/pull with ambiguous experiment names
This commit is contained in:
@@ -6,6 +6,9 @@ from dvc.command.experiments import (
|
||||
CmdExperimentsBranch,
|
||||
CmdExperimentsDiff,
|
||||
CmdExperimentsGC,
|
||||
CmdExperimentsList,
|
||||
CmdExperimentsPull,
|
||||
CmdExperimentsPush,
|
||||
CmdExperimentsRun,
|
||||
CmdExperimentsShow,
|
||||
)
|
||||
@@ -150,3 +153,47 @@ def test_experiments_branch(dvc, scm, mocker):
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(cmd.repo, "expname", "branchname")
|
||||
|
||||
|
||||
def test_experiments_list(dvc, scm, mocker):
|
||||
cli_args = parse_args(
|
||||
["experiments", "list", "origin", "--rev", "foo", "--all"]
|
||||
)
|
||||
assert cli_args.func == CmdExperimentsList
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
m = mocker.patch("dvc.repo.experiments.ls.ls", return_value={})
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(
|
||||
cmd.repo, git_remote="origin", rev="foo", all_=True
|
||||
)
|
||||
|
||||
|
||||
def test_experiments_push(dvc, scm, mocker):
|
||||
cli_args = parse_args(
|
||||
["experiments", "push", "origin", "experiment", "--force"]
|
||||
)
|
||||
assert cli_args.func == CmdExperimentsPush
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
m = mocker.patch("dvc.repo.experiments.push.push", return_value={})
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(cmd.repo, "origin", "experiment", force=True)
|
||||
|
||||
|
||||
def test_experiments_pull(dvc, scm, mocker):
|
||||
cli_args = parse_args(
|
||||
["experiments", "pull", "origin", "experiment", "--force"]
|
||||
)
|
||||
assert cli_args.func == CmdExperimentsPull
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
m = mocker.patch("dvc.repo.experiments.pull.pull", return_value={})
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with(cmd.repo, "origin", "experiment", force=True)
|
||||
|
||||
Reference in New Issue
Block a user