diff --git a/dvc/repo/experiments/queue/workspace.py b/dvc/repo/experiments/queue/workspace.py index 159dfd479f..d261819d37 100644 --- a/dvc/repo/experiments/queue/workspace.py +++ b/dvc/repo/experiments/queue/workspace.py @@ -1,4 +1,5 @@ import logging +import os from collections import defaultdict from typing import TYPE_CHECKING, Collection, Dict, Generator, Optional @@ -6,6 +7,7 @@ from dvc.exceptions import DvcException +from ....utils.fs import remove from ..exceptions import ExpQueueEmptyError from ..executor.base import BaseExecutor, ExecutorResult from ..executor.local import WorkspaceExecutor @@ -116,6 +118,8 @@ def _reproduce_entry( f"Failed to reproduce experiment '{rev[:7]}'" ) from exc finally: + if self._EXEC_NAME == exec_name: + remove(os.path.join(self.pid_dir, exec_name)) executor.cleanup() return results diff --git a/tests/func/experiments/test_experiments.py b/tests/func/experiments/test_experiments.py index 3aec053768..09eb725f00 100644 --- a/tests/func/experiments/test_experiments.py +++ b/tests/func/experiments/test_experiments.py @@ -99,6 +99,9 @@ def test_failed_exp_workspace( tmp_dir.gen("params.yaml", "foo: 2") with pytest.raises(ReproductionError): dvc.experiments.run(failed_exp_stage.addressing) + assert not dvc.fs.exists( + os.path.join(dvc.experiments.workspace_queue.pid_dir, "workspace") + ) @pytest.mark.parametrize(