From e072dfefbb2616f5526c523c92072479e0dc7e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 18 Jan 2022 13:18:37 +0545 Subject: [PATCH] repro/exp run: display stage instead of filepath on failure Before it used to say 'failed to reproduce dvc.yaml', which is now changed to print 'failed to reproduce train' or something similar. For stages that are in dvc.yaml in the current working directory, it will just print the stage names. For stages in other dvc.yaml files, it'll print in :. --- dvc/exceptions.py | 6 +++--- dvc/repo/reproduce.py | 2 +- tests/func/experiments/test_experiments.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dvc/exceptions.py b/dvc/exceptions.py index f65f307136..6bc38fb535 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -157,9 +157,9 @@ class InitError(DvcException): class ReproductionError(DvcException): - def __init__(self, dvc_file_name): - self.path = dvc_file_name - super().__init__(f"failed to reproduce '{dvc_file_name}'") + def __init__(self, name): + self.name = name + super().__init__(f"failed to reproduce '{name}'") class BadMetricError(DvcException): diff --git a/dvc/repo/reproduce.py b/dvc/repo/reproduce.py index 3b2116ec9f..cc252b72be 100644 --- a/dvc/repo/reproduce.py +++ b/dvc/repo/reproduce.py @@ -218,7 +218,7 @@ def _reproduce_stages( except CheckpointKilledError: raise except Exception as exc: - raise ReproductionError(stage.relpath) from exc + raise ReproductionError(stage.addressing) from exc if on_unchanged is not None: on_unchanged(unchanged) diff --git a/tests/func/experiments/test_experiments.py b/tests/func/experiments/test_experiments.py index 5019602b90..c71570f2c6 100644 --- a/tests/func/experiments/test_experiments.py +++ b/tests/func/experiments/test_experiments.py @@ -97,7 +97,7 @@ def test_failed_exp(tmp_dir, scm, dvc, exp_stage, mocker, caplog): mocker.patch( "concurrent.futures.Future.exception", - return_value=ReproductionError(exp_stage.relpath), + return_value=ReproductionError(exp_stage.addressing), ) with caplog.at_level(logging.ERROR): dvc.experiments.run(exp_stage.addressing, tmp_dir=True)