mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
fs: raise RemoteNotFoundError (#6375)
This commit is contained in:
+9
-1
@@ -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
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user