From 0bd34c897718d354505a1b954c4b163d37f9ee72 Mon Sep 17 00:00:00 2001 From: Ivan Shcheklein Date: Sun, 5 Mar 2023 12:47:32 -0800 Subject: [PATCH] fix(push): allow no default remote --- dvc/repo/push.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dvc/repo/push.py b/dvc/repo/push.py index cd4a806c2..e43b5c977 100644 --- a/dvc/repo/push.py +++ b/dvc/repo/push.py @@ -1,5 +1,7 @@ +from contextlib import suppress from typing import TYPE_CHECKING, Optional, Sequence +from dvc.config import NoRemoteError from dvc.exceptions import InvalidArgumentError, UploadError from dvc.utils import glob_targets @@ -30,9 +32,10 @@ def push( # noqa: C901, PLR0913 include_imports=False, ): worktree_remote: Optional["Remote"] = None - _remote = self.cloud.get_remote(name=remote) - if _remote.worktree or _remote.fs.version_aware: - worktree_remote = _remote + with suppress(NoRemoteError): + _remote = self.cloud.get_remote(name=remote) + if _remote and (_remote.worktree or _remote.fs.version_aware): + worktree_remote = _remote pushed = 0 used_run_cache = self.stage_cache.push(remote, odb=odb) if run_cache else []