mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Revert "refactor notify_refs_to_studio"
This reverts commit c16d615b55f2bb359b731939ad22712a502d8a8d.
This commit is contained in:
committed by
Dave Berenbaum
parent
827e58f305
commit
7df58ce404
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union
|
|||||||
from funcy import compact, group_by
|
from funcy import compact, group_by
|
||||||
from scmrepo.git.backend.base import SyncStatus
|
from scmrepo.git.backend.base import SyncStatus
|
||||||
|
|
||||||
|
from dvc.env import DVC_STUDIO_TOKEN, DVC_STUDIO_URL
|
||||||
from dvc.exceptions import DvcException
|
from dvc.exceptions import DvcException
|
||||||
from dvc.log import logger
|
from dvc.log import logger
|
||||||
from dvc.repo import locked
|
from dvc.repo import locked
|
||||||
@@ -31,26 +32,28 @@ class UploadError(DvcException):
|
|||||||
def notify_refs_to_studio(
|
def notify_refs_to_studio(
|
||||||
repo: "Repo", git_remote: str, **refs: list[str]
|
repo: "Repo", git_remote: str, **refs: list[str]
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
from dvc_studio_client.config import get_studio_config
|
import os
|
||||||
|
|
||||||
from dvc.utils import studio
|
|
||||||
|
|
||||||
|
config = repo.config["studio"]
|
||||||
refs = compact(refs)
|
refs = compact(refs)
|
||||||
if not refs or env2bool("DVC_TEST"):
|
if not refs or env2bool("DVC_TEST"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
config = repo.config["studio"]
|
token = (
|
||||||
config = get_studio_config(dvc_studio_config=config)
|
os.environ.get(DVC_STUDIO_TOKEN)
|
||||||
token = config.get("token")
|
or os.environ.get("STUDIO_TOKEN")
|
||||||
studio_url = config.get("url")
|
or config.get("token")
|
||||||
|
)
|
||||||
if not token:
|
if not token:
|
||||||
logger.debug("Studio token not found.")
|
logger.debug("Studio token not found.")
|
||||||
return None
|
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)
|
d = studio.notify_refs(repo_url, token, base_url=studio_url, **refs)
|
||||||
return d.get("url")
|
return d.get("url")
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from collections.abc import Collection, Generator, Iterable, Mapping
|
|||||||
from dataclasses import asdict, dataclass
|
from dataclasses import asdict, dataclass
|
||||||
from typing import TYPE_CHECKING, Any, NamedTuple, Optional, Union
|
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 funcy import retry
|
||||||
|
|
||||||
from dvc.dependency import ParamsDependency
|
from dvc.dependency import ParamsDependency
|
||||||
|
|||||||
+7
-9
@@ -128,19 +128,17 @@ def get_subrepo_relpath(repo: "Repo") -> str:
|
|||||||
return "" if relpath == "." else relpath
|
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 dulwich.porcelain import get_remote_repo
|
||||||
|
|
||||||
from dvc.env import DVC_EXP_GIT_REMOTE
|
from dvc.env import DVC_EXP_GIT_REMOTE
|
||||||
|
|
||||||
if not git_remote:
|
repo_url = os.getenv(
|
||||||
git_remote = os.getenv(
|
DVC_EXP_GIT_REMOTE, repo.config.get("exp", {}).get("git_remote")
|
||||||
DVC_EXP_GIT_REMOTE, repo.config.get("exp", {}).get("git_remote")
|
)
|
||||||
)
|
if repo_url:
|
||||||
if git_remote:
|
|
||||||
try:
|
try:
|
||||||
_, repo_url = get_remote_repo(repo.scm.dulwich.repo, git_remote)
|
_, repo_url = get_remote_repo(repo.scm.dulwich.repo, repo_url)
|
||||||
return repo_url
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
return git_remote
|
return repo_url
|
||||||
|
|||||||
Reference in New Issue
Block a user