mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-03 23:09:19 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fb8986dbd | ||
|
|
18177a6579 | ||
|
|
ea02a18b23 | ||
|
|
e04f1499a3 | ||
|
|
488c30d1ea | ||
|
|
88c3103cf3 | ||
|
|
c37bef7add | ||
|
|
7ea1daa2b8 | ||
|
|
fd181c78d2 | ||
|
|
1de7f89af8 | ||
|
|
b7e13dbd07 | ||
|
|
dc513a98e4 | ||
|
|
9908ca7f8e | ||
|
|
0eebeb9900 |
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -215,6 +215,7 @@ SCHEMA = {
|
||||
"credentialpath": str,
|
||||
"endpointurl": str,
|
||||
Optional("verify", default=False): Bool,
|
||||
Optional("allow_anonymous_login", default=False): Bool,
|
||||
**REMOTE_COMMON,
|
||||
},
|
||||
"ssh": {
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
@@ -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 = [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user