Dvc: colorama: standardize and apply output message colors

Created on 13 Nov 2019  路  4Comments  路  Source: iterative/dvc

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:
    https://github.com/iterative/dvc/blob/cfc442e932701af5ef94b94d8b70b8bd117fc6f8/dvc/utils/__init__.py#L349-L359
    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 #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'`.)
enhancement good first issue ui

All 4 comments

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 .

Thanks. Should probably use it more or remove it?

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

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...
Was this page helpful?
0 / 5 - 0 ratings

Related issues

robguinness picture robguinness  路  3Comments

analystanand picture analystanand  路  3Comments

siddygups picture siddygups  路  3Comments

GildedHonour picture GildedHonour  路  3Comments

shcheklein picture shcheklein  路  3Comments