mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
repo: add get_subrepo_relpath helper for studio live experiments monorepo support
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
d25cb79e0a
commit
44b78b81b9
@@ -135,3 +135,51 @@ def test_dynamic_cache_initialization(tmp_dir, scm):
|
||||
dvc.close()
|
||||
|
||||
Repo(str(tmp_dir)).close()
|
||||
|
||||
|
||||
def test_monorepo_relpath(tmp_dir, scm):
|
||||
from dvc.repo.destroy import destroy
|
||||
|
||||
tmp_dir.gen({"project_a": {}, "subdir/project_b": {}})
|
||||
|
||||
non_monorepo = Repo.init(tmp_dir)
|
||||
assert non_monorepo.subrepo_relpath == ""
|
||||
|
||||
destroy(non_monorepo)
|
||||
|
||||
monorepo_project_a = Repo.init(tmp_dir / "project_a", subdir=True)
|
||||
|
||||
assert monorepo_project_a.subrepo_relpath == "project_a"
|
||||
|
||||
monorepo_project_b = Repo.init(tmp_dir / "subdir" / "project_b", subdir=True)
|
||||
|
||||
assert monorepo_project_b.subrepo_relpath == "subdir/project_b"
|
||||
|
||||
|
||||
def test_virtual_monorepo_relpath(tmp_dir, scm):
|
||||
from dvc.fs.git import GitFileSystem
|
||||
from dvc.repo.destroy import destroy
|
||||
|
||||
tmp_dir.gen({"project_a": {}, "subdir/project_b": {}})
|
||||
scm.commit("initial commit")
|
||||
gfs = GitFileSystem(scm=scm, rev="master")
|
||||
|
||||
non_monorepo = Repo.init(tmp_dir)
|
||||
non_monorepo.fs = gfs
|
||||
non_monorepo.root_dir = "/"
|
||||
|
||||
assert non_monorepo.subrepo_relpath == ""
|
||||
|
||||
destroy(non_monorepo)
|
||||
|
||||
monorepo_project_a = Repo.init(tmp_dir / "project_a", subdir=True)
|
||||
monorepo_project_a.fs = gfs
|
||||
monorepo_project_a.root_dir = "/project_a"
|
||||
|
||||
assert monorepo_project_a.subrepo_relpath == "project_a"
|
||||
|
||||
monorepo_project_b = Repo.init(tmp_dir / "subdir" / "project_b", subdir=True)
|
||||
monorepo_project_b.fs = gfs
|
||||
monorepo_project_b.root_dir = "/subdir/project_b"
|
||||
|
||||
assert monorepo_project_b.subrepo_relpath == "subdir/project_b"
|
||||
|
||||
Reference in New Issue
Block a user