Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colorama: standardize and apply output message colors #2784

Closed
jorgeorpinel opened this issue Nov 12, 2019 · 5 comments
Closed

colorama: standardize and apply output message colors #2784

jorgeorpinel opened this issue Nov 12, 2019 · 5 comments
Labels
enhancement Enhances DVC good first issue ui user interface / interaction

Comments

@jorgeorpinel
Copy link
Contributor

jorgeorpinel commented Nov 12, 2019

I just recently discovered we're using colorama when reviewing https://github.com/iterative/dvc/pull/2765/files but haven't really noticed it much in most DVC output.

Current use I can see now:

  • colorama.Fore.BLUE is used for some URLs. I like this, should check it's ALL URLs.
  • RED and GREEN are used in the updater. This seems OK.
  • BLUE, RED, and YELLOW in the logger.
  • CYAN (called blue) is used for the man.dvc.org URLs here and here. Not sure we need this per the first bullet (BLUE).
  • MAGENTA for 2 "HINT" messages here and here. Should check it's used in all such hints, and that other "SOMETHING:" messages always have heir own colors.
  • There's this colorize function in dvc/dvc/utils/init.py:

    dvc/dvc/utils/__init__.py

    Lines 349 to 359 in cfc442e

    def colorize(message, color=None):
    """Returns a message in a specified color."""
    if not color:
    return message
    colors = {
    "green": colorama.Fore.GREEN,
    "yellow": colorama.Fore.YELLOW,
    "blue": colorama.Fore.BLUE,
    "red": colorama.Fore.RED,
    }

    but doesn't seem to be in use. Use it or lose it. only used in boxify. Use it more (or remove it).
  • Finally, PR Improve LockError message #2765 may introduce BLUE for sample commands in the output (those surrounded with back ticks for example. Should we apply this everywhere? (Also "dynamic" commands, printed inside single quotes'`.)
@jorgeorpinel jorgeorpinel added the enhancement Enhances DVC label Nov 12, 2019
@efiop efiop added the ui user interface / interaction label Nov 13, 2019
@efiop
Copy link
Contributor

efiop commented Nov 13, 2019

Good catch @jorgeorpinel !

There's this colorize function in dvc/dvc/utils/init.py

It is used in boxify https://github.com/iterative/dvc/blob/master/dvc/utils/__init__.py#L389 .

@jorgeorpinel
Copy link
Contributor Author

Thanks. Should probably use it more or remove it?

@efiop
Copy link
Contributor

efiop commented Nov 13, 2019

@jorgeorpinel Hm, why remove it? But yeah, could definitely use it more :)

@jorgeorpinel
Copy link
Contributor Author

jorgeorpinel commented Nov 13, 2019

Idk. It only knows 4 colors rn, and the resulting syntax is not that easy to read, at least in boxify:

        "{border}{space}{border}\n".format(
            border=colorize(chars["vertical"], color=border_color),
            space=chars["empty"] * box_size_horizontal,

vs. something like

"{blue}text{nc}\n".format(blue=colorama.Fore.BLUE...

DDR0 added a commit to DDR0/dvc that referenced this issue Sep 23, 2020
When there are no stages in the repo, show a friendly message to that
effect and display a getting-started URL.

Fixes iterative#2784.
@skshetry
Copy link
Member

Closing as stale.

@skshetry skshetry closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhances DVC good first issue ui user interface / interaction
Projects
None yet
Development

No branches or pull requests

3 participants