Skip to content

Commit f35cf7e

Browse files
authored
exp run: --reset no longer implies --force (#5751)
* exp run: --reset no longer implies --force * ref update still needs to be forced on checkpoint --reset
1 parent 4f8cfc0 commit f35cf7e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

dvc/repo/experiments/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ def reproduce_one(
324324

325325
if reset:
326326
self.reset_checkpoints()
327-
kwargs["force"] = True
328327

329328
if not (queue or tmp_dir):
330329
staged, _, _ = self.scm.status()

dvc/repo/experiments/executor/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def filter_pipeline(stages):
271271
# - if run without --reset, the checkpoint out will be checked out
272272
# using any hash present in dvc.lock (or removed if no entry
273273
# exists in dvc.lock)
274-
checkpoint_reset = kwargs.pop("reset", False)
274+
checkpoint_reset: bool = kwargs.pop("reset", False)
275275
dvc_checkout(
276276
dvc,
277277
targets=targets,
@@ -283,7 +283,10 @@ def filter_pipeline(stages):
283283
)
284284

285285
checkpoint_func = partial(
286-
cls.checkpoint_callback, dvc.scm, name, repro_force
286+
cls.checkpoint_callback,
287+
dvc.scm,
288+
name,
289+
repro_force or checkpoint_reset,
287290
)
288291
stages = dvc_reproduce(
289292
dvc,
@@ -295,12 +298,18 @@ def filter_pipeline(stages):
295298

296299
exp_hash = cls.hash_exp(stages)
297300
try:
301+
is_checkpoint = any(stage.is_checkpoint for stage in stages)
302+
if is_checkpoint and checkpoint_reset:
303+
# For reset checkpoint stages, we need to force overwriting
304+
# existing checkpoint refs even though repro may not have
305+
# actually been run with --force
306+
repro_force = True
298307
cls.commit(
299308
dvc.scm,
300309
exp_hash,
301310
exp_name=name,
302311
force=repro_force,
303-
checkpoint=any(stage.is_checkpoint for stage in stages),
312+
checkpoint=is_checkpoint,
304313
)
305314
except UnchangedExperimentError:
306315
pass

0 commit comments

Comments
 (0)