diff --git a/dvc/dependency/__init__.py b/dvc/dependency/__init__.py index 590787726..7377f94f0 100644 --- a/dvc/dependency/__init__.py +++ b/dvc/dependency/__init__.py @@ -5,7 +5,6 @@ try: except ImportError: from urllib.parse import urlparse -from dvc.exceptions import DvcException from dvc.config import Config from dvc.dependency.base import DependencyBase @@ -25,9 +24,9 @@ DEPS = [ DependencyGS, DependencyHDFS, DependencyHTTP, - DependencyLOCAL, DependencyS3, DependencySSH, + # NOTE: DependencyLOCAL is the default choice ] DEP_MAP = { @@ -60,7 +59,7 @@ def _get(stage, p, info): for d in DEPS: if d.supported(p): return d(stage, p, info) - raise DvcException('Dependency \'{}\' is not supported'.format(p)) + return DependencyLOCAL(stage, p, info) def loadd_from(stage, d_list): diff --git a/dvc/dependency/local.py b/dvc/dependency/local.py index e858cf54a..b5671cbee 100644 --- a/dvc/dependency/local.py +++ b/dvc/dependency/local.py @@ -12,7 +12,7 @@ from dvc.remote.local import RemoteLOCAL class DependencyLOCAL(DependencyBase): - REGEX = r'^(?P(/+|.:\\+)?[^:]*)$' + REGEX = r'^(?P.*)$' DoesNotExistError = DependencyDoesNotExistError IsNotFileOrDirError = DependencyIsNotFileOrDirError diff --git a/dvc/output/__init__.py b/dvc/output/__init__.py index 5a6488350..20e7c92f2 100644 --- a/dvc/output/__init__.py +++ b/dvc/output/__init__.py @@ -1,6 +1,5 @@ import schema -from dvc.exceptions import DvcException from dvc.config import Config from dvc.dependency import SCHEMA, urlparse @@ -14,7 +13,13 @@ from dvc.output.ssh import OutputSSH from dvc.remote import Remote -OUTS = [OutputHDFS, OutputS3, OutputGS, OutputSSH, OutputLOCAL] +OUTS = [ + OutputHDFS, + OutputS3, + OutputGS, + OutputSSH, + # NOTE: OutputLOCAL is the default choice +] OUTS_MAP = {'hdfs': OutputHDFS, 's3': OutputS3, @@ -42,7 +47,7 @@ def _get(stage, p, info, cache, metric): for o in OUTS: if o.supported(p): return o(stage, p, info, cache=cache, remote=None, metric=metric) - raise DvcException('Output \'{}\' is not supported'.format(p)) + return OutputLOCAL(stage, p, info, cache=cache, remote=None, metric=metric) def loadd_from(stage, d_list): diff --git a/tests/test_dependency.py b/tests/test_dependency.py index 57a6f75d0..3799025d5 100644 --- a/tests/test_dependency.py +++ b/tests/test_dependency.py @@ -1,10 +1,15 @@ -from dvc.dependency import _get -from dvc.exceptions import DvcException +from dvc.stage import Stage +from dvc.dependency import _get, DEP_MAP -from tests.basic_env import TestDvc +from tests.test_output import TestOutScheme -class TestUnsupported(TestDvc): - def test(self): - with self.assertRaises(DvcException): - _get(None, 'unsupported://a/b', None) +class TestDepScheme(TestOutScheme): + MAP = DEP_MAP + + TESTS = TestOutScheme.TESTS.copy() + TESTS['http://example.com/path/to/file'] = 'http' + TESTS['https://example.com/path/to/file'] = 'https' + + def _get(self, path): + return _get(Stage(self.dvc), path, None) diff --git a/tests/test_output.py b/tests/test_output.py index d391458da..a93068aaa 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -1,10 +1,30 @@ -from dvc.output import _get -from dvc.exceptions import DvcException +from dvc.stage import Stage +from dvc.output import _get, OUTS_MAP from tests.basic_env import TestDvc -class TestUnsupported(TestDvc): +class TestOutScheme(TestDvc): + MAP = OUTS_MAP + + TESTS = { + 's3://bucket/path': 's3', + 'gs://bucket/path': 'gs', + 'ssh://example.com:/dir/path': 'ssh', + 'hdfs://example.com/dir/path': 'hdfs', + 'path/to/file': '', + 'path\\to\\file': '', + 'file': '', + './file': '', + '.\\file': '', + '../file': '', + '..\\file': '', + 'unknown://path': '', + } + + def _get(self, path): + return _get(Stage(self.dvc), path, None, None, None) + def test(self): - with self.assertRaises(DvcException): - _get(None, 'unsupported://a/b', None, None, None) + for path, cls in self.TESTS.items(): + self.assertIsInstance(self._get(path), self.MAP[cls])