From 2e59a9eaf2db822ecb48a5c3ad2307ec1b34d848 Mon Sep 17 00:00:00 2001 From: DDR Date: Wed, 23 Sep 2020 16:08:02 -0700 Subject: [PATCH 1/4] status: Show friendly message for empty project. When there are no stages in the repo, show a friendly message to that effect and display a getting-started URL. Fixes #4395. --- dvc/command/status.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dvc/command/status.py b/dvc/command/status.py index 54711caf80..be5bdabc93 100644 --- a/dvc/command/status.py +++ b/dvc/command/status.py @@ -1,5 +1,7 @@ import logging +import colorama + from dvc.command.data_sync import CmdDataBase from dvc.exceptions import DvcException @@ -10,6 +12,10 @@ class CmdDataStatus(CmdDataBase): STATUS_LEN = 20 STATUS_INDENT = "\t" UP_TO_DATE_MSG = "Data and pipelines are up to date." + EMPTY_PROJECT_MSG = ( + "There is no data tracked in this project yet.\n" + "See {blue}https://dvc.org/doc/start/data-versioning{nc} to get started!" + ).format(blue=colorama.Fore.BLUE, nc=colorama.Fore.RESET) def _normalize(self, s): s += ":" @@ -61,6 +67,8 @@ def run(self): logger.info(json.dumps(st)) elif st: self._show(st, indent) + elif not self.repo.stages: + logger.info(self.EMPTY_PROJECT_MSG) else: logger.info(self.UP_TO_DATE_MSG) From 1a3764f7d60ef180981522fcdc9f493d7064b5f4 Mon Sep 17 00:00:00 2001 From: DDR Date: Wed, 23 Sep 2020 17:15:51 -0700 Subject: [PATCH 2/4] Fix style check failing due to line too long. (E501) --- dvc/command/status.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dvc/command/status.py b/dvc/command/status.py index be5bdabc93..16284a5818 100644 --- a/dvc/command/status.py +++ b/dvc/command/status.py @@ -14,8 +14,8 @@ class CmdDataStatus(CmdDataBase): UP_TO_DATE_MSG = "Data and pipelines are up to date." EMPTY_PROJECT_MSG = ( "There is no data tracked in this project yet.\n" - "See {blue}https://dvc.org/doc/start/data-versioning{nc} to get started!" - ).format(blue=colorama.Fore.BLUE, nc=colorama.Fore.RESET) + "See {bl}https://dvc.org/doc/start/data-versioning{nc} to get started!" + ).format(bl=colorama.Fore.BLUE, nc=colorama.Fore.RESET) def _normalize(self, s): s += ":" From 26963e43a438dd08b95d50b700ff6e65856a508c Mon Sep 17 00:00:00 2001 From: DDR Date: Wed, 23 Sep 2020 22:31:29 -0700 Subject: [PATCH 3/4] =?UTF-8?q?Use=20format=5Flink(=E2=80=A6)=20as=20sugge?= =?UTF-8?q?sted=20by=20@skshetry,=20vs=20{blue}/{nc}.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since I'd pulled the old syntax out of repo/init.py, I've fixed that up as well so no one makes that mistake again. Note that this adds <>s around the link text, unlike before: +---------------------------------------------------------------------+ | | | DVC has enabled anonymous aggregate usage analytics. | | Read the analytics documentation (and how to opt-out) here: | | | | | +---------------------------------------------------------------------+ This is probably fine, since if we're going to have a standard link format we might as well stick with it consistently. If we don't like it, we can change format_link() I guess. --- dvc/command/status.py | 7 +++---- dvc/repo/init.py | 20 ++++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/dvc/command/status.py b/dvc/command/status.py index 16284a5818..7744e1b377 100644 --- a/dvc/command/status.py +++ b/dvc/command/status.py @@ -1,9 +1,8 @@ import logging -import colorama - from dvc.command.data_sync import CmdDataBase from dvc.exceptions import DvcException +from dvc.utils import format_link logger = logging.getLogger(__name__) @@ -14,8 +13,8 @@ class CmdDataStatus(CmdDataBase): UP_TO_DATE_MSG = "Data and pipelines are up to date." EMPTY_PROJECT_MSG = ( "There is no data tracked in this project yet.\n" - "See {bl}https://dvc.org/doc/start/data-versioning{nc} to get started!" - ).format(bl=colorama.Fore.BLUE, nc=colorama.Fore.RESET) + "See {link} to get started!" + ).format(link=format_link("https://dvc.org/doc/start/data-versioning")) def _normalize(self, s): s += ":" diff --git a/dvc/repo/init.py b/dvc/repo/init.py index 67701c99d3..8584a30c08 100644 --- a/dvc/repo/init.py +++ b/dvc/repo/init.py @@ -10,7 +10,9 @@ from dvc.repo import Repo from dvc.scm import SCM from dvc.scm.base import SCMError -from dvc.utils import boxify, relpath +from dvc.utils import boxify +from dvc.utils import format_link as fmt_link +from dvc.utils import relpath from dvc.utils.fs import remove logger = logging.getLogger(__name__) @@ -22,9 +24,7 @@ def _welcome_message(): boxify( "DVC has enabled anonymous aggregate usage analytics.\n" "Read the analytics documentation (and how to opt-out) here:\n" - "{blue}https://dvc.org/doc/user-guide/analytics{nc}".format( - blue=colorama.Fore.BLUE, nc=colorama.Fore.RESET - ), + + fmt_link("https://dvc.org/doc/user-guide/analytics"), border_color="red", ) ) @@ -32,14 +32,10 @@ def _welcome_message(): msg = ( "{yellow}What's next?{nc}\n" "{yellow}------------{nc}\n" - "- Check out the documentation: {blue}https://dvc.org/doc{nc}\n" - "- Get help and share ideas: {blue}https://dvc.org/chat{nc}\n" - "- Star us on GitHub: {blue}https://github.com/iterative/dvc{nc}" - ).format( - yellow=colorama.Fore.YELLOW, - blue=colorama.Fore.BLUE, - nc=colorama.Fore.RESET, - ) + f"- Check out the documentation: {fmt_link('https://dvc.org/doc')}\n" + f"- Get help and share ideas: {fmt_link('https://dvc.org/chat')}\n" + f"- Star us on GitHub: {fmt_link('https://github.com/iterative/dvc')}" + ).format(yellow=colorama.Fore.YELLOW, nc=colorama.Fore.RESET) logger.info(msg) From 1866a5b8ef45cfe5c4635e12bec4bf25712d3762 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 24 Sep 2020 21:57:22 +0300 Subject: [PATCH 4/4] Update dvc/command/status.py --- dvc/command/status.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dvc/command/status.py b/dvc/command/status.py index 7744e1b377..f020107780 100644 --- a/dvc/command/status.py +++ b/dvc/command/status.py @@ -12,9 +12,9 @@ class CmdDataStatus(CmdDataBase): STATUS_INDENT = "\t" UP_TO_DATE_MSG = "Data and pipelines are up to date." EMPTY_PROJECT_MSG = ( - "There is no data tracked in this project yet.\n" + "There are no data or pipelines tracked in this project yet.\n" "See {link} to get started!" - ).format(link=format_link("https://dvc.org/doc/start/data-versioning")) + ).format(link=format_link("https://dvc.org/doc/start")) def _normalize(self, s): s += ":"