Compare commits

...
5 Commits
Author SHA1 Message Date
Ruslan Kuprieiev 73fdfc8059 build: fpm: don't create .build-id/* files
These are leaking into our rpm packages.

Related https://github.com/iterative/dvc-s3-repo/issues/86
2022-11-24 01:02:44 +02:00
Ruslan Kuprieiev 8dc11417d2 testing: api: test opening a file in subdir
Related to #8420
2022-11-23 17:47:13 +02:00
b02855fb93 ui: Fix WSL check in open_browser (#8604)
* ui: Fix WSL check in `open_browser`

* Update dvc/ui/__init__.py

Co-authored-by: Peter Rowlands (변기호) <[email protected]>

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

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

Co-authored-by: Peter Rowlands (변기호) <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-23 09:57:57 +00:00
Peter Rowlands af255a46b4 worktree: use progress bars in push/fetch 2022-11-23 13:05:51 +09:00
Peter Rowlands 2748492f6b worktree push: don't push existing versions 2022-11-23 13:05:51 +09:00
5 changed files with 45 additions and 10 deletions
+26 -5
View File
@@ -1,5 +1,7 @@
from typing import TYPE_CHECKING, Optional
from dvc.fs.callbacks import Callback
if TYPE_CHECKING:
from dvc.cloud import Remote
from dvc.index import Index, IndexView
@@ -30,7 +32,11 @@ def worktree_view(
return True
def outs_filter(out: "Output") -> bool:
if not out.is_in_repo or (push and not out.can_push):
if (
not out.is_in_repo
or not out.use_cache
or (push and not out.can_push)
):
return False
return True
@@ -53,8 +59,12 @@ def fetch_worktree(repo: "Repo", remote: "Remote") -> int:
remote.path,
*key,
)
save(index)
return len(index)
total = len(index)
with Callback.as_tqdm_callback(
unit="file", desc="Fetch", disable=total == 0
) as cb:
cb.set_size(total)
return save(index, callback=cb)
def push_worktree(repo: "Repo", remote: "Remote") -> int:
@@ -63,7 +73,18 @@ def push_worktree(repo: "Repo", remote: "Remote") -> int:
view = worktree_view(repo.index, push=True)
index = view.data["repo"]
checkout(index, remote.path, remote.fs)
total = len(index)
with Callback.as_tqdm_callback(
unit="file", desc="Push", disable=total == 0
) as cb:
cb.set_size(total)
pushed = checkout(
index,
remote.path,
remote.fs,
latest_only=False,
callback=cb,
)
for stage in view.stages:
for out in stage.outs:
@@ -97,4 +118,4 @@ def push_worktree(repo: "Repo", remote: "Remote") -> int:
out.meta = entry.meta
stage.dvcfile.dump(stage, with_files=True, update_pipeline=False)
return len(index)
return pushed
+11 -3
View File
@@ -13,14 +13,22 @@ class TestAPI:
assert api.get_url("foo") == expected_url
def test_open(self, tmp_dir, dvc, remote):
tmp_dir.dvc_gen("foo", "foo-text")
tmp_dir.dvc_gen(
{
"foo": "foo-text",
"dir": {"bar": "bar-text"},
}
)
dvc.push()
# Remove cache to force download
remove(dvc.odb.local.path)
with api.open("foo") as fd:
assert fd.read() == "foo-text"
with api.open("foo") as fobj:
assert fobj.read() == "foo-text"
with api.open("dir/bar") as fobj:
assert fobj.read() == "bar-text"
@pytest.mark.parametrize(
"clear_cache", [True, False], ids=["cache", "no_cache"]
+3 -1
View File
@@ -270,7 +270,9 @@ class Console:
path = Path(file).resolve()
url = (
relpath(path) if "Microsoft" in uname().release else path.as_uri()
relpath(path)
if "microsoft" in uname().release.lower()
else path.as_uri()
)
opened = webbrowser.open(url)
+4
View File
@@ -44,6 +44,10 @@ if args.pkg == "osxpkg":
]
)
else:
if args.pkg == "rpm":
# https://github.com/jordansissel/fpm/issues/1503
flags.extend(["--rpm-rpmbuild-define", '"_build_id_links none"'])
bash_dir = build / "etc" / "bash_completion.d"
dirs = ["usr", "etc"]
flags.extend(["--depends", "git >= 1.7.0"]) # needed for gitpython
+1 -1
View File
@@ -178,7 +178,7 @@ def test_plots_diff_open(tmp_dir, dvc, mocker, capsys, plots_data, auto_open):
def test_plots_diff_open_WSL(tmp_dir, dvc, mocker, plots_data):
mocked_open = mocker.patch("webbrowser.open", return_value=True)
mocked_uname_result = mocker.MagicMock()
mocked_uname_result.release = "Microsoft"
mocked_uname_result.release = "microsoft"
mocker.patch("platform.uname", return_value=mocked_uname_result)
cli_args = parse_args(