Compare commits

...
14 Commits
Author SHA1 Message Date
skshetry 5fb8986dbd bench: check for dvc_bin.version instead of dvc_rev (#10764)
* bench: check for dvc_bin.version instead of dvc_rev

* Update dvc/testing/benchmarks/cli/stories/use_cases/test_sharing.py

* Update dvc/testing/benchmarks/cli/stories/use_cases/test_sharing.py
2025-06-05 11:41:04 +05:45
skshetry 18177a6579 tests(bench): also check if dvc_rev is set (#10763) 2025-06-05 09:26:27 +05:45
skshetry ea02a18b23 tests(bench): remove allow_anonymous_login config use from dvc<3.59.3 (#10762) 2025-06-05 09:21:44 +05:45
skshetry e04f1499a3 fix(dvcfs): rename argument url to repo (#10754)
See #10700 for the motivation.
2025-06-05 08:30:22 +05:45
skshetry 488c30d1ea tests(bench): adapt for pytest>=8.4 (#10761) 2025-06-04 10:13:28 +05:45
Clouds 88c3103cf3 fix: treated S3 configpath as a relpath (#10758)
Update config.py
2025-06-03 19:31:03 +05:45
pre-commit-ci[bot] c37bef7add [pre-commit.ci] pre-commit autoupdate (#10755)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.11 → v0.11.12](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.11...v0.11.12)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-06-03 11:59:26 +05:45
skshetry 7ea1daa2b8 deps: bump minver version for dvc-gs to 3.0.2 (#10757)
To support allow_anonymous_login that was added in dvc-gs 3.0.2.

Related:
- https://github.com/iterative/dvc-gs/pull/115
- https://github.com/iterative/dvc/pull/10756
- https://github.com/iterative/dvc/issues/5797
2025-06-03 10:55:35 +05:45
skshetry fd181c78d2 fs(gs): allow configuring anonymous login (#10756) 2025-06-03 10:41:08 +05:45
pre-commit-ci[bot] 1de7f89af8 [pre-commit.ci] pre-commit autoupdate (#10751)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.10 → v0.11.11](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.10...v0.11.11)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-27 07:10:08 +05:45
pre-commit-ci[bot]andskshetry b7e13dbd07 [pre-commit.ci] pre-commit autoupdate (#10748)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.9 → v0.11.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.9...v0.11.10)

* Update .pre-commit-config.yaml

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: skshetry <[email protected]>
2025-05-20 11:04:00 +05:45
pre-commit-ci[bot] dc513a98e4 [pre-commit.ci] pre-commit autoupdate (#10745)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.11.8 → v0.11.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.8...v0.11.9)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-14 07:15:39 +05:45
skshetry 9908ca7f8e drop inputs passed to codecov-action (#10740)
It can already search and find these coverage files.
2025-05-07 14:34:27 +05:45
skshetry 0eebeb9900 tests: fix flaky test in test_get_used_objs (#10739)
Clear logs before assertions so that logs from other tests do not interfere with the test.
Some destructors may also run in between due to GC, so hopefully this will fix that issue too,
or reduce the chances of it happening.

See
https://github.com/iterative/dvc/actions/runs/14873217814/job/41775314725#step:6:97.

```console
>       assert first(caplog.messages) == expected_message
E       assert 'RC: discarding all clients' == "Output 'path... 'stage.dvc'."
E
E         + RC: discarding all clients
E         - Output 'path'(stage: 'stage.dvc') is missing version info. Cache for it will not be collected. Use `dvc repro` to get your pipeline up to date.
E         - You can also use `dvc commit stage.dvc` to associate existing 'path' with stage: 'stage.dvc'.
```
2025-05-07 12:40:51 +05:45
13 changed files with 100 additions and 24 deletions
-3
View File
@@ -143,9 +143,6 @@ jobs:
--cov --cov-report=xml --cov-report=term --durations-path=./.github/.test_durations
- name: upload coverage report
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
fail_ci_if_error: false
check:
if: always()
needs: [tests]
+2 -2
View File
@@ -22,9 +22,9 @@ repos:
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.11.8'
rev: 'v0.11.12'
hooks:
- id: ruff
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
+1
View File
@@ -340,6 +340,7 @@ class Config(dict):
"gdrive_user_credentials_file": func,
"gdrive_service_account_json_file_path": func,
"credentialpath": func,
"configpath": func,
"keyfile": func,
"cert_path": func,
"key_path": func,
+1
View File
@@ -215,6 +215,7 @@ SCHEMA = {
"credentialpath": str,
"endpointurl": str,
Optional("verify", default=False): Bool,
Optional("allow_anonymous_login", default=False): Bool,
**REMOTE_COMMON,
},
"ssh": {
+1 -1
View File
@@ -154,7 +154,7 @@ class RepoDependency(Dependency):
config["cache"]["dir"] = self.repo.cache.local_cache_dir
return DVCFileSystem(
url=self.def_repo[self.PARAM_URL],
repo=self.def_repo[self.PARAM_URL],
rev=rev or self._get_rev(locked=locked),
subrepos=True,
config=config,
+16 -7
View File
@@ -83,11 +83,10 @@ class _DVCFileSystem(AbstractFileSystem):
cachable = False
root_marker = "/"
def __init__( # noqa: PLR0913
def __init__(
self,
url: Optional[str] = None,
repo: Union["Repo", os.PathLike[str], str, None] = None,
rev: Optional[str] = None,
repo: Optional["Repo"] = None,
subrepos: bool = False,
repo_factory: Optional[RepoFactory] = None,
fo: Optional[str] = None,
@@ -101,7 +100,8 @@ class _DVCFileSystem(AbstractFileSystem):
"""DVC + git-tracked files fs.
Args:
path (str, optional): URL or path to a DVC/Git repository.
repo (str | os.PathLike[str] | Repo, optional): A url or a path to a DVC/Git
repository, or a `Repo` instance.
Defaults to a DVC repository in the current working directory.
Both HTTP and SSH protocols are supported for remote Git repos
(e.g. [user@]server:project.git).
@@ -111,7 +111,6 @@ class _DVCFileSystem(AbstractFileSystem):
In case of a local repository, if rev is unspecified, it will
default to the working directory.
If the repo is not a Git repo, this option is ignored.
repo (:obj:`Repo`, optional): `Repo` instance.
subrepos (bool): traverse to subrepos.
By default, it ignores subrepos.
repo_factory (callable): A function to initialize subrepo with.
@@ -136,13 +135,23 @@ class _DVCFileSystem(AbstractFileSystem):
... rev="main",
... )
"""
from dvc.repo import Repo
# kwargs.get("url") is for maintaining backward compatibility
repo = repo or fo or kwargs.get("url")
if isinstance(repo, Repo):
self._repo: Optional[Repo] = repo
url = None
else:
self._repo = None
url = os.fspath(repo) if repo else None
super().__init__()
self._repo = repo
self._repo_factory = repo_factory
self._traverse_subrepos = subrepos
self._repo_stack = ExitStack()
self._repo_kwargs = {
"url": url if url is not None else fo,
"url": url,
"rev": rev,
"subrepos": subrepos,
"config": config,
+8 -5
View File
@@ -32,12 +32,13 @@ class TestAPI:
"fs_kwargs",
[
{},
{"url": "{path}"},
{"url": "{path}", "rev": "{default_branch}"},
{"url": "file://{posixpath}"},
{"url": "file://{posixpath}", "rev": "{default_branch}"},
{"repo": "{path}"},
{"repo": "{path}", "rev": "{default_branch}"},
{"repo": "file://{posixpath}"},
{"repo": "file://{posixpath}", "rev": "{default_branch}"},
{"url": "{path}"}, # test for backward compatibility
],
ids=["current", "local", "local_rev", "git", "git_rev"],
ids=["current", "local", "local_rev", "git", "git_rev", "local_url"],
)
def test_filesystem(
self,
@@ -59,6 +60,8 @@ class TestAPI:
if clear_cache:
remove(dvc.cache.repo.path)
if repo := fs_kwargs.get("repo"):
fs_kwargs["repo"] = repo.format(path=tmp_dir, posixpath=tmp_dir.as_posix())
if url := fs_kwargs.get("url"):
fs_kwargs["url"] = url.format(path=tmp_dir, posixpath=tmp_dir.as_posix())
if rev := fs_kwargs.get("rev"):
@@ -1,7 +1,17 @@
import shutil
from packaging import version
def test_sharing(bench_dvc, tmp_dir, dvc, make_dataset, remote, dvc_bin):
is_gs = dvc.config["remote"]["upstream"]["url"].startswith("gs://")
if is_gs and version.Version(dvc_bin.version) < version.Version("3.59.2"):
# support for allow_anonymous_login in gs was introduced in dvc==3.60
# This should not impact the test, just that it will make it slower if used
# with fake-gcs-server.
with dvc.config.edit() as d:
d["remote"]["upstream"].pop("allow_anonymous_login", None)
def test_sharing(bench_dvc, tmp_dir, dvc, make_dataset, remote):
dataset = make_dataset(cache=True, dvcfile=True)
bench_dvc("push")
+17 -3
View File
@@ -1,3 +1,4 @@
import inspect
import os
import shutil
import sys
@@ -76,7 +77,10 @@ def dvc_repo(tmp_path_factory, bench_config):
def dvc_bench_repo(tmp_path_factory, bench_config):
url = bench_config.dvc_bench_repo
if url is None:
pytest.skip("--dvc-bench-repo is not set")
pytest.skip(
"--dvc-bench-repo is not set, "
"clone https://github.com/iterative/dvc-bench repository and set its path"
)
if os.path.isdir(url):
return Path(url)
@@ -149,8 +153,18 @@ def make_bench(request):
import pytest_benchmark.plugin
# hack from https://github.com/ionelmc/pytest-benchmark/issues/166
bench_gen = pytest_benchmark.plugin.benchmark.__pytest_wrapped__.obj(request)
bench = next(bench_gen)
fixture_function = pytest_benchmark.plugin.benchmark
try:
# pytest >= 8.4.0
wrapped_func = fixture_function._get_wrapped_function()
except AttributeError:
wrapped_func = fixture_function.__pytest_wrapped__.obj
assert inspect.isgeneratorfunction(wrapped_func)
generator = wrapped_func(request)
bench = next(generator)
assert isinstance(bench, pytest_benchmark.plugin.BenchmarkFixture)
request.addfinalizer(lambda: next(generator, None))
suffix = f"-{name}"
+2 -1
View File
@@ -82,7 +82,7 @@ all = ["dvc[azure,gdrive,gs,hdfs,oss,s3,ssh,webdav,webhdfs]"]
azure = ["dvc-azure>=3.1.0,<4"]
dev = ["dvc[azure,gdrive,gs,hdfs,lint,oss,s3,ssh,tests,webdav,webhdfs]"]
gdrive = ["dvc-gdrive>=3,<4"]
gs = ["dvc-gs>=3,<4"]
gs = ["dvc-gs>=3.0.2,<4"]
hdfs = ["dvc-hdfs>=3,<4"]
lint = [
"mypy==1.15.0",
@@ -173,6 +173,7 @@ filterwarnings = [
"ignore:nx.nx_pydot.* depends on the pydot package, which has.*known issues and is not actively maintained:DeprecationWarning",
# TODO: investigate where we are not closing sqlite3.Connection
"ignore:unclosed database.*sqlite3.Connection:ResourceWarning",
"ignore:unclosed.*<socket.socket:ResourceWarning",
]
log_level = "debug"
markers = [
+17
View File
@@ -696,3 +696,20 @@ def test_fsid_url(erepo_dir):
fs = DVCFileSystem(repo=dvc)
assert fs.fsid != old_fsid
assert fs.fsid == "dvcfs_" + tokenize(url, erepo_dir.scm.get_rev())
@pytest.mark.parametrize(
"fs_kwargs",
[
lambda tmp_dir, dvc: {}, # noqa: ARG005
lambda tmp_dir, dvc: {"repo": tmp_dir}, # noqa: ARG005
lambda tmp_dir, dvc: {"repo": os.fspath(tmp_dir)}, # noqa: ARG005
lambda tmp_dir, dvc: {"url": tmp_dir}, # noqa: ARG005
lambda tmp_dir, dvc: {"url": os.fspath(tmp_dir)}, # noqa: ARG005
lambda tmp_dir, dvc: {"repo": dvc}, # noqa: ARG005
],
)
def test_init_arg(tmp_dir, dvc, fs_kwargs):
fs = DVCFileSystem(**fs_kwargs(tmp_dir, dvc))
assert fs.repo.root_dir == dvc.root_dir
+23 -1
View File
@@ -779,7 +779,7 @@ def test_maxdepth(tmp_dir, dvc, scm):
commit="add dir",
)
fs = DVCFileSystem(url=tmp_dir)
fs = DVCFileSystem(tmp_dir)
fs.get("dir", "dir1", recursive=True, maxdepth=1)
assert (tmp_dir / "dir1").read_text() == {"file1": "file1"}
@@ -803,3 +803,25 @@ def test_maxdepth(tmp_dir, dvc, scm):
"subdir2": {"file3": "file3", "subdir3": {"file4": "file4"}},
},
}
@pytest.mark.parametrize(
"fs_args",
[
lambda tmp_dir, dvc: ((), {}), # noqa: ARG005
lambda tmp_dir, dvc: ((dvc,), {}), # noqa: ARG005
lambda tmp_dir, dvc: ((tmp_dir,), {}), # noqa: ARG005
lambda tmp_dir, dvc: ((str(tmp_dir),), {}), # noqa: ARG005
lambda tmp_dir, dvc: ((), {"repo": tmp_dir}), # noqa: ARG005
lambda tmp_dir, dvc: ((), {"repo": os.fspath(tmp_dir)}), # noqa: ARG005
# url= is deprecated, but is still supported for backward compatibility
lambda tmp_dir, dvc: ((), {"url": tmp_dir}), # noqa: ARG005
lambda tmp_dir, dvc: ((), {"url": os.fspath(tmp_dir)}), # noqa: ARG005
lambda tmp_dir, dvc: ((), {"repo": dvc}), # noqa: ARG005
],
)
def test_init_arg(tmp_dir, dvc, fs_args):
args, kwargs = fs_args(tmp_dir, dvc)
fs = DVCFileSystem(*args, **kwargs)
assert fs.repo.root_dir == dvc.root_dir
+1
View File
@@ -101,6 +101,7 @@ def test_get_used_objs(exists, expected_message, mocker, caplog):
Output, "exists", new_callable=mocker.PropertyMock
).return_value = exists
caplog.clear()
with caplog.at_level(logging.WARNING, logger="dvc"):
assert output.get_used_objs() == {}
assert first(caplog.messages) == expected_message