mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
exp save: Track top level files
This commit is contained in:
@@ -34,6 +34,8 @@ from dvc.repo.experiments.refs import (
|
||||
ExpRefInfo,
|
||||
)
|
||||
from dvc.repo.experiments.utils import to_studio_params
|
||||
from dvc.repo.metrics.show import _collect_top_level_metrics
|
||||
from dvc.repo.params.show import _collect_top_level_params
|
||||
from dvc.stage.serialize import to_lockfile
|
||||
from dvc.ui import ui
|
||||
from dvc.utils import dict_sha256, env2bool, relpath
|
||||
@@ -275,6 +277,13 @@ class BaseExecutor(ABC):
|
||||
else:
|
||||
os.chdir(dvc.root_dir)
|
||||
|
||||
include_untracked = include_untracked or []
|
||||
include_untracked.extend(_collect_top_level_metrics(dvc))
|
||||
include_untracked.extend(_collect_top_level_params(dvc))
|
||||
include_untracked.extend(
|
||||
dvc.index._plot_sources # pylint: disable=protected-access
|
||||
)
|
||||
|
||||
try:
|
||||
stages = dvc.commit([], force=True, relink=False)
|
||||
exp_hash = cls.hash_exp(stages)
|
||||
|
||||
@@ -116,3 +116,23 @@ def test_exp_save_include_untracked_warning(tmp_dir, dvc, scm, mocker):
|
||||
|
||||
dvc.experiments.save(name="exp", include_untracked=["new_dir"])
|
||||
assert not logger.warning.called
|
||||
|
||||
|
||||
def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc):
|
||||
(tmp_dir / "dvc.yaml").dump(
|
||||
{
|
||||
"metrics": ["metrics.json"],
|
||||
"params": ["params.yaml"],
|
||||
"plots": ["plots.csv"],
|
||||
}
|
||||
)
|
||||
stage = dvc.stage.add(
|
||||
cmd="touch metrics.json && touch params.yaml && touch plots.csv",
|
||||
name="top-level",
|
||||
)
|
||||
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
|
||||
dvc.reproduce(stage.addressing)
|
||||
exp = dvc.experiments.save()
|
||||
fs = scm.get_fs(exp)
|
||||
for file in ["metrics.json", "params.yaml", "plots.csv"]:
|
||||
assert fs.exists(file)
|
||||
|
||||
Reference in New Issue
Block a user