Skip to content

Commit

Permalink
output: use remote kwarg instead of odb (iterative#6600)
Browse files Browse the repository at this point in the history
* output: use remote kwarg instead of odb

Fixes iterative#6596

* Update dvc/output.py

Co-authored-by: Dave Berenbaum <[email protected]>

* add test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Dave Berenbaum <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 14, 2021
1 parent 237e9d4 commit dae0825
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,9 @@ def get_dir_cache(self, **kwargs):
try:
objects.check(self.odb, obj)
except FileNotFoundError:
remote = self.repo.cloud.get_remote_odb(self.remote)
self.repo.cloud.pull([obj.hash_info], odb=remote, **kwargs)
if self.remote:
kwargs["remote"] = self.remote
self.repo.cloud.pull([obj.hash_info], **kwargs)

if self.obj:
return self.obj
Expand Down
32 changes: 32 additions & 0 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,35 @@ def test_output_remote(tmp_dir, dvc, make_remote):
"6b18131dc289fd37006705affe961ef8.dir",
"b8a9f715dbb64fd5c56e7783c6820a61",
}


def test_target_remote(tmp_dir, dvc, make_remote):
make_remote("default", default=True)
make_remote("myremote", default=False)

tmp_dir.dvc_gen("foo", "foo")
tmp_dir.dvc_gen("data", {"one": "one", "two": "two"})

dvc.push(remote="myremote")

default = dvc.cloud.get_remote_odb("default")
myremote = dvc.cloud.get_remote_odb("myremote")

assert set(default.all()) == set()
assert set(myremote.all()) == {
"acbd18db4cc2f85cedef654fccc4a4d8",
"f97c5d29941bfb1b2fdab0874906ab82",
"6b18131dc289fd37006705affe961ef8.dir",
"b8a9f715dbb64fd5c56e7783c6820a61",
}

clean(["foo", "data"], dvc)

dvc.pull(remote="myremote")

assert set(dvc.odb.local.all()) == {
"acbd18db4cc2f85cedef654fccc4a4d8",
"f97c5d29941bfb1b2fdab0874906ab82",
"6b18131dc289fd37006705affe961ef8.dir",
"b8a9f715dbb64fd5c56e7783c6820a61",
}

0 comments on commit dae0825

Please sign in to comment.