-
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
[core] Ray Core / Ray Data logging configuration leads to unexpected behavior #48958
base: master
Are you sure you want to change the base?
[core] Ray Core / Ray Data logging configuration leads to unexpected behavior #48958
Conversation
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
I don't know the expected behavior for the |
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.
LG.
Need to change python/ray/_private/log.py
as well since there is old dictConfig
call there.
|
yea let's rewrite to avoid any surprises in the future. |
Signed-off-by: kaihsun <[email protected]>
Co-authored-by: Jiajun Yao <[email protected]> Signed-off-by: Kai-Hsun Chen <[email protected]>
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
python/ray/_private/log.py
Outdated
import threading | ||
|
||
# TODO (kevin85421): It is not used, but a weird error occurs if it is removed. |
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.
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.
Let's spend some time figuring out why.
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.
ray_logging/__init__.py
contains a function setup_component_logger
, which uses logging.handlers.RotatingFileHandler
. However, the file doesn't import logging.handlers
.
Instead, log.py
imports logging.config
, which implicitly imports logging.handlers
.
When the runtime environment agent calls setup_component_logger
, it fails, causing the Raylet to also terminate.
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.
Solution: import logging.handlers
in ray_logging/__init__.py
directly.
python/ray/_private/log.py
Outdated
import threading | ||
|
||
# TODO (kevin85421): It is not used, but a weird error occurs if it is removed. |
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.
Let's spend some time figuring out why.
ray.init(logging_config=ray.LoggingConfig(encoding="TEXT", log_level="INFO")) | ||
new_test_logger = logging.getLogger("ray.test") | ||
assert old_test_logger.getEffectiveLevel() == logging.DEBUG |
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.
so with dictConfig, log level will also be cleared not just handlers?
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.
Yes, see https://github.com/python/cpython/blob/71ede1142ddad2d31cc966b8fe4a5aff664f4d53/Lib/logging/config.py#L193-L196 for more details.
Child logger's level will be set to NOTSET
.
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
Why are these changes needed?
Issue
In the Ray codebase, logging.config.dictConfig may be called multiple times. However, we found that if a logger’s child loggers are set before the logger is set via
dictConfig
, it may cause issues.Example1 (incremental: False): The logger
Ray.data
loses its original handler and uses theRay
logger’s handler after the Ray logger is set viadictConfig
.Example2 (incremental: True): It looks like
Ray.data
’s handlers are removed after theRay
logger is set viadictConfig
.CPython implementation
incremental
isFalse
propagate
attribute will be set to true.Ray.data
is not only an existing logger but also a child logger of Ray. Therefore, its handlers will be reset, and propagate will be set to true.Case 2:
incremental
isTrue
Solution
Instead of using
dictConfig
to set the root logger and the Ray logger, call other functions to set the loggers explicitly.Related issue number
Closes #48732
Checks
Test 1
Test 2
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.