mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Adds support for `--config` to all three commands. For `ls` and `get`, it is
a purely runtime option that will merge the config you provide with target
repo's configs (similar to how .dvc/config.local works). E.g.
```
$ cat myconfig
[remote "myremote"]
access_key_id = 12345
secret_access_key = 98765
$ dvc get https://github.com/efiop/mydataregistry recent-grads.csv --config myconfig
```
In case of `dvc import`, the semantics are the same, but the value is also
recorded in the resulting dvcfile. E.g.
```
$ dvc import https://github.com/efiop/mydataregistry recent-grads.csv --config myconfig
...
$ cat recent-grads.csv.dvc
md5: 85c86eeb3afa6d1f7d11beedc644d28e
frozen: true
deps:
- path: recent-grads.csv
repo:
url: https://github.com/efiop/mydataregistry
config: myconfig
rev_lock: af22e06bbfe34d62a140437abf32f48b535944a7
outs:
- md5: f447e23a170a9f25a7799f069a1ba934
size: 26872
hash: md5
path: recent-grads.csv
```
This is the most general and powerful mechanism that we can give, that works
for everything from reconfiguring your default remote to completely changing
your remote layout and beyond (will be handy in the future).
Fixes #2466
51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
from dvc.cli import parse_args
|
|
from dvc.commands.get import CmdGet
|
|
|
|
|
|
def test_get(mocker):
|
|
cli_args = parse_args(
|
|
[
|
|
"get",
|
|
"repo_url",
|
|
"src",
|
|
"--out",
|
|
"out",
|
|
"--rev",
|
|
"version",
|
|
"--jobs",
|
|
"4",
|
|
"--config",
|
|
"myconfig",
|
|
]
|
|
)
|
|
assert cli_args.func == CmdGet
|
|
|
|
cmd = cli_args.func(cli_args)
|
|
m = mocker.patch("dvc.repo.Repo.get")
|
|
|
|
assert cmd.run() == 0
|
|
|
|
m.assert_called_once_with(
|
|
"repo_url",
|
|
path="src",
|
|
out="out",
|
|
rev="version",
|
|
jobs=4,
|
|
config="myconfig",
|
|
force=False,
|
|
)
|
|
|
|
|
|
def test_get_url(mocker, capsys):
|
|
cli_args = parse_args(["get", "repo_url", "src", "--rev", "version", "--show-url"])
|
|
assert cli_args.func == CmdGet
|
|
|
|
cmd = cli_args.func(cli_args)
|
|
m = mocker.patch("dvc.api.get_url", return_value="resource_url")
|
|
|
|
assert cmd.run() == 0
|
|
out, _ = capsys.readouterr()
|
|
assert "resource_url" in out
|
|
|
|
m.assert_called_once_with("src", repo="repo_url", rev="version")
|