diff --git a/pyproject.toml b/pyproject.toml index cccce557..353b276c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "dvc>=3.47.0", + "dvc>=3.48.4", "dvc-render>=1.0.0,<2", "dvc-studio-client>=0.20,<1", "funcy", diff --git a/src/dvclive/live.py b/src/dvclive/live.py index 46271159..58a3eca7 100644 --- a/src/dvclive/live.py +++ b/src/dvclive/live.py @@ -19,7 +19,7 @@ import PIL from dvc.exceptions import DvcException -from dvc.utils.studio import get_subrepo_relpath +from dvc.utils.studio import get_repo_url, get_subrepo_relpath from funcy import set_in from ruamel.yaml.representer import RepresenterError @@ -149,6 +149,7 @@ def __init__( self._exp_name: Optional[str] = exp_name or os.getenv(env.DVC_EXP_NAME) self._exp_message: Optional[str] = exp_message self._subdir: Optional[str] = None + self._repo_url: Optional[str] = None self._experiment_rev: Optional[str] = None self._inside_dvc_exp: bool = False self._inside_dvc_pipeline: bool = False @@ -254,6 +255,7 @@ def _init_dvc(self): # noqa: C901 return self._subdir = get_subrepo_relpath(self._dvc_repo) + self._repo_url = get_repo_url(self._dvc_repo) if self._save_dvc_exp: mark_dvclive_only_started(self._exp_name) diff --git a/src/dvclive/studio.py b/src/dvclive/studio.py index fd32f961..31a61e5c 100644 --- a/src/dvclive/studio.py +++ b/src/dvclive/studio.py @@ -121,6 +121,7 @@ def post_to_studio(live: Live, event: Literal["start", "data", "done"]): # noqa live._exp_name, # type: ignore "dvclive", dvc_studio_config=live._dvc_studio_config, + studio_repo_url=live._repo_url, **kwargs, # type: ignore ) if not response: diff --git a/tests/test_post_to_studio.py b/tests/test_post_to_studio.py index 93493f93..4729ba5c 100644 --- a/tests/test_post_to_studio.py +++ b/tests/test_post_to_studio.py @@ -1,6 +1,7 @@ from pathlib import Path import pytest +from dvc.env import DVC_EXP_GIT_REMOTE from dvc_studio_client import DEFAULT_STUDIO_URL from dvc_studio_client.env import DVC_STUDIO_REPO_URL, DVC_STUDIO_TOKEN from PIL import Image as ImagePIL @@ -93,6 +94,17 @@ def test_post_to_studio_subrepo(tmp_dir, mocked_dvc_subrepo, mocked_studio_post) ) +def test_post_to_studio_repo_url(tmp_dir, dvc_repo, mocked_studio_post, monkeypatch): + monkeypatch.setenv(DVC_EXP_GIT_REMOTE, "dvc_exp_git_remote") + + live = Live() + live.log_param("fooparam", 1) + + mocked_post, _ = mocked_studio_post + + assert mocked_post.call_args.kwargs["json"]["repo_url"] == "dvc_exp_git_remote" + + def test_post_to_studio_failed_data_request( tmp_dir, mocker, mocked_dvc_repo, mocked_studio_post ):