Skip to content

Commit 8265d52

Browse files
author
Dave Berenbaum
authored
use dvc_exp_git_remote to set studio repo url (#799)
* use dvc_exp_git_remote to set studio repo url * update min dvc version
1 parent e93dc8a commit 8265d52

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ classifiers = [
3131
]
3232
dynamic = ["version"]
3333
dependencies = [
34-
"dvc>=3.47.0",
34+
"dvc>=3.48.4",
3535
"dvc-render>=1.0.0,<2",
3636
"dvc-studio-client>=0.20,<1",
3737
"funcy",

src/dvclive/live.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import PIL
2020

2121
from dvc.exceptions import DvcException
22-
from dvc.utils.studio import get_subrepo_relpath
22+
from dvc.utils.studio import get_repo_url, get_subrepo_relpath
2323
from funcy import set_in
2424
from ruamel.yaml.representer import RepresenterError
2525

@@ -149,6 +149,7 @@ def __init__(
149149
self._exp_name: Optional[str] = exp_name or os.getenv(env.DVC_EXP_NAME)
150150
self._exp_message: Optional[str] = exp_message
151151
self._subdir: Optional[str] = None
152+
self._repo_url: Optional[str] = None
152153
self._experiment_rev: Optional[str] = None
153154
self._inside_dvc_exp: bool = False
154155
self._inside_dvc_pipeline: bool = False
@@ -254,6 +255,7 @@ def _init_dvc(self): # noqa: C901
254255
return
255256

256257
self._subdir = get_subrepo_relpath(self._dvc_repo)
258+
self._repo_url = get_repo_url(self._dvc_repo)
257259

258260
if self._save_dvc_exp:
259261
mark_dvclive_only_started(self._exp_name)

src/dvclive/studio.py

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def post_to_studio(live: Live, event: Literal["start", "data", "done"]): # noqa
121121
live._exp_name, # type: ignore
122122
"dvclive",
123123
dvc_studio_config=live._dvc_studio_config,
124+
studio_repo_url=live._repo_url,
124125
**kwargs, # type: ignore
125126
)
126127
if not response:

tests/test_post_to_studio.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22

33
import pytest
4+
from dvc.env import DVC_EXP_GIT_REMOTE
45
from dvc_studio_client import DEFAULT_STUDIO_URL
56
from dvc_studio_client.env import DVC_STUDIO_REPO_URL, DVC_STUDIO_TOKEN
67
from PIL import Image as ImagePIL
@@ -93,6 +94,17 @@ def test_post_to_studio_subrepo(tmp_dir, mocked_dvc_subrepo, mocked_studio_post)
9394
)
9495

9596

97+
def test_post_to_studio_repo_url(tmp_dir, dvc_repo, mocked_studio_post, monkeypatch):
98+
monkeypatch.setenv(DVC_EXP_GIT_REMOTE, "dvc_exp_git_remote")
99+
100+
live = Live()
101+
live.log_param("fooparam", 1)
102+
103+
mocked_post, _ = mocked_studio_post
104+
105+
assert mocked_post.call_args.kwargs["json"]["repo_url"] == "dvc_exp_git_remote"
106+
107+
96108
def test_post_to_studio_failed_data_request(
97109
tmp_dir, mocker, mocked_dvc_repo, mocked_studio_post
98110
):

0 commit comments

Comments
 (0)