Skip to content

Commit a664059

Browse files
DDR0efiop
andauthored
status: Show friendly message for empty project. (#4609)
* 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. * Fix style check failing due to line too long. (E501) * Use format_link(…) as suggested by @skshetry, vs {blue}/{nc}. 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: | | <https://dvc.org/doc/user-guide/analytics> | | | +---------------------------------------------------------------------+ 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. * Update dvc/command/status.py Co-authored-by: Ruslan Kuprieiev <[email protected]>
1 parent c94ab35 commit a664059

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

dvc/command/status.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from dvc.command.data_sync import CmdDataBase
44
from dvc.exceptions import DvcException
5+
from dvc.utils import format_link
56

67
logger = logging.getLogger(__name__)
78

@@ -10,6 +11,10 @@ class CmdDataStatus(CmdDataBase):
1011
STATUS_LEN = 20
1112
STATUS_INDENT = "\t"
1213
UP_TO_DATE_MSG = "Data and pipelines are up to date."
14+
EMPTY_PROJECT_MSG = (
15+
"There are no data or pipelines tracked in this project yet.\n"
16+
"See {link} to get started!"
17+
).format(link=format_link("https://dvc.org/doc/start"))
1318

1419
def _normalize(self, s):
1520
s += ":"
@@ -61,6 +66,8 @@ def run(self):
6166
logger.info(json.dumps(st))
6267
elif st:
6368
self._show(st, indent)
69+
elif not self.repo.stages:
70+
logger.info(self.EMPTY_PROJECT_MSG)
6471
else:
6572
logger.info(self.UP_TO_DATE_MSG)
6673

dvc/repo/init.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from dvc.repo import Repo
1111
from dvc.scm import SCM
1212
from dvc.scm.base import SCMError
13-
from dvc.utils import boxify, relpath
13+
from dvc.utils import boxify
14+
from dvc.utils import format_link as fmt_link
15+
from dvc.utils import relpath
1416
from dvc.utils.fs import remove
1517

1618
logger = logging.getLogger(__name__)
@@ -22,24 +24,18 @@ def _welcome_message():
2224
boxify(
2325
"DVC has enabled anonymous aggregate usage analytics.\n"
2426
"Read the analytics documentation (and how to opt-out) here:\n"
25-
"{blue}https://dvc.org/doc/user-guide/analytics{nc}".format(
26-
blue=colorama.Fore.BLUE, nc=colorama.Fore.RESET
27-
),
27+
+ fmt_link("https://dvc.org/doc/user-guide/analytics"),
2828
border_color="red",
2929
)
3030
)
3131

3232
msg = (
3333
"{yellow}What's next?{nc}\n"
3434
"{yellow}------------{nc}\n"
35-
"- Check out the documentation: {blue}https://dvc.org/doc{nc}\n"
36-
"- Get help and share ideas: {blue}https://dvc.org/chat{nc}\n"
37-
"- Star us on GitHub: {blue}https://github.com/iterative/dvc{nc}"
38-
).format(
39-
yellow=colorama.Fore.YELLOW,
40-
blue=colorama.Fore.BLUE,
41-
nc=colorama.Fore.RESET,
42-
)
35+
f"- Check out the documentation: {fmt_link('https://dvc.org/doc')}\n"
36+
f"- Get help and share ideas: {fmt_link('https://dvc.org/chat')}\n"
37+
f"- Star us on GitHub: {fmt_link('https://github.com/iterative/dvc')}"
38+
).format(yellow=colorama.Fore.YELLOW, nc=colorama.Fore.RESET)
4339

4440
logger.info(msg)
4541

0 commit comments

Comments
 (0)