From a41e23a45320efe4431e65e356434bc8d8c42899 Mon Sep 17 00:00:00 2001 From: metalglove Date: Tue, 8 Dec 2020 12:43:53 +0100 Subject: [PATCH] Improve OverlappingOutputsError exception message. (#5015) * trie: updated message for OverlappingOutputsError the message given by the exception was not verbose enough why this exception is thrown. now gives the user more information as to why the overlapping paths should be changed. * test_run_single_stage: fixed test TestShouldRaiseOnOverlappingOutputPaths the test is now updated to reflect the exception message changes. Signed-off-by: metalglove --- dvc/repo/trie.py | 7 ++++--- tests/func/test_run_single_stage.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dvc/repo/trie.py b/dvc/repo/trie.py index d0826d0b9..ca54a5fba 100644 --- a/dvc/repo/trie.py +++ b/dvc/repo/trie.py @@ -25,9 +25,10 @@ def build_outs_trie(stages): overlapping = out if parent and overlapping: msg = ( - "Paths for outs:\n'{}'('{}')\n'{}'('{}')\n" - "overlap. To avoid unpredictable behaviour, " - "rerun command with non overlapping outs paths." + "The output paths:\n'{}'('{}')\n'{}'('{}')\n" + "overlap and are thus in the same tracked directory.\n" + "To keep reproducibility, outputs should be in separate " + "tracked directories or tracked individually." ).format( str(parent), parent.stage.addressing, diff --git a/tests/func/test_run_single_stage.py b/tests/func/test_run_single_stage.py index 24969570e..3db7b0f3e 100644 --- a/tests/func/test_run_single_stage.py +++ b/tests/func/test_run_single_stage.py @@ -830,14 +830,15 @@ class TestShouldRaiseOnOverlappingOutputPaths(TestDvc): data_dir_stage = self.DATA_DIR + DVC_FILE_SUFFIX data_stage = os.path.basename(self.DATA) + DVC_FILE_SUFFIX - self.assertIn("Paths for outs:\n", error_output) + self.assertIn("The output paths:\n", error_output) self.assertIn( f"\n'{self.DATA_DIR}'('{data_dir_stage}')\n", error_output, ) self.assertIn(f"\n'{self.DATA}'('{data_stage}')\n", error_output) self.assertIn( - "\noverlap. To avoid unpredictable behaviour, rerun " - "command with non overlapping outs paths.", + "overlap and are thus in the same tracked directory.\n" + "To keep reproducibility, outputs should be in separate " + "tracked directories or tracked individually.", error_output, )