Skip to content

Commit 7c220a5

Browse files
authored
[Data] Move logging configuration to python dictionary from yaml (#48093)
## Why are these changes needed? We currently have our default logging configuration as a YAML file that we then load as a python dictionary. This forces us to include the yaml in the ray wheel. This inlines the configuration into a python dictionary to be included in `logging.py`. ## Related issue number ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [x] 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 added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] 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 - [x] Unit tests - [ ] Release tests - [ ] This PR is not tested :( Signed-off-by: Matthew Owen <[email protected]>
1 parent 65ab047 commit 7c220a5

File tree

3 files changed

+49
-45
lines changed

3 files changed

+49
-45
lines changed

python/ray/data/_internal/logging.py

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,53 @@
77

88
import ray
99

10-
DEFAULT_CONFIG_PATH = os.path.abspath(
11-
os.path.join(os.path.dirname(__file__), "logging.yaml")
12-
)
10+
DEFAULT_CONFIG = {
11+
"version": 1,
12+
"disable_existing_loggers": False,
13+
"formatters": {
14+
"ray": {
15+
"format": "%(asctime)s\t%(levelname)s %(filename)s:%(lineno)s -- %(message)s" # noqa: E501
16+
},
17+
"ray_json": {"class": "ray._private.ray_logging.formatters.JSONFormatter"},
18+
},
19+
"filters": {
20+
"console_filter": {"()": "ray.data._internal.logging.HiddenRecordFilter"},
21+
"core_context_filter": {
22+
"()": "ray._private.ray_logging.filters.CoreContextFilter"
23+
},
24+
},
25+
"handlers": {
26+
"file": {
27+
"class": "ray.data._internal.logging.SessionFileHandler",
28+
"formatter": "ray",
29+
"filename": "ray-data.log",
30+
},
31+
"file_json": {
32+
"class": "ray.data._internal.logging.SessionFileHandler",
33+
"formatter": "ray_json",
34+
"filename": "ray-data.log",
35+
"filters": ["core_context_filter"],
36+
},
37+
"console": {
38+
"class": "ray._private.log.PlainRayHandler",
39+
"formatter": "ray",
40+
"level": "INFO",
41+
"filters": ["console_filter"],
42+
},
43+
},
44+
"loggers": {
45+
"ray.data": {
46+
"level": "DEBUG",
47+
"handlers": ["file", "console"],
48+
"propagate": False,
49+
},
50+
"ray.air.util.tensor_extensions": {
51+
"level": "DEBUG",
52+
"handlers": ["file", "console"],
53+
"propagate": False,
54+
},
55+
},
56+
}
1357

1458
# Dictionary of substitutions to be performed when using JSON mode. Handlers with names
1559
# corresponding to keys will be replaced by those corresponding to values.
@@ -119,7 +163,7 @@ def _load_logging_config(config_path: str):
119163
if config_path is not None:
120164
config = _load_logging_config(config_path)
121165
else:
122-
config = _load_logging_config(DEFAULT_CONFIG_PATH)
166+
config = DEFAULT_CONFIG
123167
if log_encoding is not None and log_encoding.upper() == "JSON":
124168
for logger in config["loggers"].values():
125169
for (

python/ray/data/_internal/logging.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def has_ext_modules(self):
809809
]
810810
},
811811
package_data={
812-
"ray": ["includes/*.pxd", "*.pxd", "data/_internal/logging.yaml"],
812+
"ray": ["includes/*.pxd", "*.pxd"],
813813
},
814814
include_package_data=True,
815815
exclude_package_data={

0 commit comments

Comments
 (0)