Reduce RLlib log verbosity (#6154)

This commit is contained in:
Eric Liang 2019-11-13 18:50:45 -08:00 committed by GitHub
parent 51e76151d6
commit e4565c9cc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -567,13 +567,18 @@ You can use the `data output API <rllib-offline.html>`__ to save episode traces
Log Verbosity
~~~~~~~~~~~~~
You can control the trainer log level via the ``"log_level"`` flag. Valid values are "INFO" (default), "DEBUG", "WARN", and "ERROR". This can be used to increase or decrease the verbosity of internal logging. For example:
You can control the trainer log level via the ``"log_level"`` flag. Valid values are "DEBUG", "INFO", "WARN" (default), and "ERROR". This can be used to increase or decrease the verbosity of internal logging. You can also use the ``-v`` and ``-vv`` flags. For example, the following two commands are about equivalent:
.. code-block:: bash
rllib train --env=PongDeterministic-v4 \
--run=A2C --config '{"num_workers": 2, "log_level": "DEBUG"}'
rllib train --env=PongDeterministic-v4 \
--run=A2C --config '{"num_workers": 2}' -vv
The default log level is ``WARN``. We strongly recommend using at least ``INFO`` level logging for development.
Stack Traces
~~~~~~~~~~~~

View file

@ -47,7 +47,7 @@ COMMON_CONFIG = {
# Should be one of DEBUG, INFO, WARN, or ERROR. The DEBUG level will also
# periodically print out summaries of relevant internal dataflow (this is
# also printed out once at startup at the INFO level).
"log_level": "INFO",
"log_level": "WARN",
# Callbacks that will be run during various phases of training. These all
# take a single "info" dict as an argument. For episode callbacks, custom
# metrics can be attached to the episode by updating the episode object's
@ -479,6 +479,11 @@ class Trainer(Trainable):
self.raw_user_config = config
self.config = merged_config
Trainer._validate_config(self.config)
log_level = self.config.get("log_level")
if log_level in ["WARN", "ERROR"]:
logger.info("Current log_level is {}. For more information, "
"set 'log_level': 'INFO' / 'DEBUG' or use the -v and "
"-vv flags.".format(log_level))
if self.config.get("log_level"):
logging.getLogger("ray.rllib").setLevel(self.config["log_level"])

View file

@ -88,6 +88,10 @@ def create_parser(parser_creator=None):
default="",
type=str,
help="Optional URI to sync training results to (e.g. s3://bucket).")
parser.add_argument(
"-v", action="store_true", help="Whether to use INFO level logging.")
parser.add_argument(
"-vv", action="store_true", help="Whether to use DEBUG level logging.")
parser.add_argument(
"--resume",
action="store_true",
@ -143,6 +147,7 @@ def run(args, parser):
}
}
verbose = 1
for exp in experiments.values():
if not exp.get("run"):
parser.error("the following arguments are required: --run")
@ -150,6 +155,12 @@ def run(args, parser):
parser.error("the following arguments are required: --env")
if args.eager:
exp["config"]["eager"] = True
if args.v:
exp["config"]["log_level"] = "INFO"
verbose = 2
if args.vv:
exp["config"]["log_level"] = "DEBUG"
verbose = 3
if args.trace:
if not exp["config"].get("eager"):
raise ValueError("Must enable --eager to enable tracing.")
@ -178,6 +189,7 @@ def run(args, parser):
scheduler=_make_scheduler(args),
queue_trials=args.queue_trials,
resume=args.resume,
verbose=verbose,
concurrent=True)