Skip to content

Commit

Permalink
use dvc_exp_git_remote to set studio repo url (#799)
Browse files Browse the repository at this point in the history
* use dvc_exp_git_remote to set studio repo url

* update min dvc version
  • Loading branch information
Dave Berenbaum authored Mar 11, 2024
1 parent e93dc8a commit 8265d52
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/dvclive/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/dvclive/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_post_to_studio.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
):
Expand Down

0 comments on commit 8265d52

Please sign in to comment.