mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 20:56:34 +08:00
[cli] Fix colors on light themes (#10577)
This commit is contained in:
@@ -379,7 +379,7 @@ class AWSNodeProvider(NodeProvider):
|
||||
if node.spot_instance_request_id:
|
||||
cli_logger.print(
|
||||
"Terminating instance {} " +
|
||||
cf.gray("(cannot stop spot instances, only terminate)"),
|
||||
cf.dimmed("(cannot stop spot instances, only terminate)"),
|
||||
node_id) # todo: show node name?
|
||||
|
||||
cli_logger.old_info(
|
||||
@@ -388,7 +388,7 @@ class AWSNodeProvider(NodeProvider):
|
||||
"be stopped, only terminated)", node_id)
|
||||
node.terminate()
|
||||
else:
|
||||
cli_logger.print("Stopping instance {} " + cf.gray(
|
||||
cli_logger.print("Stopping instance {} " + cf.dimmed(
|
||||
"(to terminate instead, "
|
||||
"set `cache_stopped_nodes: False` "
|
||||
"under `provider` in the cluster configuration)"),
|
||||
@@ -422,7 +422,7 @@ class AWSNodeProvider(NodeProvider):
|
||||
if on_demand_ids:
|
||||
# todo: show node names?
|
||||
cli_logger.print(
|
||||
"Stopping instances {} " + cf.gray(
|
||||
"Stopping instances {} " + cf.dimmed(
|
||||
"(to terminate instead, "
|
||||
"set `cache_stopped_nodes: False` "
|
||||
"under `provider` in the cluster configuration)"),
|
||||
@@ -437,7 +437,7 @@ class AWSNodeProvider(NodeProvider):
|
||||
if spot_ids:
|
||||
cli_logger.print(
|
||||
"Terminating instances {} " +
|
||||
cf.gray("(cannot stop spot instances, only terminate)"),
|
||||
cf.dimmed("(cannot stop spot instances, only terminate)"),
|
||||
cli_logger.render_list(spot_ids))
|
||||
cli_logger.old_info(
|
||||
logger,
|
||||
|
||||
@@ -138,13 +138,13 @@ def _format_msg(msg: str,
|
||||
tags_list += [k + "=" + v]
|
||||
if tags_list:
|
||||
tags_str = cf.reset(
|
||||
cf.gray(" [{}]".format(", ".join(tags_list))))
|
||||
cf.dimmed(" [{}]".format(", ".join(tags_list))))
|
||||
|
||||
numbering_str = ""
|
||||
if _numbered is not None:
|
||||
chars, i, n = _numbered
|
||||
numbering_str = cf.gray(chars[0] + str(i) + "/" + str(n) +
|
||||
chars[1]) + " "
|
||||
numbering_str = cf.dimmed(chars[0] + str(i) + "/" + str(n) +
|
||||
chars[1]) + " "
|
||||
|
||||
if _no_format:
|
||||
# todo: throw if given args/kwargs?
|
||||
@@ -289,7 +289,7 @@ class _CliLogger():
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self.print(cf.cornflowerBlue(msg), *args, **kwargs)
|
||||
self.print(cf.dodgerBlue(msg), *args, **kwargs)
|
||||
|
||||
return self.indented()
|
||||
|
||||
@@ -326,7 +326,8 @@ class _CliLogger():
|
||||
return
|
||||
|
||||
self._print(
|
||||
cf.cyan(key) + ": " + _format_msg(cf.bold(msg), *args, **kwargs))
|
||||
cf.skyBlue(key) + ": " +
|
||||
_format_msg(cf.bold(msg), *args, **kwargs))
|
||||
|
||||
def verbose(self, msg: str, *args: Any, **kwargs: Any):
|
||||
"""Prints a message if verbosity is not 0.
|
||||
@@ -365,14 +366,14 @@ class _CliLogger():
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self.print(cf.green(msg), *args, **kwargs)
|
||||
self.print(cf.limeGreen(msg), *args, **kwargs)
|
||||
|
||||
def warning(self, msg: str, *args: Any, **kwargs: Any):
|
||||
"""Prints a formatted warning message.
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self.print(cf.yellow(msg), *args, **kwargs)
|
||||
self.print(cf.orange(msg), *args, **kwargs)
|
||||
|
||||
def error(self, msg: str, *args: Any, **kwargs: Any):
|
||||
"""Prints a formatted error message.
|
||||
@@ -543,9 +544,9 @@ class _CliLogger():
|
||||
default = _default
|
||||
|
||||
if default:
|
||||
yn_str = cf.green("Y") + "/" + cf.red("n")
|
||||
yn_str = cf.limeGreen("Y") + "/" + cf.red("n")
|
||||
else:
|
||||
yn_str = cf.green("y") + "/" + cf.red("N")
|
||||
yn_str = cf.limeGreen("y") + "/" + cf.red("N")
|
||||
|
||||
confirm_str = cf.underlined("Confirm [" + yn_str + "]:") + " "
|
||||
|
||||
@@ -559,7 +560,7 @@ class _CliLogger():
|
||||
|
||||
if yes:
|
||||
self._print(complete_str + "y " +
|
||||
cf.gray("[automatic, due to --yes]"))
|
||||
cf.dimmed("[automatic, due to --yes]"))
|
||||
return True
|
||||
|
||||
self._print(complete_str, linefeed=False)
|
||||
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This is an executable script that runs an example of every single CliLogger
|
||||
# function for demonstration purposes. Primarily useful for tuning color and
|
||||
# other formatting.
|
||||
|
||||
from ray.autoscaler.cli_logger import cli_logger
|
||||
import colorful as cf
|
||||
|
||||
cli_logger.old_style = False
|
||||
cli_logger.verbosity = 999
|
||||
cli_logger.detect_colors()
|
||||
|
||||
cli_logger.print(
|
||||
cf.bold("Bold ") + cf.italic("Italic ") + cf.underlined("Underlined"))
|
||||
cli_logger.labeled_value("Label", "value")
|
||||
cli_logger.print("List: {}", cli_logger.render_list([1, 2, 3]))
|
||||
cli_logger.newline()
|
||||
cli_logger.very_verbose("Very verbose")
|
||||
cli_logger.verbose("Verbose")
|
||||
cli_logger.verbose_warning("Verbose warning")
|
||||
cli_logger.verbose_error("Verbose error")
|
||||
cli_logger.print("Info")
|
||||
cli_logger.success("Success")
|
||||
cli_logger.warning("Warning")
|
||||
cli_logger.error("Error")
|
||||
cli_logger.newline()
|
||||
try:
|
||||
cli_logger.abort("Abort")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
cli_logger.doassert(False, "Assert")
|
||||
except Exception:
|
||||
pass
|
||||
cli_logger.newline()
|
||||
cli_logger.confirm(True, "example")
|
||||
cli_logger.newline()
|
||||
with cli_logger.indented():
|
||||
cli_logger.print("Indented")
|
||||
with cli_logger.group("Group"):
|
||||
cli_logger.print("Group contents")
|
||||
with cli_logger.timed("Timed (unimplemented)"):
|
||||
cli_logger.print("Timed contents")
|
||||
with cli_logger.verbatim_error_ctx("Verbtaim error"):
|
||||
cli_logger.print("Error contents")
|
||||
@@ -322,7 +322,7 @@ def teardown_cluster(config_file: str, yes: bool, workers_only: bool,
|
||||
|
||||
cli_logger.print(
|
||||
"{} random worker nodes will not be shut down. " +
|
||||
cf.gray("(due to {})"), cf.bold(min_workers),
|
||||
cf.dimmed("(due to {})"), cf.bold(min_workers),
|
||||
cf.bold("--keep-min-workers"))
|
||||
cli_logger.old_info(logger,
|
||||
"teardown_cluster: Keeping {} nodes...",
|
||||
@@ -334,7 +334,7 @@ def teardown_cluster(config_file: str, yes: bool, workers_only: bool,
|
||||
if workers_only:
|
||||
cli_logger.print(
|
||||
"The head node will not be shut down. " +
|
||||
cf.gray("(due to {})"), cf.bold("--workers-only"))
|
||||
cf.dimmed("(due to {})"), cf.bold("--workers-only"))
|
||||
|
||||
return workers
|
||||
|
||||
|
||||
@@ -339,8 +339,8 @@ def run_cmd_redirected(cmd, silent=False, use_login_shells=False):
|
||||
cli_logger.verbose("Command stdout is redirected to {}",
|
||||
cf.bold(tmp.name))
|
||||
cli_logger.verbose(
|
||||
cf.gray("Use --dump-command-output to "
|
||||
"dump to terminal instead."))
|
||||
cf.dimmed("Use --dump-command-output to "
|
||||
"dump to terminal instead."))
|
||||
|
||||
return _run_and_process_output(
|
||||
cmd,
|
||||
|
||||
@@ -253,7 +253,7 @@ class NodeUpdater:
|
||||
|
||||
cli_logger.print(
|
||||
"SSH still not available {}, "
|
||||
"retrying in {} seconds.", cf.gray(retry_str),
|
||||
"retrying in {} seconds.", cf.dimmed(retry_str),
|
||||
cf.bold(str(READY_CHECK_INTERVAL)))
|
||||
cli_logger.old_debug(logger,
|
||||
"{}Node not up, retrying: {}",
|
||||
|
||||
@@ -839,11 +839,11 @@ def stop(force, verbose, log_new_style, log_color):
|
||||
|
||||
if force:
|
||||
cli_logger.verbose("Killed `{}` {} ", cf.bold(proc_string),
|
||||
cf.gray("(via SIGKILL)"))
|
||||
cf.dimmed("(via SIGKILL)"))
|
||||
else:
|
||||
cli_logger.verbose("Send termination request to `{}` {}",
|
||||
cf.bold(proc_string),
|
||||
cf.gray("(via SIGTERM)"))
|
||||
cf.dimmed("(via SIGTERM)"))
|
||||
|
||||
total_stopped += 1
|
||||
except psutil.NoSuchProcess:
|
||||
|
||||
Reference in New Issue
Block a user