Skip to content

Commit

Permalink
Revert "refactor notify_refs_to_studio"
Browse files Browse the repository at this point in the history
This reverts commit c16d615.
  • Loading branch information
dberenbaum authored and dberenbaum committed Mar 11, 2024
1 parent 827e58f commit 7df58ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
25 changes: 14 additions & 11 deletions dvc/repo/experiments/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from funcy import compact, group_by
from scmrepo.git.backend.base import SyncStatus

from dvc.env import DVC_STUDIO_TOKEN, DVC_STUDIO_URL
from dvc.exceptions import DvcException
from dvc.log import logger
from dvc.repo import locked
Expand Down Expand Up @@ -31,26 +32,28 @@ def __init__(self, msg, result):
def notify_refs_to_studio(
repo: "Repo", git_remote: str, **refs: list[str]
) -> Optional[str]:
from dvc_studio_client.config import get_studio_config

from dvc.utils import studio
import os

config = repo.config["studio"]
refs = compact(refs)
if not refs or env2bool("DVC_TEST"):
return None

config = repo.config["studio"]
config = get_studio_config(dvc_studio_config=config)
token = config.get("token")
studio_url = config.get("url")
token = (
os.environ.get(DVC_STUDIO_TOKEN)
or os.environ.get("STUDIO_TOKEN")
or config.get("token")
)
if not token:
logger.debug("Studio token not found.")
return None
repo_url = studio.get_repo_url(repo, git_remote)
if not repo_url:
logger.debug("Git remote repo URL not found.")
return None

from dulwich.porcelain import get_remote_repo

from dvc.utils import studio

_, repo_url = get_remote_repo(repo.scm.dulwich.repo, git_remote)
studio_url = os.environ.get(DVC_STUDIO_URL) or config.get("url")
d = studio.notify_refs(repo_url, token, base_url=studio_url, **refs)
return d.get("url")

Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/queue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import asdict, dataclass
from typing import TYPE_CHECKING, Any, NamedTuple, Optional, Union

from dvc_studio_client.config import get_studio_config
from dvc_studio_client.post_live_metrics import get_studio_config
from funcy import retry

from dvc.dependency import ParamsDependency
Expand Down
16 changes: 7 additions & 9 deletions dvc/utils/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,17 @@ def get_subrepo_relpath(repo: "Repo") -> str:
return "" if relpath == "." else relpath


def get_repo_url(repo: "Repo", git_remote: Optional[str] = None) -> str | None:
def get_repo_url(repo: "Repo") -> str:
from dulwich.porcelain import get_remote_repo

from dvc.env import DVC_EXP_GIT_REMOTE

if not git_remote:
git_remote = os.getenv(
DVC_EXP_GIT_REMOTE, repo.config.get("exp", {}).get("git_remote")
)
if git_remote:
repo_url = os.getenv(
DVC_EXP_GIT_REMOTE, repo.config.get("exp", {}).get("git_remote")
)
if repo_url:
try:
_, repo_url = get_remote_repo(repo.scm.dulwich.repo, git_remote)
return repo_url
_, repo_url = get_remote_repo(repo.scm.dulwich.repo, repo_url)
except IndexError:
pass
return git_remote
return repo_url

0 comments on commit 7df58ce

Please sign in to comment.