diff --git a/dvc/repo/experiments/push.py b/dvc/repo/experiments/push.py index 4c74e6c6ea..c893bb7d27 100644 --- a/dvc/repo/experiments/push.py +++ b/dvc/repo/experiments/push.py @@ -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 @@ -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") diff --git a/dvc/repo/experiments/queue/base.py b/dvc/repo/experiments/queue/base.py index dc5d7966be..742b11348b 100644 --- a/dvc/repo/experiments/queue/base.py +++ b/dvc/repo/experiments/queue/base.py @@ -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 diff --git a/dvc/utils/studio.py b/dvc/utils/studio.py index 3d179589ed..13065c2918 100644 --- a/dvc/utils/studio.py +++ b/dvc/utils/studio.py @@ -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