diff --git a/dvc/stage/__init__.py b/dvc/stage/__init__.py index 325c90704..254f18791 100644 --- a/dvc/stage/__init__.py +++ b/dvc/stage/__init__.py @@ -273,7 +273,7 @@ class Stage(params.StageParams): from dvc.output import Output from dvc.schema import LIVE_PROPS - env[DVCLIVE_PATH] = str(out.path_info) + env[DVCLIVE_PATH] = relpath(out.path_info, self.wdir) if isinstance(out.live, dict): config = project(out.live, LIVE_PROPS) diff --git a/tests/func/test_live.py b/tests/func/test_live.py index f6989895f..7cea6939e 100644 --- a/tests/func/test_live.py +++ b/tests/func/test_live.py @@ -255,3 +255,22 @@ def test_dvc_generates_html_during_run(tmp_dir, dvc, mocker, live_stage): live_stage(summary=True, live="logs", code=script) assert show_spy.call_count == 2 + + +def test_dvclive_stage_with_different_wdir(tmp_dir, scm, dvc): + (tmp_dir / "subdir").gen("train.py", LIVE_SCRIPT) + (tmp_dir / "subdir" / "params.yaml").dump({"foo": 1}) + dvc.stage.add( + cmd="python train.py", + params=["foo"], + deps=["train.py"], + name="live_stage", + live="dvclive", + live_no_html=True, + wdir="subdir", + ) + + dvc.reproduce() + + assert (tmp_dir / "subdir" / "dvclive").is_dir() + assert (tmp_dir / "subdir" / "dvclive.json").is_file()