-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Add rich logging configuration #31205
Add rich logging configuration #31205
Conversation
942333c
to
8d955ac
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
|
e392a4a
to
985fdb9
Compare
b9408b4
to
46262ff
Compare
Been working on this for a few days. Some notes about the work so far:
I think for now I'm going to stop work on this PR, and introduce additional changes in subsequent PRs, otherwise I'll run the risk of this getting bigger than it already is. |
f6baa45
to
a1ca333
Compare
I will defer to @rkooo567 for ray logging in general. But I really like the direction this is going. A few comments on surfacing this to users better:
|
6c91c4d
to
6d80357
Compare
2360353
to
642e467
Compare
💯 Agree, done for both. |
At the moment, this logging configuration specifically avoids touching worker logs - any messages produced internally to Ray that pass through a worker will be handled with a In the next PR, I'd like to implement a system where logs are passed directly to the driver over the network, so we can do away with this intermediate log file approach that bypasses Python's existing logging machinery. |
642e467
to
e950e63
Compare
ac8d655
to
3047833
Compare
3047833
to
f321953
Compare
Looks like the pandas issue is not yet solved? https://buildkite.com/ray-project/oss-ci-build-pr/builds/12347#018652f8-533e-46b6-bd81-9957216ad7a8 |
Made some editing suggestions, hoping to be helpful. Pardon any mangling of the intent. |
Not at all, this is very helpful - thank you!! |
Signed-off-by: pdmurray <[email protected]>
f321953
to
7535248
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have several comments regarding doc. But I think we need some alignment before proceeding the PR. (Let's do that in person next week)
- We should not deprecate logging config option since they are still needed to configure component logs. Or we should have an alternative (e.g., use env var). We also need API review to deprecate this option.
- Actually, I am not sure if we need [Ray Core] (this seems a bit weird to me). I will bring this up internally to get more feedback.
- For user logs from workers, I don't think we need to follow ray's logger at all. All the config from this RFC should be applied to the "library" level logging only (e.g., ray, rllib, tune, train, etc.).
- It looks like we only have support for rllib. Are we handling other libraries in separate PRs?
Wanted to address a few comments before the discussion on Monday:
They are not used to configure component logs here. The logging configuration variables used here call
Thanks, I'd appreciate feedback. I like the idea of having each message provide its associated ray component, but others may disagree.
Yep, that's true. I guess the only thing this PR does related to that is recommend to the users to follow standard python logging practices. I know there are some examples in the docs which run contrary to these practices, but maybe this isn't the place to encourage users in the right direction.
We have support for every component of Ray, because any child loggers of So in short we are handling every library of Ray - |
Please remove a tag when it is ready to review! |
Why are these changes needed?
This PR adds a new default logging configuration based on
rich
for Ray's primary logging needs.Changes
ray/log.py
.ray/__init__.py
at the top of the module. Subsequent calls to the configuration are ignored.ray.init()
:configure_logging
,logging_level
, andlogging_format
. All loggers configured in this PR propagate up to the root logger, so whatever settings the user decides to use for the root logger are what the logs generated byray
will be subject to. If the user doesn't like the configurations introduced here, they can change the configuration through the usual python logging mechanisms rather than throughray
-specific paths; and, if they want to know more about logging, they only need to look in one place:ray/log.py
. For example, if the user wants to suppress everything butCRITICAL
messages, they can doto do this.
rich
is available, the new logging configuration produces nicely formatted log messages which appear in an organized table, improving readability. This is an example of how the new color and formatting can dramatically improve readability ofray
output:Here, log messages are easily distinguished from status information printed to the console; log levels are clearly identified, and appear in the same place in the console no matter the width of the log message; and additional information is now shown, including the
ray
subpackage (shown in yellow here) as well as the file and line number where the message is emitted.rich
is not available, a plain logging format is used instead, and a new log message is displayed suggesting that the user installrich
for nicer output. The user can set theFORCE_PLAIN_LOGGING
environment variable to avoid using the rich logger; this is useful for a lot of tests which rely on the content of stdout to determine the outcome of a test.ray.rllib
is configured at theWARN
level, to address Revert "Simplify logging configuration. (#30863)" #31858. With this change, Revert "Simplify logging configuration. (#30863)" #31858 can be reverted, again simplifying and consolidating logging configuration.test_output.py::test_logger_config
to test only the logger config, not launch a ray cluster. The test was failing intermittently, I think due to a race condition between the launch of the cluster and the reading of the subprocess'sstdout
, and anyway it wasn't necessary to callray.init
here to check that logging was configured correctly.python/ray/tune/tests/test_commands.py::test_ls_with_cfg
to test the underlying data, not what gets printed to stdout (which has changed with the new logging system).Related issue number
Partially addresses #30005.
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.