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

[tune] refactor verbosity levels #11767

Merged
merged 33 commits into from
Nov 16, 2020
Merged

Conversation

krfricke
Copy link
Contributor

@krfricke krfricke commented Nov 2, 2020

Why are these changes needed?

Adds a new verbosity level, so we now have four levels:

  • 0 No reporting
  • 1 Experiment-level updates
  • 2 Brief trial-level updates
  • 3 Detailed trial-level updates (like current default, stays the default).

Todo:

  • Add output tests

This PR depends on #11748.

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@krfricke
Copy link
Contributor Author

krfricke commented Nov 5, 2020

I'll update this PR once #11749 is merged.

Kai Fricke added 2 commits November 5, 2020 19:19
# Conflicts:
#	python/ray/tune/logger.py
#	python/ray/tune/syncer.py
#	python/ray/tune/trial.py
#	python/ray/tune/tune.py
#	python/ray/tune/utils/callback.py
@richardliaw richardliaw marked this pull request as ready for review November 6, 2020 23:20
Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry for the late review!) Thanks for opening this PR; the callback is great.

The only main concern for me is that the verbosity enum does not suggest any form of ordering (high verbosity or low verbosity); as a result, it's a bit hard to parse. Can we go with some other enumeration wording?

Comment on lines 27 to 36
def verbose_log(logger: Callable[[str], Any], level: Union[int, Verbosity],
message: str):
"""Log `message` if specified level exceeds global verbosity level.

`logger` should be a Callable, e.g. `logger.info`. It can also be
`print` or a logger method of any other level - or any callable that
accepts a string.
"""
if has_verbosity(level):
logger(message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, doesn't this ruin the file trace? i.e.

2020-11-06 22:38:34,948	DEBUG trial_runner.py:557 -- Waiting for redis server at 172.31.48.39:6379 to respond...

will now show up as:

2020-11-06 22:38:34,948	DEBUG log.py:557 -- Waiting for redis server at 172.31.48.39:6379 to respond...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead just configure the python logging system correctly?

Copy link
Contributor Author

@krfricke krfricke Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By passing the logger this should not happen, right? I.e. in one.py I instantiate a logger, which will log as DEBUG one.py ... - and if I call verbose_log(logger.info, ...) it will use the same logger and thus print the correct file. Right?

I thought about using custom loglevels for this but it seems to be much overhead and might interfere with other parts of Ray. Overall it seems introducing custom log levels is considered bad practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think verbose_log will not use the same logger:

2020-11-09 20:05:56,650	INFO log.py:36 -- Total run time: 2.39 seconds (2.35 seconds for the tuning loop).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(which instead should show tune.py)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran: python examples/async_hyperband_example.py --smoke-test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this almost slipped. You're right, and that's because of our logger format "%(asctime)s\t%(levelname)s %(filename)s:%(lineno)s -- %(message)s" - I thought it was name instead of filename.

Since we currently used it only in one location anyway I removed that utility function. It should be fine now.

python/ray/tune/utils/callback.py Show resolved Hide resolved
python/ray/tune/progress_reporter.py Show resolved Hide resolved
python/ray/tune/progress_reporter.py Outdated Show resolved Hide resolved
python/ray/tune/tune.py Outdated Show resolved Hide resolved
python/ray/tune/progress_reporter.py Outdated Show resolved Hide resolved
python/ray/tune/progress_reporter.py Outdated Show resolved Hide resolved
python/ray/tune/progress_reporter.py Show resolved Hide resolved
python/ray/tune/progress_reporter.py Outdated Show resolved Hide resolved
python/ray/tune/progress_reporter.py Outdated Show resolved Hide resolved
@krfricke
Copy link
Contributor Author

krfricke commented Nov 9, 2020

Thanks for the comments!

Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just need to add tests?

@krfricke
Copy link
Contributor Author

I added more thorough (end to end) output testing

| train_xxxxx_00000 | RUNNING | | complete |
+-------------------+----------+-------+----------+"""

VERBOSE_CMD = """from ray import tune
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I've been saving these as separate py files

@richardliaw richardliaw merged commit 8609e2d into ray-project:master Nov 16, 2020
@krfricke krfricke deleted the tune-verbosity branch November 16, 2020 19:37
richardliaw added a commit to richardliaw/ray that referenced this pull request Nov 18, 2020
This reverts commit 8609e2d.

Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants