Skip to content

Commit c74d181

Browse files
d4l3kfacebook-github-bot
authored andcommitted
cli: change torchx color to blue and fix for closed stdout (#419)
Summary: Fixes #418. Fixes #413. This changes the `torchx` logo color to blue since the PT orange can be confused with an red error message and fixes a bug where `isatty` fails due to `stdout` being closed in strange environments. Color choices: * red/orange - too close to error colors * green - already used by log role/rank prefixes * purple - clashes with green * blue - neutral/meta * cyan - a little too bright (backup if blue is too dark) * black - no * brown - ick * gray - already used for timestamps * white - user feedback is colors are good :) Pull Request resolved: #419 Test Plan: ![2022-03-11-122158_1090x138_scrot](https://user-images.githubusercontent.com/909104/157956804-366cfa94-2bd9-402b-a907-a2d63a9ff259.png) Reviewed By: kiukchung Differential Revision: D34829636 Pulled By: d4l3k fbshipit-source-id: 8651a0e70797b5a49e0fef9a36ee5b414d2b619f
1 parent 2d3a981 commit c74d181

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

torchx/cli/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
import sys
99

1010
# only print colors if outputting directly to a terminal
11-
if sys.stdout.isatty():
11+
if not sys.stdout.closed and sys.stdout.isatty():
1212
GREEN = "\033[32m"
13+
BLUE = "\033[34m"
1314
ORANGE = "\033[38:2:238:76:44m"
1415
GRAY = "\033[2m"
1516
ENDC = "\033[0m"
1617
else:
1718
GREEN = ""
1819
ORANGE = ""
20+
BLUE = ""
1921
GRAY = ""
2022
ENDC = ""

torchx/cli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from torchx.cli.cmd_run import CmdBuiltins, CmdRun
1818
from torchx.cli.cmd_runopts import CmdRunopts
1919
from torchx.cli.cmd_status import CmdStatus
20-
from torchx.cli.colors import ENDC, GRAY, ORANGE
20+
from torchx.cli.colors import ENDC, GRAY, BLUE
2121
from torchx.util.entrypoints import load_group
2222

2323

@@ -97,7 +97,7 @@ def run_main(subcmds: Dict[str, SubCommand], argv: List[str] = sys.argv[1:]) ->
9797
args = parser.parse_args(argv)
9898
logging.basicConfig(
9999
level=args.log_level,
100-
format=f"{ORANGE}torchx{ENDC} {GRAY}%(asctime)s %(levelname)-8s{ENDC} %(message)s",
100+
format=f"{BLUE}torchx{ENDC} {GRAY}%(asctime)s %(levelname)-8s{ENDC} %(message)s",
101101
datefmt="%Y-%m-%d %H:%M:%S",
102102
)
103103
if "func" not in args:

0 commit comments

Comments
 (0)