-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
artifacts: add support for monorepo (#10386)
- Loading branch information
Showing
4 changed files
with
212 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from os.path import join, normpath | ||
|
||
import pytest | ||
|
||
from dvc.api import artifacts_show | ||
from dvc.testing.tmp_dir import make_subrepo | ||
from dvc.utils import as_posix | ||
from tests.func.artifacts.test_artifacts import get_tag_and_name, make_artifact | ||
|
||
|
||
@pytest.mark.parametrize("sub", ["sub", ""]) | ||
def test_artifacts_show(tmp_dir, dvc, scm, sub): | ||
subdir = tmp_dir / sub | ||
|
||
dirname = str(subdir.relative_to(tmp_dir)) | ||
tag, name = get_tag_and_name(as_posix(dirname), "myart", "v2.0.0") | ||
make_artifact(tmp_dir, "myart", tag, subdir / "myart.pkl") | ||
|
||
assert artifacts_show(name) == { | ||
"path": normpath(join(dirname, "myart.pkl")), | ||
"rev": scm.get_rev(), | ||
} | ||
assert artifacts_show(name, repo=tmp_dir.fs_path) == { | ||
"path": normpath(join(dirname, "myart.pkl")), | ||
"rev": scm.get_rev(), | ||
} | ||
assert artifacts_show(name, repo=f"file://{tmp_dir.as_posix()}") == { | ||
"path": normpath(join(dirname, "myart.pkl")), | ||
"rev": scm.get_rev(), | ||
} | ||
|
||
assert artifacts_show(name, repo=subdir.fs_path) == { | ||
"path": normpath(join(dirname, "myart.pkl")), | ||
"rev": scm.get_rev(), | ||
} | ||
with subdir.chdir(): | ||
assert artifacts_show(name) == { | ||
"path": normpath(join(dirname, "myart.pkl")), | ||
"rev": scm.get_rev(), | ||
} | ||
|
||
|
||
@pytest.mark.parametrize("sub", ["sub", ""]) | ||
def test_artifacts_show_subrepo(tmp_dir, scm, sub): | ||
subrepo = tmp_dir / "subrepo" | ||
make_subrepo(subrepo, scm) | ||
subdir = subrepo / sub | ||
|
||
dirname = str(subdir.relative_to(tmp_dir)) | ||
tag, name = get_tag_and_name(as_posix(dirname), "myart", "v2.0.0") | ||
make_artifact(subrepo, "myart", tag, subdir / "myart.pkl") | ||
|
||
assert artifacts_show(name) == { | ||
"path": join(dirname, "myart.pkl"), | ||
"rev": scm.get_rev(), | ||
} | ||
assert artifacts_show(name, repo=tmp_dir.fs_path) == { | ||
"path": join(dirname, "myart.pkl"), | ||
"rev": scm.get_rev(), | ||
} | ||
assert artifacts_show(name, repo=f"file://{tmp_dir.as_posix()}") == { | ||
"path": join(dirname, "myart.pkl"), | ||
"rev": scm.get_rev(), | ||
} | ||
|
||
assert artifacts_show(name, repo=subdir.fs_path) == { | ||
"path": str((subdir / "myart.pkl").relative_to(subrepo)), | ||
"rev": scm.get_rev(), | ||
} | ||
with subdir.chdir(): | ||
assert artifacts_show(name) == { | ||
"path": str((subdir / "myart.pkl").relative_to(subrepo)), | ||
"rev": scm.get_rev(), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters