From 385674a78bdd867808113fa891ce2fc12db2aad1 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Tue, 22 Oct 2019 16:11:40 -0500 Subject: [PATCH 1/8] dvc: use ' for dynamic output and ` for DVC names (follow-up) continues https://github.com/iterative/dvc/pull/2644#discussion_r338417698 --- dvc/analytics.py | 2 +- dvc/command/diff.py | 2 +- dvc/command/imp_url.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dvc/analytics.py b/dvc/analytics.py index 1ae02f60ac..55baf12253 100644 --- a/dvc/analytics.py +++ b/dvc/analytics.py @@ -164,4 +164,4 @@ def _find_or_create_user_id(): return user_id except LockError: - logger.debug("Failed to acquire {lockfile}".format(lockfile=lockfile)) + logger.debug("Failed to acquire '{lockfile}'".format(lockfile=lockfile)) diff --git a/dvc/command/diff.py b/dvc/command/diff.py index 180508896c..4e82ea520f 100644 --- a/dvc/command/diff.py +++ b/dvc/command/diff.py @@ -31,7 +31,7 @@ def _print_size(size): def _get_md5_string(sign, file_name, checksum): sample_msg = "" if file_name: - sample_msg = "{}{} with md5 {}\n" + sample_msg = "'{}{}' with md5 {}\n" sample_msg = sample_msg.format(sign, file_name, checksum) return sample_msg diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py index e072bc1e34..9c325dbe37 100644 --- a/dvc/command/imp_url.py +++ b/dvc/command/imp_url.py @@ -19,7 +19,7 @@ def run(self): ) except DvcException: logger.exception( - "failed to import {}. You could also try downloading " + "failed to import '{}'. You could also try downloading " "it manually, and adding it with `dvc add`.".format( self.args.url ) From e1f755bbddda5103d4846c0d59fb7329655706ab Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 12:54:31 -0700 Subject: [PATCH 2/8] fix formatting of dvc/analytics.py based on https://github.com/iterative/dvc/pull/2987/files#diff-60f82c04687a06de3f632551d63de49e --- dvc/analytics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dvc/analytics.py b/dvc/analytics.py index 55baf12253..a8969b2ef3 100644 --- a/dvc/analytics.py +++ b/dvc/analytics.py @@ -164,4 +164,6 @@ def _find_or_create_user_id(): return user_id except LockError: - logger.debug("Failed to acquire '{lockfile}'".format(lockfile=lockfile)) + logger.debug( + "Failed to acquire '{lockfile}'".format(lockfile=lockfile) + ) From 3574b0c107181ed0b6a485dac5d5d9f25595234c Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 17:48:09 -0700 Subject: [PATCH 3/8] dvc: use ' for dynamic output (up to lock) --- dvc/command/remove.py | 4 ++-- dvc/config.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dvc/command/remove.py b/dvc/command/remove.py index 179d373f6b..b4b47f98f3 100644 --- a/dvc/command/remove.py +++ b/dvc/command/remove.py @@ -20,7 +20,7 @@ def _is_outs_only(self, target): if self.args.force: return False - msg = "Are you sure you want to remove {} with its outputs?".format( + msg = "Are you sure you want to remove '{}' with its outputs?".format( target ) @@ -38,7 +38,7 @@ def run(self): outs_only = self._is_outs_only(target) self.repo.remove(target, outs_only=outs_only) except DvcException: - logger.exception("failed to remove {}".format(target)) + logger.exception("failed to remove '{}'".format(target)) return 1 return 0 diff --git a/dvc/config.py b/dvc/config.py index 0854ae9304..5c71da3d01 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -81,7 +81,7 @@ def Choices(*choices): *choices: pass allowed values as arguments, or pass a list or tuple as a single argument """ - return Any(*choices, msg="expected one of {}".format(",".join(choices))) + return Any(*choices, msg="expected one of {}".format(", ".join(choices))) class Config(object): # pylint: disable=too-many-instance-attributes From 655fa956d4288beddb708bb23638926cb979c223 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 18:59:45 -0700 Subject: [PATCH 4/8] diff: revert ' in string --- dvc/command/diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/command/diff.py b/dvc/command/diff.py index 4e82ea520f..180508896c 100644 --- a/dvc/command/diff.py +++ b/dvc/command/diff.py @@ -31,7 +31,7 @@ def _print_size(size): def _get_md5_string(sign, file_name, checksum): sample_msg = "" if file_name: - sample_msg = "'{}{}' with md5 {}\n" + sample_msg = "{}{} with md5 {}\n" sample_msg = sample_msg.format(sign, file_name, checksum) return sample_msg From 06822a060e05623df257e754ba0cf218602db169 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 19:00:09 -0700 Subject: [PATCH 5/8] dvc: use ' for dynamic output (through dvc/util/) --- dvc/remote/base.py | 2 +- dvc/remote/oss.py | 6 +++--- dvc/repo/add.py | 2 +- dvc/repo/gc.py | 2 +- dvc/stage.py | 4 ++-- dvc/updater.py | 20 ++++++++++---------- dvc/utils/__init__.py | 4 +++- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 57a1846a66..0f66b27ab0 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -58,7 +58,7 @@ def __init__(self, remote, cmd, ret, err): class RemoteActionNotImplemented(DvcException): def __init__(self, action, scheme): - m = "{} is not supported by {} remote".format(action, scheme) + m = "{} is not supported for {} remotes".format(action, scheme) super(RemoteActionNotImplemented, self).__init__(m) diff --git a/dvc/remote/oss.py b/dvc/remote/oss.py index 9445fd0b2b..0abf1a92e4 100644 --- a/dvc/remote/oss.py +++ b/dvc/remote/oss.py @@ -69,9 +69,9 @@ def __init__(self, repo, config): def oss_service(self): import oss2 - logger.debug("URL {}".format(self.path_info)) - logger.debug("key id {}".format(self.key_id)) - logger.debug("key secret {}".format(self.key_secret)) + logger.debug("URL: {}".format(self.path_info)) + logger.debug("key id: {}".format(self.key_id)) + logger.debug("key secret: {}".format(self.key_secret)) auth = oss2.Auth(self.key_id, self.key_secret) bucket = oss2.Bucket(auth, self.endpoint, self.path_info.bucket) diff --git a/dvc/repo/add.py b/dvc/repo/add.py index 85486c1f78..8fe180d41a 100644 --- a/dvc/repo/add.py +++ b/dvc/repo/add.py @@ -37,7 +37,7 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None): "You are adding a large directory '{target}' recursively," " consider tracking it as a whole instead.\n" "{purple}HINT:{nc} Remove the generated DVC-file and then" - " run {cyan}dvc add {target}{nc}".format( + " run `{cyan}dvc add {target}{nc}`".format( purple=colorama.Fore.MAGENTA, cyan=colorama.Fore.CYAN, nc=colorama.Style.RESET_ALL, diff --git a/dvc/repo/gc.py b/dvc/repo/gc.py index 8313f8feb3..7d8e0dd22f 100644 --- a/dvc/repo/gc.py +++ b/dvc/repo/gc.py @@ -12,7 +12,7 @@ def _do_gc(typ, func, clist): removed = func(clist) if not removed: - logger.info("No unused {} cache to remove.".format(typ)) + logger.info("No unused `{}` cache to remove.".format(typ)) @locked diff --git a/dvc/stage.py b/dvc/stage.py index 236a5f2d39..7aafa5d750 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -116,7 +116,7 @@ def __init__(self, deps): else: dep = "dependency" - msg = "missing {}: {}".format(dep, ", ".join(map(str, deps))) + msg = "missing '{}': {}".format(dep, ", ".join(map(str, deps))) super(MissingDep, self).__init__(msg) @@ -128,7 +128,7 @@ def __init__(self, missing_files): if len(missing_files) > 1: source += "s" - msg = "missing data {}: {}".format(source, ", ".join(missing_files)) + msg = "missing data '{}': {}".format(source, ", ".join(missing_files)) super(MissingDataSource, self).__init__(msg) diff --git a/dvc/updater.py b/dvc/updater.py index 6612219262..4c83084a60 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -124,12 +124,13 @@ def _notify(self): def _get_update_instructions(self): instructions = { - "pip": "Run {yellow}pip{reset} install dvc {blue}--upgrade{reset}", - "rpm": "Run {yellow}yum{reset} update dvc", - "brew": "Run {yellow}brew{reset} upgrade dvc", + "pip": "Run `{yellow}pip{reset} install dvc " + "{blue}--upgrade{reset}`", + "rpm": "Run `{yellow}yum{reset} update dvc`", + "brew": "Run `{yellow}brew{reset} upgrade dvc`", "deb": ( - "Run {yellow}apt-get{reset} install" - " {blue}--only-upgrade{reset} dvc" + "Run `{yellow}apt-get{reset} install" + " {blue}--only-upgrade{reset} dvc`" ), "binary": ( "To upgrade follow these steps:\n" @@ -137,12 +138,11 @@ def _get_update_instructions(self): "2. Go to {blue}https://dvc.org{reset}\n" "3. Download and install new binary" ), - "conda": "Run {yellow}conda{reset} update dvc", - "choco": "Run {yellow}choco{reset} upgrade dvc", + "conda": "Run `{yellow}conda{reset} update dvc`", + "choco": "Run `{yellow}choco{reset} upgrade dvc`", None: ( - "Find the latest release at\n{blue}" - "https://github.com/iterative/dvc/releases/latest" - "{reset}" + "Find the latest release at\n" + "{blue}https://github.com/iterative/dvc/releases/latest{reset}" ), } diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index a1d15aa0b3..92fd34a8a9 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -50,7 +50,9 @@ def file_md5(fname): no_progress_bar = True if size >= LARGE_FILE_SIZE: no_progress_bar = False - msg = "Computing md5 for a large file {}. This is only done once." + msg = ( + "Computing md5 for a large file '{}'. This is only done once." + ) logger.info(msg.format(relpath(fname))) name = relpath(fname) From 14ab7c93d39e49700a15e05fc2e16adced3494b9 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 19:09:22 -0700 Subject: [PATCH 6/8] import-url: revert ' around exception string --- dvc/command/imp_url.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py index 9c325dbe37..e072bc1e34 100644 --- a/dvc/command/imp_url.py +++ b/dvc/command/imp_url.py @@ -19,7 +19,7 @@ def run(self): ) except DvcException: logger.exception( - "failed to import '{}'. You could also try downloading " + "failed to import {}. You could also try downloading " "it manually, and adding it with `dvc add`.".format( self.args.url ) From 781314dc8991cdc98aa5e91f9077a7a6ec789677 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 19:15:27 -0700 Subject: [PATCH 7/8] dvc: fix ` to ' in dvc/repo/gc.py --- dvc/repo/gc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/repo/gc.py b/dvc/repo/gc.py index 7d8e0dd22f..85d681b087 100644 --- a/dvc/repo/gc.py +++ b/dvc/repo/gc.py @@ -12,7 +12,7 @@ def _do_gc(typ, func, clist): removed = func(clist) if not removed: - logger.info("No unused `{}` cache to remove.".format(typ)) + logger.info("No unused '{}' cache to remove.".format(typ)) @locked From 654525cddef86c2df8b090aafff3a6daa5fdc412 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Fri, 20 Dec 2019 19:29:29 -0700 Subject: [PATCH 8/8] add: fix test with ` around DVC command --- tests/func/test_add.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/func/test_add.py b/tests/func/test_add.py index 1d99ed4c1b..3c3b215197 100644 --- a/tests/func/test_add.py +++ b/tests/func/test_add.py @@ -92,7 +92,7 @@ def test_warn_about_large_directories(self): "You are adding a large directory 'large-dir' recursively," " consider tracking it as a whole instead.\n" "{purple}HINT:{nc} Remove the generated DVC-file and then" - " run {cyan}dvc add large-dir{nc}".format( + " run `{cyan}dvc add large-dir{nc}`".format( purple=colorama.Fore.MAGENTA, cyan=colorama.Fore.CYAN, nc=colorama.Style.RESET_ALL,