mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-12 07:18:23 +01:00
experiments: fix git stash mtime race condition (#4727)
This commit is contained in:
@@ -263,9 +263,6 @@ class Experiments:
|
||||
if os.path.getsize(tmp):
|
||||
logger.debug("Patching experiment workspace")
|
||||
self.scm.repo.git.apply(tmp)
|
||||
elif not params and not allow_unchanged:
|
||||
# experiment matches original baseline
|
||||
raise UnchangedExperimentError(rev)
|
||||
finally:
|
||||
remove(tmp)
|
||||
|
||||
@@ -273,6 +270,10 @@ class Experiments:
|
||||
if params:
|
||||
self._update_params(params)
|
||||
|
||||
if not self.scm.is_dirty(untracked_files=True) and not allow_unchanged:
|
||||
# experiment matches original baseline
|
||||
raise UnchangedExperimentError(rev)
|
||||
|
||||
# save additional repro command line arguments
|
||||
self._pack_args(*args, **kwargs)
|
||||
|
||||
@@ -317,6 +318,12 @@ class Experiments:
|
||||
with modify_data(path, tree=self.exp_dvc.tree) as data:
|
||||
_update(data, params[params_fname])
|
||||
|
||||
# Force params file changes to be staged in git
|
||||
# Otherwise in certain situations the changes to params file may be
|
||||
# ignored when we `git stash` them since mtime is used to determine
|
||||
# whether the file is dirty
|
||||
self.scm.add(list(params.keys()))
|
||||
|
||||
def _commit(
|
||||
self, exp_hash, check_exists=True, create_branch=True, checkpoint=False
|
||||
):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
from flaky.flaky_decorator import flaky
|
||||
from funcy import first
|
||||
|
||||
from dvc.utils.serialize import PythonFileCorruptedError
|
||||
@@ -206,8 +205,6 @@ def test_update_py_params(tmp_dir, scm, dvc):
|
||||
dvc.experiments.run(stage.addressing, params=["params.py:INT=2a"])
|
||||
|
||||
|
||||
# See: https://github.com/iterative/dvc/issues/4717
|
||||
@flaky(max_runs=3, min_passes=1)
|
||||
def test_extend_branch(tmp_dir, scm, dvc):
|
||||
tmp_dir.gen("copy.py", COPY_SCRIPT)
|
||||
tmp_dir.gen("params.yaml", "foo: 1")
|
||||
@@ -232,6 +229,7 @@ def test_extend_branch(tmp_dir, scm, dvc):
|
||||
)
|
||||
exp_b = first(results)
|
||||
|
||||
assert exp_a != exp_b
|
||||
assert dvc.experiments._get_branch_containing(exp_b) == exp_branch
|
||||
|
||||
dvc.experiments.checkout(exp_a)
|
||||
|
||||
Reference in New Issue
Block a user