From 42c8fab47f7c1e36ca91ab1fa76f1849a8d61381 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 18 Mar 2020 01:14:59 +0200 Subject: [PATCH] version: add supported remotes (#3498) Since our remotes have optional dependencies, it is really useful to be able to see what is currently supported. Also helps debug issues with packages such as brew/conda/etc. --- dvc/command/version.py | 12 ++++++++++++ dvc/remote/base.py | 10 +++++++--- tests/func/test_version.py | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dvc/command/version.py b/dvc/command/version.py index 60c6109d3..3a4fe042d 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -31,6 +31,7 @@ class CmdVersion(CmdBaseNoRepo): "Platform: {}".format(platform.platform()), "Binary: {}".format(is_binary()), "Package: {}".format(PKG), + "Supported remotes: {}".format(self.get_supported_remotes()), ] try: @@ -112,6 +113,17 @@ class CmdVersion(CmdBaseNoRepo): return ", ".join(cache) + @staticmethod + def get_supported_remotes(): + from dvc.remote import REMOTES + + supported_remotes = [] + for remote in REMOTES: + if not remote.get_missing_deps(): + supported_remotes.append(remote.scheme) + + return ", ".join(supported_remotes) + def add_parser(subparsers, parent_parser): VERSION_HELP = "Show DVC version and system/environment information." diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 8ff3046cb..67941b37a 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -108,17 +108,21 @@ class RemoteBASE(object): self.cache_types = config.get("type") or copy(self.DEFAULT_CACHE_TYPES) self.cache_type_confirmed = False - def _check_requires(self, config): + @classmethod + def get_missing_deps(cls): import importlib missing = [] - - for package, module in self.REQUIRES.items(): + for package, module in cls.REQUIRES.items(): try: importlib.import_module(module) except ImportError: missing.append(package) + return missing + + def _check_requires(self, config): + missing = self.get_missing_deps() if not missing: return diff --git a/tests/func/test_version.py b/tests/func/test_version.py index 31d0d7e66..44e44d552 100644 --- a/tests/func/test_version.py +++ b/tests/func/test_version.py @@ -17,6 +17,7 @@ def test_info_in_repo(tmp_dir, dvc, caplog): assert re.search(r"Platform: .*", caplog.text) assert re.search(r"Binary: (True|False)", caplog.text) assert re.search(r"Package: .*", caplog.text) + assert re.search(r"Supported remotes: .*", caplog.text) assert re.search( r"(Cache: (.*link - (not )?supported(,\s)?){3})", caplog.text ) @@ -39,6 +40,7 @@ def test_info_outside_of_repo(tmp_dir, caplog): assert re.search(r"Platform: .*", caplog.text) assert re.search(r"Binary: (True|False)", caplog.text) assert re.search(r"Package: .*", caplog.text) + assert re.search(r"Supported remotes: .*", caplog.text) assert not re.search(r"(Cache: (.*link - (not )?(,\s)?){3})", caplog.text)