fs: raise RemoteNotFoundError (#6375)

This commit is contained in:
Ruslan Kuprieiev
2021-08-02 21:09:55 +03:00
committed by GitHub
parent 15de826266
commit 8d71c3861f
3 changed files with 22 additions and 3 deletions
+9 -1
View File
@@ -20,7 +20,15 @@ class ConfigError(DvcException):
super().__init__(f"config file error: {msg}")
class NoRemoteError(ConfigError):
class RemoteConfigError(ConfigError):
pass
class NoRemoteError(RemoteConfigError):
pass
class RemoteNotFoundError(RemoteConfigError):
pass
+6 -1
View File
@@ -40,7 +40,12 @@ def get_fs_cls(remote_conf):
def get_fs_config(config, **kwargs):
name = kwargs.get("name")
if name:
remote_conf = config["remote"][name.lower()]
try:
remote_conf = config["remote"][name.lower()]
except KeyError:
from dvc.config import RemoteNotFoundError
raise RemoteNotFoundError(f"remote '{name}' doesn't exist")
else:
remote_conf = kwargs
return _resolve_remote_refs(config, remote_conf)
+7 -1
View File
@@ -1,6 +1,7 @@
import pytest
from dvc.fs import get_fs_cls
from dvc.config import RemoteNotFoundError
from dvc.fs import get_fs_cls, get_fs_config
from dvc.fs.hdfs import HDFSFileSystem
from dvc.fs.http import HTTPFileSystem
from dvc.fs.https import HTTPSFileSystem
@@ -29,3 +30,8 @@ from dvc.fs.ssh import SSHFileSystem
)
def test_get_fs_cls(url, cls):
assert get_fs_cls({"url": url}) == cls
def test_get_fs_config():
with pytest.raises(RemoteNotFoundError):
get_fs_config({"remote": {}}, name="myremote")